Skip to content

Commit a407eb4

Browse files
update test_name to no longer conflict
1 parent 78a0955 commit a407eb4

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

spark-3.1-spanner-lib/src/test/java/com/google/cloud/spark/spanner/acceptance/DataprocServerlessAcceptanceTestBase.java

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,21 +85,26 @@ public class DataprocServerlessAcceptanceTestBase {
8585
private static String classTestBaseGcsDir;
8686

8787
BatchControllerClient batchController;
88-
String testName =
89-
getClass()
90-
.getSimpleName()
91-
.substring(0, getClass().getSimpleName().length() - 32)
92-
.toLowerCase(Locale.ENGLISH);
93-
String testId = String.format("%s-%s", testName, System.currentTimeMillis());
94-
String testBaseGcsDir = AcceptanceTestUtils.createTestBaseGcsDir(testId);
95-
AcceptanceTestContext context =
96-
new AcceptanceTestContext(
97-
testId, generateClusterName(testId), testBaseGcsDir, classConnectorJarUri);
98-
9988
private final String s8sImageVersion;
89+
private final String testName;
90+
private final String testId;
91+
private final String testBaseGcsDir;
92+
private final AcceptanceTestContext context;
10093

10194
public DataprocServerlessAcceptanceTestBase(String s8sImageVersion) {
10295
this.s8sImageVersion = s8sImageVersion;
96+
// Cluster name has a length limit of 63 characters. Given currentTimeMillis returns 13 digits
97+
// (until the year 2286),
98+
// and the prefix is 39 characters ("dataproc-serverless-acceptance-test-"), we only have 11
99+
// characters left for the image version.
100+
// To prevent naming collisions, we'll use just the image version as the test name.
101+
// The image version will be something like "latest" or "2.2", so we'll remove the dot.
102+
testName = s8sImageVersion.replace(".", "").toLowerCase(Locale.ENGLISH);
103+
testId = String.format("%s-%s", testName, System.currentTimeMillis());
104+
testBaseGcsDir = AcceptanceTestUtils.createTestBaseGcsDir(testId);
105+
context =
106+
new AcceptanceTestContext(
107+
testId, generateClusterName(testId), testBaseGcsDir, classConnectorJarUri);
103108
}
104109

105110
protected static void setup(String connectorJarDirectory, String connectorJarPrefix)

0 commit comments

Comments
 (0)