Skip to content

Commit

Permalink
samples: adding a test prefix to db to allow for concurrent runs (goo…
Browse files Browse the repository at this point in the history
  • Loading branch information
jabubake authored and thiagotnunes committed Oct 6, 2020
1 parent ea653f7 commit fd092d0
Showing 1 changed file with 6 additions and 1 deletion.
Expand Up @@ -25,6 +25,7 @@

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.UUID;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -39,7 +40,7 @@
public class SpannerSampleIT {
// The instance needs to exist for tests to pass.
private final String instanceId = System.getProperty("spanner.test.instance");
private final String databaseId = System.getProperty("spanner.sample.database");
private final String databaseId = formatForTest(System.getProperty("spanner.sample.database"));
DatabaseId dbId;
DatabaseAdminClient dbClient;
private long lastUpdateDataTimeInMillis;
Expand Down Expand Up @@ -116,4 +117,8 @@ public void testSample() throws Exception {
out = runSample("readonlytransaction");
assertThat(out.replaceAll("[\r\n]+", " ")).containsMatch("(Total Junk.*){2}");
}

private String formatForTest(String name) {
return name + "-" + UUID.randomUUID().toString().substring(0, 20);
}
}

0 comments on commit fd092d0

Please sign in to comment.