Skip to content

Commit d553cd1

Browse files
jabubakelesv
authored andcommitted
adding a test prefix to db to allow for concurrent runs (GoogleCloudPlatform#867)
1 parent e38719e commit d553cd1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

spanner/cloud-client/src/test/java/com/example/spanner/SpannerSampleIT.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import java.io.ByteArrayOutputStream;
2727
import java.io.PrintStream;
28+
import java.util.UUID;
2829
import org.junit.After;
2930
import org.junit.Before;
3031
import org.junit.Test;
@@ -39,7 +40,7 @@
3940
public class SpannerSampleIT {
4041
// The instance needs to exist for tests to pass.
4142
private final String instanceId = System.getProperty("spanner.test.instance");
42-
private final String databaseId = System.getProperty("spanner.sample.database");
43+
private final String databaseId = formatForTest(System.getProperty("spanner.sample.database"));
4344
DatabaseId dbId;
4445
DatabaseAdminClient dbClient;
4546
private long lastUpdateDataTimeInMillis;
@@ -116,4 +117,8 @@ public void testSample() throws Exception {
116117
out = runSample("readonlytransaction");
117118
assertThat(out.replaceAll("[\r\n]+", " ")).containsMatch("(Total Junk.*){2}");
118119
}
120+
121+
private String formatForTest(String name) {
122+
return name + "-" + UUID.randomUUID().toString().substring(0, 20);
123+
}
119124
}

0 commit comments

Comments
 (0)