Skip to content

Commit

Permalink
fix: sets the project for the integration tests (#386)
Browse files Browse the repository at this point in the history
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.
This PR hardcodes the project so it matches the instance for the integration tests. Note it can still be overridden, instructions were added in the `CONTRIBUTING.md` file.
  • Loading branch information
thiagotnunes committed Aug 17, 2020
1 parent 5e89ebb commit c8fa458
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion CONTRIBUTING.md
Expand Up @@ -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/<your-project>/instances/<your-instance> \
-Dspanner.gce.config.project_id=<your-project> \
clean verify
```

## Code Samples
Expand Down
3 changes: 2 additions & 1 deletion google-cloud-spanner/pom.xml
Expand Up @@ -69,6 +69,7 @@
<systemPropertyVariables>
<spanner.testenv.config.class>com.google.cloud.spanner.GceTestEnvConfig</spanner.testenv.config.class>
<spanner.testenv.instance>projects/gcloud-devel/instances/spanner-testing</spanner.testenv.instance>
<spanner.gce.config.project_id>gcloud-devel</spanner.gce.config.project_id>
</systemPropertyVariables>
<forkedProcessTimeoutInSeconds>3000</forkedProcessTimeoutInSeconds>
</configuration>
Expand Down Expand Up @@ -363,4 +364,4 @@
</build>
</profile>
</profiles>
</project>
</project>
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c8fa458

Please sign in to comment.