From 7c6d9f1fb150a0d4389583971034d0d3f3120a6d Mon Sep 17 00:00:00 2001 From: Thiago Nunes Date: Mon, 17 Aug 2020 16:25:32 +1000 Subject: [PATCH 1/2] fix: sets the project for the integration tests The emulator uses the project set in order to list the instance configurations. If the none is set, it gets that information through the gcloud project set, which might mismatch the project being used to create the databases in the integration tests. --- google-cloud-spanner/pom.xml | 3 ++- .../test/java/com/google/cloud/spanner/IntegrationTestEnv.java | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/google-cloud-spanner/pom.xml b/google-cloud-spanner/pom.xml index f749be01b4a..63db371d055 100644 --- a/google-cloud-spanner/pom.xml +++ b/google-cloud-spanner/pom.xml @@ -69,6 +69,7 @@ com.google.cloud.spanner.GceTestEnvConfig projects/gcloud-devel/instances/spanner-testing + gcloud-devel 3000 @@ -363,4 +364,4 @@ - \ No newline at end of file + diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/IntegrationTestEnv.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/IntegrationTestEnv.java index 3d5263fb08f..b67f970273c 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/IntegrationTestEnv.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/IntegrationTestEnv.java @@ -16,7 +16,6 @@ package com.google.cloud.spanner; -import static com.google.cloud.spanner.testing.EmulatorSpannerHelper.isUsingEmulator; import static com.google.common.base.Preconditions.checkState; import com.google.api.gax.longrunning.OperationFuture; @@ -80,7 +79,7 @@ protected void before() throws Throwable { SpannerOptions options = config.spannerOptions(); String instanceProperty = System.getProperty(TEST_INSTANCE_PROPERTY, ""); InstanceId instanceId; - if (!instanceProperty.isEmpty() && !isUsingEmulator()) { + if (!instanceProperty.isEmpty()) { instanceId = InstanceId.of(instanceProperty); isOwnedInstance = false; logger.log(Level.INFO, "Using existing test instance: {0}", instanceId); From ba177b7589a82ee70c91a865683ae4d4f9a65a31 Mon Sep 17 00:00:00 2001 From: Thiago Nunes Date: Mon, 17 Aug 2020 18:43:00 +1000 Subject: [PATCH 2/2] fix: updates instructions for it tests Updates the instructions to run the integration tests in the contributing file. With the update, users will know how to properly set the instance and project to run the integration tests. --- CONTRIBUTING.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f2dbdee06bc..53d24601789 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -48,7 +48,11 @@ integration tests. ```bash export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service/account.json -mvn -Penable-integration-tests clean verify +mvn \ + -Penable-integration-tests \ + -Dspanner.testenv.instance=projects//instances/ \ + -Dspanner.gce.config.project_id= \ + clean verify ``` ## Code Samples