Skip to content

Commit fe54eda

Browse files
suztomokolea2gcf-owl-bot[bot]
authored
ci: adding sample build (#2150)
* ci: adding sample build * BIGTABLE_TESTING_INSTANCE=instance * trigger build * add setup for quickstart test See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: kolea2 <kaoleary@google.com> Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent e181bd1 commit fe54eda

2 files changed

Lines changed: 58 additions & 1 deletion

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
steps:
2+
- name: gcr.io/cloud-devrel-public-resources/java8
3+
entrypoint: ls
4+
args: [
5+
'-alt',
6+
]
7+
- name: gcr.io/cloud-devrel-public-resources/java8
8+
entrypoint: curl
9+
args: [
10+
'--header',
11+
'Metadata-Flavor: Google',
12+
'http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/email'
13+
]
14+
- name: gcr.io/cloud-devrel-public-resources/java8
15+
entrypoint: pwd
16+
- name: gcr.io/cloud-devrel-public-resources/java8
17+
entrypoint: bash
18+
args: [
19+
'.kokoro/build.sh'
20+
]
21+
env:
22+
- 'JOB_TYPE=samples'
23+
- 'GOOGLE_CLOUD_PROJECT=cloud-java-ci-sample'
24+
- 'BIGTABLE_TESTING_INSTANCE=instance'
25+
- name: gcr.io/cloud-devrel-public-resources/java8
26+
entrypoint: echo
27+
args: [
28+
'Sample job succeeded',
29+
]
30+
timeout: 3600s
31+
options:
32+
defaultLogsBucketBehavior: REGIONAL_USER_OWNED_BUCKET
33+
34+

java-bigtable/samples/snippets/src/test/java/com/example/bigtable/QuickstartTest.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818

1919
import static org.junit.Assert.assertThat;
2020

21+
import com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient;
22+
import com.google.cloud.bigtable.admin.v2.models.CreateTableRequest;
23+
import com.google.cloud.bigtable.data.v2.BigtableDataClient;
24+
import com.google.cloud.bigtable.data.v2.models.Row;
25+
import com.google.cloud.bigtable.data.v2.models.RowMutation;
26+
import java.io.IOException;
2127
import org.hamcrest.CoreMatchers;
2228
import org.junit.BeforeClass;
2329
import org.junit.Test;
@@ -28,8 +34,25 @@ public class QuickstartTest extends BigtableBaseTest {
2834
private static final String TABLE_ID = "quickstart-table";
2935

3036
@BeforeClass
31-
public static void beforeClass() {
37+
public static void beforeClass() throws IOException {
3238
initializeVariables();
39+
40+
// set up required table and row data if not present
41+
try (BigtableTableAdminClient tableAdminClient =
42+
BigtableTableAdminClient.create(projectId, instanceId)) {
43+
String columnFamily = "cf1";
44+
if (!tableAdminClient.exists(TABLE_ID)) {
45+
tableAdminClient.createTable(CreateTableRequest.of(TABLE_ID).addFamily(columnFamily));
46+
}
47+
try (BigtableDataClient dataClient = BigtableDataClient.create(projectId, instanceId)) {
48+
String rowKey = "r1";
49+
Row row = dataClient.readRow(TABLE_ID, rowKey);
50+
if (row == null) {
51+
dataClient.mutateRow(
52+
RowMutation.create(TABLE_ID, rowKey).setCell(columnFamily, "c1", "quickstart"));
53+
}
54+
}
55+
}
3356
}
3457

3558
@Test

0 commit comments

Comments
 (0)