Skip to content

Commit

Permalink
ci: adding sample build (#2150)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
3 people committed Mar 21, 2024
1 parent fa67d0f commit 79988b2
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
34 changes: 34 additions & 0 deletions .cloudbuild/samples_build.yaml
@@ -0,0 +1,34 @@
steps:
- name: gcr.io/cloud-devrel-public-resources/java8
entrypoint: ls
args: [
'-alt',
]
- name: gcr.io/cloud-devrel-public-resources/java8
entrypoint: curl
args: [
'--header',
'Metadata-Flavor: Google',
'http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/email'
]
- name: gcr.io/cloud-devrel-public-resources/java8
entrypoint: pwd
- name: gcr.io/cloud-devrel-public-resources/java8
entrypoint: bash
args: [
'.kokoro/build.sh'
]
env:
- 'JOB_TYPE=samples'
- 'GOOGLE_CLOUD_PROJECT=cloud-java-ci-sample'
- 'BIGTABLE_TESTING_INSTANCE=instance'
- name: gcr.io/cloud-devrel-public-resources/java8
entrypoint: echo
args: [
'Sample job succeeded',
]
timeout: 3600s
options:
defaultLogsBucketBehavior: REGIONAL_USER_OWNED_BUCKET


Expand Up @@ -18,6 +18,12 @@

import static org.junit.Assert.assertThat;

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

@BeforeClass
public static void beforeClass() {
public static void beforeClass() throws IOException {
initializeVariables();

// set up required table and row data if not present
try (BigtableTableAdminClient tableAdminClient =
BigtableTableAdminClient.create(projectId, instanceId)) {
String columnFamily = "cf1";
if (!tableAdminClient.exists(TABLE_ID)) {
tableAdminClient.createTable(CreateTableRequest.of(TABLE_ID).addFamily(columnFamily));
}
try (BigtableDataClient dataClient = BigtableDataClient.create(projectId, instanceId)) {
String rowKey = "r1";
Row row = dataClient.readRow(TABLE_ID, rowKey);
if (row == null) {
dataClient.mutateRow(
RowMutation.create(TABLE_ID, rowKey).setCell(columnFamily, "c1", "quickstart"));
}
}
}
}

@Test
Expand Down

0 comments on commit 79988b2

Please sign in to comment.