From 6b8a0421be761c6c1a7e8fe5b35f68925517f17c Mon Sep 17 00:00:00 2001 From: Igor Bernstein Date: Tue, 16 Jul 2019 18:07:15 -0400 Subject: [PATCH 1/9] Bigtable: Add ability to run tests against direct path * Reorganize failsafe config to have a separate execution for each test integration test target * Move each test integration target into it's own profile (keeping the emulator tests on by default) * Fork the ProdEnv for direct path environment --- .kokoro/continuous/bigtable-it.cfg | 2 +- .kokoro/nightly/bigtable-it.cfg | 2 +- .kokoro/presubmit/bigtable-it.cfg | 2 +- .../google-cloud-bigtable/pom.xml | 104 +++++++++- .../scripts/setup-test-table.sh | 35 +++- .../data/v2/it/env/DirectPathEnv.java | 182 ++++++++++++++++++ .../bigtable/data/v2/it/env/TestEnvRule.java | 6 + 7 files changed, 318 insertions(+), 15 deletions(-) create mode 100644 google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/env/DirectPathEnv.java diff --git a/.kokoro/continuous/bigtable-it.cfg b/.kokoro/continuous/bigtable-it.cfg index b5129e51121e..dd830ea20f16 100644 --- a/.kokoro/continuous/bigtable-it.cfg +++ b/.kokoro/continuous/bigtable-it.cfg @@ -8,7 +8,7 @@ env_vars: { env_vars: { key: "INTEGRATION_TEST_ARGS" - value: "google-cloud-clients/google-cloud-bigtable -Dbigtable.env=prod -Dbigtable.project=gcloud-devel -Dbigtable.instance=google-cloud-bigtable -Dbigtable.table=integration-tests" + value: "google-cloud-clients/google-cloud-bigtable -P bigtable-emulator-it,bigtable-prod-it -Dbigtable.project=gcloud-devel -Dbigtable.instance=google-cloud-bigtable -Dbigtable.table=integration-tests" } env_vars: { diff --git a/.kokoro/nightly/bigtable-it.cfg b/.kokoro/nightly/bigtable-it.cfg index b5129e51121e..dd830ea20f16 100644 --- a/.kokoro/nightly/bigtable-it.cfg +++ b/.kokoro/nightly/bigtable-it.cfg @@ -8,7 +8,7 @@ env_vars: { env_vars: { key: "INTEGRATION_TEST_ARGS" - value: "google-cloud-clients/google-cloud-bigtable -Dbigtable.env=prod -Dbigtable.project=gcloud-devel -Dbigtable.instance=google-cloud-bigtable -Dbigtable.table=integration-tests" + value: "google-cloud-clients/google-cloud-bigtable -P bigtable-emulator-it,bigtable-prod-it -Dbigtable.project=gcloud-devel -Dbigtable.instance=google-cloud-bigtable -Dbigtable.table=integration-tests" } env_vars: { diff --git a/.kokoro/presubmit/bigtable-it.cfg b/.kokoro/presubmit/bigtable-it.cfg index b5129e51121e..dd830ea20f16 100644 --- a/.kokoro/presubmit/bigtable-it.cfg +++ b/.kokoro/presubmit/bigtable-it.cfg @@ -8,7 +8,7 @@ env_vars: { env_vars: { key: "INTEGRATION_TEST_ARGS" - value: "google-cloud-clients/google-cloud-bigtable -Dbigtable.env=prod -Dbigtable.project=gcloud-devel -Dbigtable.instance=google-cloud-bigtable -Dbigtable.table=integration-tests" + value: "google-cloud-clients/google-cloud-bigtable -P bigtable-emulator-it,bigtable-prod-it -Dbigtable.project=gcloud-devel -Dbigtable.instance=google-cloud-bigtable -Dbigtable.table=integration-tests" } env_vars: { diff --git a/google-cloud-clients/google-cloud-bigtable/pom.xml b/google-cloud-clients/google-cloud-bigtable/pom.xml index e0c0c41a209b..663251ebb210 100644 --- a/google-cloud-clients/google-cloud-bigtable/pom.xml +++ b/google-cloud-clients/google-cloud-bigtable/pom.xml @@ -76,20 +76,108 @@ test + + + + bigtable-emulator-it + + true + + + + + + maven-failsafe-plugin + + + emulator-it + + integration-test + verify + + + + prod + + com.google.cloud.bigtable.data.v2.it.** + target/failsafe-reports/failsafe-summary-emulator-it.xml + + + + + + + + + + bigtable-prod-it + + + + maven-failsafe-plugin + + + prod-it + + integration-test + verify + + + + prod + + com.google.cloud.bigtable.data.v2.it.** + com.google.cloud.bigtable.admin.v2.it.** + target/failsafe-reports/failsafe-summary-prod-it.xml + + + + + + + + + + bigtable-directpath-it + + + + maven-failsafe-plugin + + + directpath-it + + integration-test + verify + + + + direct_path + + true + + + + bigtable + + + com.google.cloud.bigtable.data.v2.it.** + target/failsafe-reports/failsafe-summary-directpath-it.xml + + + + + + + + + org.apache.maven.plugins maven-failsafe-plugin 3.0.0-M3 - - - - integration-test - verify - - - classes true diff --git a/google-cloud-clients/google-cloud-bigtable/scripts/setup-test-table.sh b/google-cloud-clients/google-cloud-bigtable/scripts/setup-test-table.sh index 1ebedb0f6007..15b564a9d0b2 100755 --- a/google-cloud-clients/google-cloud-bigtable/scripts/setup-test-table.sh +++ b/google-cloud-clients/google-cloud-bigtable/scripts/setup-test-table.sh @@ -2,7 +2,16 @@ # Set up a table to use for integration tests. -set -x +set -e +set -u + +ADMIN_HOSTS=( + "bigtableadmin.googleapis.com:443" + "test-bigtableadmin.sandbox.googleapis.com:443" +) + +ZONE=us-central1-b +FAMILY=cf # Format: projects//instances//tables/ TABLE_NAME=$1 @@ -16,6 +25,24 @@ else exit 1 fi -cbt -project $PROJECT_ID -instance $INSTANCE_ID createtable $TABLE_ID -cbt -project $PROJECT_ID -instance $INSTANCE_ID createfamily $TABLE_ID cf -cbt -project $PROJECT_ID -instance $INSTANCE_ID setgcpolicy $TABLE_ID cf maxversions=1 +call_cbt() { + cbt -admin-endpoint="${ADMIN_HOST}" -project "${PROJECT_ID}" -instance "${INSTANCE_ID}" "$@" +} + +for ADMIN_HOST in "${ADMIN_HOSTS[@]}"; do + # Ensure that the instance exists. + if ! call_cbt listinstances | grep -q "${INSTANCE_ID}"; then + call_cbt createinstance "${INSTANCE_ID}" "${INSTANCE_ID}" "${INSTANCE_ID}-c0" "${ZONE}" 1 SSD + fi + + # Ensure that the table exists + if ! call_cbt -instance ${INSTANCE_ID} ls | grep -q "^${TABLE_ID}\$"; then + call_cbt createtable ${TABLE_ID} + fi + + # Ensure that the family exists + if ! call_cbt ls "${TABLE_ID}" | grep -q "^$FAMILY\b"; then + call_cbt createfamily "${TABLE_ID}" "${FAMILY}" + call_cbt setgcpolicy "${TABLE_ID}" "${FAMILY}" maxversions=1 + fi +done diff --git a/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/env/DirectPathEnv.java b/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/env/DirectPathEnv.java new file mode 100644 index 000000000000..c14179e3a309 --- /dev/null +++ b/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/env/DirectPathEnv.java @@ -0,0 +1,182 @@ +/* + * Copyright 2019 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.bigtable.data.v2.it.env; + +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.api.gax.rpc.ServerStream; +import com.google.cloud.bigtable.data.v2.BigtableDataClient; +import com.google.cloud.bigtable.data.v2.BigtableDataSettings; +import com.google.cloud.bigtable.data.v2.models.Query; +import com.google.cloud.bigtable.data.v2.models.Row; +import com.google.cloud.bigtable.data.v2.models.RowMutation; +import com.google.cloud.bigtable.data.v2.stub.EnhancedBigtableStubSettings; +import com.google.common.collect.Lists; +import java.io.IOException; +import java.util.List; +import java.util.UUID; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +/** + * Test environment that uses an existing bigtable table in the directpath environment. + * + *

The test environment can be accessed via both, CFE and direct path. The transport is + * controlled via the environment variable {@code GOOGLE_CLOUD_ENABLE_DIRECT_PATH}. Which contains + * comma delimited list of service names that should be accessed via direct path. + * + *

The target table must have a pre-existing family {@code cf}. The target table is configured + * via the system properties: + * + *

    + *
  • {@code bigtable.project} + *
  • {@code bigtable.instance} + *
  • {@code bigtable.table} + *
+ */ +public class DirectPathEnv implements TestEnv { + // TODO(igorbernstein): move direct path conditional logic to gax + private static final String DIRECT_PATH_ENV_VAR = "GOOGLE_CLOUD_ENABLE_DIRECT_PATH"; + private static final String DIRECT_PATH_SERVICE_NAME = + "testdirectpath-bigtable.sandbox.googleapis.com"; + + private static final String PROJECT_PROPERTY_NAME = "bigtable.project"; + private static final String INSTANCE_PROPERTY_NAME = "bigtable.instance"; + private static final String TABLE_PROPERTY_NAME = "bigtable.table"; + + private final boolean directPathEnabled; + private final String projectId; + private final String instanceId; + private final String tableId; + private static final String FAMILY_ID = "cf"; + private String rowPrefix; + + private BigtableDataClient dataClient; + + static DirectPathEnv create() { + return new DirectPathEnv( + isDirectPathEnabled(), + getRequiredProperty(PROJECT_PROPERTY_NAME), + getRequiredProperty(INSTANCE_PROPERTY_NAME), + getRequiredProperty(TABLE_PROPERTY_NAME)); + } + + public DirectPathEnv( + boolean directPathEnabled, String projectId, String instanceId, String tableId) { + this.directPathEnabled = directPathEnabled; + this.projectId = projectId; + this.instanceId = instanceId; + this.tableId = tableId; + this.rowPrefix = UUID.randomUUID() + "-"; + } + + @Override + public void start() throws IOException { + BigtableDataSettings.Builder settingsBuilder = + BigtableDataSettings.newBuilder().setProjectId(projectId).setInstanceId(instanceId); + + // Direct path test environment uses a different endpoint. + settingsBuilder.stubSettings().setEndpoint(DIRECT_PATH_SERVICE_NAME + ":443"); + + // TODO(igorbernstein): move direct path conditional logic to gax + // Direct path environment can be accessed via CFE or direct path. When using direct path, + // disable connection pooling. + if (directPathEnabled) { + settingsBuilder + .stubSettings() + .setTransportChannelProvider( + EnhancedBigtableStubSettings.defaultGrpcTransportProviderBuilder() + .setPoolSize(1) + .build()); + } + + dataClient = BigtableDataClient.create(settingsBuilder.build()); + } + + @Override + public void stop() throws Exception { + deleteRows(); + dataClient.close(); + } + + @Override + public BigtableDataClient getDataClient() { + return dataClient; + } + + @Override + public String getProjectId() { + return projectId; + } + + @Override + public String getInstanceId() { + return instanceId; + } + + @Override + public String getTableId() { + return tableId; + } + + @Override + public String getFamilyId() { + return FAMILY_ID; + } + + @Override + public String getRowPrefix() { + return rowPrefix; + } + + private void deleteRows() throws InterruptedException, ExecutionException, TimeoutException { + Query query = Query.create(tableId).prefix(rowPrefix); + + List> futures = Lists.newArrayList(); + ServerStream rows = dataClient.readRows(query); + for (Row row : rows) { + ApiFuture future = + dataClient.mutateRowAsync(RowMutation.create(tableId, row.getKey()).deleteRow()); + futures.add(future); + } + + ApiFutures.allAsList(futures).get(10, TimeUnit.MINUTES); + } + + private static String getRequiredProperty(String prop) { + String value = System.getProperty(prop); + if (value == null || value.isEmpty()) { + throw new RuntimeException("Missing system property: " + prop); + } + return value; + } + + // TODO(igorbernstein): move direct path conditional logic to gax + private static boolean isDirectPathEnabled() { + String whiteList = System.getenv(DIRECT_PATH_ENV_VAR); + if (whiteList == null) { + return false; + } + + for (String service : whiteList.split(",")) { + if (!service.isEmpty() && DIRECT_PATH_SERVICE_NAME.contains(service)) { + return true; + } + } + return false; + } +} diff --git a/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/env/TestEnvRule.java b/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/env/TestEnvRule.java index 06f4c6d3ef54..b2f7ca40e567 100644 --- a/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/env/TestEnvRule.java +++ b/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/env/TestEnvRule.java @@ -29,6 +29,9 @@ *
  • {@code emulator}: uses the cbtemulator component that can be installed by gcloud *
  • {@code prod}: uses a pre-existing production table. The target table is defined using * system properties listed in {@link ProdEnv} and application default credentials + *
  • {@code direct_path}: uses a pre-existing table in the direct path test environment. The + * target table is defined using system properties listed in {@link ProdEnv} and application + * default credentials * * *

    By default, {@code emulator} will be used @@ -51,6 +54,9 @@ protected void before() throws Throwable { case "prod": testEnv = ProdEnv.fromSystemProperties(); break; + case "direct_path": + testEnv = DirectPathEnv.create(); + break; default: throw new IllegalArgumentException( String.format( From 065271641c9429926139d0e0ecb4bf32ed8c15cb Mon Sep 17 00:00:00 2001 From: Igor Bernstein Date: Tue, 16 Jul 2019 18:14:05 -0400 Subject: [PATCH 2/9] update docs --- TESTING.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/TESTING.md b/TESTING.md index 179774638429..0c288d37c6da 100644 --- a/TESTING.md +++ b/TESTING.md @@ -45,22 +45,22 @@ Here is an example that clears the dataset created in Step 3. ### Testing code that uses Bigtable Bigtable integration tests can either be run against an emulator or a real Bigtable table. The -target environment can be selected via the `bigtable.env` system property. By default it is set to -`emulator` and the other option is `prod`. +target environment can be selected by setting a maven profile. By default it is set to +`bigtable-emulator-it` and other options are `bigtable-prod-it` and `bigtable-directpath-it`. To use the `emulator` environment, please install the gcloud sdk and use it to install the `cbtemulator` via `gcloud components install bigtable`. -To use the `prod` environment: +To use the `bigtable-prod-it` and `bigtable-directpath-it` environments: 1. Set up the target table using `google-cloud-bigtable/scripts/setup-test-table.sh` 2. Download the [JSON service account credentials file][create-service-account] from the Google Developer's Console. 3. Set the environment variable `GOOGLE_APPLICATION_CREDENTIALS` to the path of the credentials file -4. Set the system property `bigtable.env=prod`, `bigtable.project`, `bigtable.instance` and +4. Enable the profile and the system properties `bigtable.project`, `bigtable.instance` and `bigtable.table` to created earlier. Example: ```shell mvn verify -am -pl google-cloud-bigtable \ - -Dbigtable.env=prod \ + -P bigtable-prod-it \ -Dbigtable.project=my-project -Dbigtable.instance=my-instance -Dbigtable.table=my-table From 284aed9a075738553ce055cf6adb26b6c515962d Mon Sep 17 00:00:00 2001 From: Igor Bernstein Date: Wed, 17 Jul 2019 23:28:48 -0400 Subject: [PATCH 3/9] cherrypick https://github.com/googleapis/google-cloud-java/pull/5762 --- .../bigtable/admin/v2/it/BigtableTableAdminClientIT.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/it/BigtableTableAdminClientIT.java b/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/it/BigtableTableAdminClientIT.java index 7788d534a9e2..4097f98ce870 100644 --- a/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/it/BigtableTableAdminClientIT.java +++ b/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/it/BigtableTableAdminClientIT.java @@ -43,6 +43,7 @@ import org.junit.AssumptionViolatedException; import org.junit.Before; import org.junit.BeforeClass; +import org.junit.Ignore; import org.junit.Test; import org.threeten.bp.Duration; @@ -223,7 +224,7 @@ public void listTables() { @Test public void listTablesAsync() throws Exception { - String tableId = getTableId("adminListTest"); + String tableId = getTableId("adminListAsyncTest"); try { tableAdmin.createTable(CreateTableRequest.of(tableId)); @@ -235,6 +236,7 @@ public void listTablesAsync() throws Exception { } } + @Ignore @Test public void dropRowRange() { String tableId = getTableId("adminDropRowrangeTest"); From 303f0fa27811bc9aa114079ca3c8cdd5f3ca4c11 Mon Sep 17 00:00:00 2001 From: Igor Bernstein Date: Thu, 18 Jul 2019 12:45:03 -0400 Subject: [PATCH 4/9] include port in const --- .../cloud/bigtable/data/v2/it/env/DirectPathEnv.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/env/DirectPathEnv.java b/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/env/DirectPathEnv.java index c14179e3a309..cf3356ee1f30 100644 --- a/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/env/DirectPathEnv.java +++ b/google-cloud-clients/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/env/DirectPathEnv.java @@ -51,8 +51,8 @@ public class DirectPathEnv implements TestEnv { // TODO(igorbernstein): move direct path conditional logic to gax private static final String DIRECT_PATH_ENV_VAR = "GOOGLE_CLOUD_ENABLE_DIRECT_PATH"; - private static final String DIRECT_PATH_SERVICE_NAME = - "testdirectpath-bigtable.sandbox.googleapis.com"; + private static final String DIRECT_PATH_END_POINT = + "testdirectpath-bigtable.sandbox.googleapis.com:443"; private static final String PROJECT_PROPERTY_NAME = "bigtable.project"; private static final String INSTANCE_PROPERTY_NAME = "bigtable.instance"; @@ -90,7 +90,7 @@ public void start() throws IOException { BigtableDataSettings.newBuilder().setProjectId(projectId).setInstanceId(instanceId); // Direct path test environment uses a different endpoint. - settingsBuilder.stubSettings().setEndpoint(DIRECT_PATH_SERVICE_NAME + ":443"); + settingsBuilder.stubSettings().setEndpoint(DIRECT_PATH_END_POINT); // TODO(igorbernstein): move direct path conditional logic to gax // Direct path environment can be accessed via CFE or direct path. When using direct path, @@ -173,7 +173,7 @@ private static boolean isDirectPathEnabled() { } for (String service : whiteList.split(",")) { - if (!service.isEmpty() && DIRECT_PATH_SERVICE_NAME.contains(service)) { + if (!service.isEmpty() && DIRECT_PATH_END_POINT.contains(service)) { return true; } } From 442ac84b72dafa8be861e12662e4a68f1ee43859 Mon Sep 17 00:00:00 2001 From: Igor Bernstein Date: Thu, 18 Jul 2019 12:52:38 -0400 Subject: [PATCH 5/9] fix emulator system prop --- google-cloud-clients/google-cloud-bigtable/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google-cloud-clients/google-cloud-bigtable/pom.xml b/google-cloud-clients/google-cloud-bigtable/pom.xml index 2a8077fa8683..9196233febcd 100644 --- a/google-cloud-clients/google-cloud-bigtable/pom.xml +++ b/google-cloud-clients/google-cloud-bigtable/pom.xml @@ -97,7 +97,7 @@ - prod + emulator com.google.cloud.bigtable.data.v2.it.** target/failsafe-reports/failsafe-summary-emulator-it.xml From 7900ee1090728e1c299705f1a1c5cba584f5fed3 Mon Sep 17 00:00:00 2001 From: Igor Bernstein Date: Fri, 19 Jul 2019 00:08:33 -0400 Subject: [PATCH 6/9] make sure to download emulator before running the bigtable integration tests --- .kokoro/presubmit/bigtable-it.cfg | 2 +- .../src/main/java/com/google/cloud/DownloadComponentsMojo.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.kokoro/presubmit/bigtable-it.cfg b/.kokoro/presubmit/bigtable-it.cfg index dd830ea20f16..f11e73ea9a40 100644 --- a/.kokoro/presubmit/bigtable-it.cfg +++ b/.kokoro/presubmit/bigtable-it.cfg @@ -8,7 +8,7 @@ env_vars: { env_vars: { key: "INTEGRATION_TEST_ARGS" - value: "google-cloud-clients/google-cloud-bigtable -P bigtable-emulator-it,bigtable-prod-it -Dbigtable.project=gcloud-devel -Dbigtable.instance=google-cloud-bigtable -Dbigtable.table=integration-tests" + value: "google-cloud-testing/google-cloud-bigtable-emulator,google-cloud-clients/google-cloud-bigtable -P bigtable-emulator-it,bigtable-prod-it -Dbigtable.project=gcloud-devel -Dbigtable.instance=google-cloud-bigtable -Dbigtable.table=integration-tests" } env_vars: { diff --git a/google-cloud-testing/google-cloud-gcloud-maven-plugin/src/main/java/com/google/cloud/DownloadComponentsMojo.java b/google-cloud-testing/google-cloud-gcloud-maven-plugin/src/main/java/com/google/cloud/DownloadComponentsMojo.java index 85d743d9c390..f571c057442c 100644 --- a/google-cloud-testing/google-cloud-gcloud-maven-plugin/src/main/java/com/google/cloud/DownloadComponentsMojo.java +++ b/google-cloud-testing/google-cloud-gcloud-maven-plugin/src/main/java/com/google/cloud/DownloadComponentsMojo.java @@ -104,6 +104,7 @@ public void execute() throws MojoExecutionException { private void executeInner() throws MojoExecutionException { if (shouldSkipDownload) { + getLog().info("Skipping download because shouldSkipDownload=true"); return; } From 146ff79bf39bfa6175e46088aeec53e768bc88ff Mon Sep 17 00:00:00 2001 From: Igor Bernstein Date: Fri, 19 Jul 2019 00:29:42 -0400 Subject: [PATCH 7/9] fix kokoro cmd line --- .kokoro/presubmit/bigtable-it.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.kokoro/presubmit/bigtable-it.cfg b/.kokoro/presubmit/bigtable-it.cfg index f11e73ea9a40..36c82abfd639 100644 --- a/.kokoro/presubmit/bigtable-it.cfg +++ b/.kokoro/presubmit/bigtable-it.cfg @@ -8,7 +8,7 @@ env_vars: { env_vars: { key: "INTEGRATION_TEST_ARGS" - value: "google-cloud-testing/google-cloud-bigtable-emulator,google-cloud-clients/google-cloud-bigtable -P bigtable-emulator-it,bigtable-prod-it -Dbigtable.project=gcloud-devel -Dbigtable.instance=google-cloud-bigtable -Dbigtable.table=integration-tests" + value: "google-cloud-clients/google-cloud-bigtable -pl google-cloud-testing/google-cloud-bigtable-emulator -P bigtable-emulator-it,bigtable-prod-it -Dbigtable.project=gcloud-devel -Dbigtable.instance=google-cloud-bigtable -Dbigtable.table=integration-tests" } env_vars: { From 73d9c8eb65f2b553c41ccb17a2c77eee09ae0374 Mon Sep 17 00:00:00 2001 From: Igor Bernstein Date: Fri, 19 Jul 2019 00:44:19 -0400 Subject: [PATCH 8/9] fix continuous & nightly jobs as well --- .kokoro/continuous/bigtable-it.cfg | 2 +- .kokoro/nightly/bigtable-it.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.kokoro/continuous/bigtable-it.cfg b/.kokoro/continuous/bigtable-it.cfg index dd830ea20f16..36c82abfd639 100644 --- a/.kokoro/continuous/bigtable-it.cfg +++ b/.kokoro/continuous/bigtable-it.cfg @@ -8,7 +8,7 @@ env_vars: { env_vars: { key: "INTEGRATION_TEST_ARGS" - value: "google-cloud-clients/google-cloud-bigtable -P bigtable-emulator-it,bigtable-prod-it -Dbigtable.project=gcloud-devel -Dbigtable.instance=google-cloud-bigtable -Dbigtable.table=integration-tests" + value: "google-cloud-clients/google-cloud-bigtable -pl google-cloud-testing/google-cloud-bigtable-emulator -P bigtable-emulator-it,bigtable-prod-it -Dbigtable.project=gcloud-devel -Dbigtable.instance=google-cloud-bigtable -Dbigtable.table=integration-tests" } env_vars: { diff --git a/.kokoro/nightly/bigtable-it.cfg b/.kokoro/nightly/bigtable-it.cfg index dd830ea20f16..36c82abfd639 100644 --- a/.kokoro/nightly/bigtable-it.cfg +++ b/.kokoro/nightly/bigtable-it.cfg @@ -8,7 +8,7 @@ env_vars: { env_vars: { key: "INTEGRATION_TEST_ARGS" - value: "google-cloud-clients/google-cloud-bigtable -P bigtable-emulator-it,bigtable-prod-it -Dbigtable.project=gcloud-devel -Dbigtable.instance=google-cloud-bigtable -Dbigtable.table=integration-tests" + value: "google-cloud-clients/google-cloud-bigtable -pl google-cloud-testing/google-cloud-bigtable-emulator -P bigtable-emulator-it,bigtable-prod-it -Dbigtable.project=gcloud-devel -Dbigtable.instance=google-cloud-bigtable -Dbigtable.table=integration-tests" } env_vars: { From 42ee5e5278b161d837759cac95dc46210aa5d931 Mon Sep 17 00:00:00 2001 From: Igor Bernstein Date: Fri, 19 Jul 2019 01:43:11 -0400 Subject: [PATCH 9/9] wrokaround flakes due to jdk bug --- .../google/cloud/bigtable/emulator/v2/Emulator.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/google-cloud-testing/google-cloud-bigtable-emulator/src/main/java/com/google/cloud/bigtable/emulator/v2/Emulator.java b/google-cloud-testing/google-cloud-bigtable-emulator/src/main/java/com/google/cloud/bigtable/emulator/v2/Emulator.java index 6b1df2190c15..9c2fa49b38df 100644 --- a/google-cloud-testing/google-cloud-bigtable-emulator/src/main/java/com/google/cloud/bigtable/emulator/v2/Emulator.java +++ b/google-cloud-testing/google-cloud-bigtable-emulator/src/main/java/com/google/cloud/bigtable/emulator/v2/Emulator.java @@ -96,7 +96,18 @@ public synchronized void start() throws IOException, TimeoutException, Interrupt } this.port = getAvailablePort(); - process = Runtime.getRuntime().exec(String.format("%s -port %d", executable, port)); + // Workaround https://bugs.openjdk.java.net/browse/JDK-8068370 + for (int attemptsLeft = 3; process == null; attemptsLeft--) { + try { + process = Runtime.getRuntime().exec(String.format("%s -port %d", executable, port)); + } catch (IOException e) { + if (attemptsLeft > 0) { + Thread.sleep(1000); + continue; + } + throw e; + } + } pipeStreamToLog(process.getInputStream(), Level.INFO); pipeStreamToLog(process.getErrorStream(), Level.WARNING); isStopped = false;