Skip to content

Commit d155c3d

Browse files
committed
test(java-bigquerystorage): Use regex to match traceID
This should resolve the test failure in the java-bigquerystorage module: https://github.com/googleapis/google-cloud-java/actions/runs/23780714031/job/69292481126?pr=12299 b/492517601
1 parent bba6e32 commit d155c3d

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

java-bigquerystorage/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/ConnectionWorkerTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,17 @@ void testMultiplexedAppendSuccess_NonNullTraceId() throws Exception {
118118
testMultiplexedIngestion(
119119
/* sw1TraceId= */ "header_1:trailer_1",
120120
/* sw2TraceId= */ "header_2:trailer_2",
121-
/* expectedSW1TraceId= */ "java-streamwriter header_1:trailer_1",
122-
/* expectedSW2TraceId= */ "java-streamwriter header_2:trailer_2");
121+
/* expectedSW1TraceId= */ "java-streamwriter(:.+)? header_1:trailer_1",
122+
/* expectedSW2TraceId= */ "java-streamwriter(:.+)? header_2:trailer_2");
123123
}
124124

125125
@Test
126126
void testMultiplexedAppendSuccess_EmptyTraceId() throws Exception {
127127
testMultiplexedIngestion(
128128
/* sw1TraceId= */ "header_1:trailer_1",
129129
/* sw2TraceId= */ "",
130-
/* expectedSW1TraceId= */ "java-streamwriter header_1:trailer_1",
131-
/* expectedSW2TraceId= */ "java-streamwriter");
130+
/* expectedSW1TraceId= */ "java-streamwriter(:.+)? header_1:trailer_1",
131+
/* expectedSW2TraceId= */ "java-streamwriter(:.+)?");
132132
}
133133

134134
private void testMultiplexedIngestion(
@@ -216,7 +216,7 @@ private void testMultiplexedIngestion(
216216
assertThat(
217217
serverRequest.getProtoRows().getWriterSchema().getProtoDescriptor().getName())
218218
.isEqualTo("foo");
219-
assertThat(serverRequest.getTraceId()).isEqualTo(expectedSW1TraceId);
219+
assertThat(serverRequest.getTraceId()).matches(expectedSW1TraceId);
220220
break;
221221
case 1:
222222
// The write stream is empty until we enter multiplexing.
@@ -232,7 +232,7 @@ private void testMultiplexedIngestion(
232232
assertThat(
233233
serverRequest.getProtoRows().getWriterSchema().getProtoDescriptor().getName())
234234
.isEqualTo("complicate");
235-
assertThat(serverRequest.getTraceId()).isEqualTo(expectedSW2TraceId);
235+
assertThat(serverRequest.getTraceId()).matches(expectedSW2TraceId);
236236
break;
237237
case 3:
238238
// Schema is empty if not at the first request after table switch.

java-bigquerystorage/google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/JsonStreamWriterTest.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package com.google.cloud.bigquery.storage.v1;
1717

18+
import static com.google.common.truth.Truth.assertThat;
1819
import static org.junit.jupiter.api.Assertions.assertEquals;
1920
import static org.junit.jupiter.api.Assertions.assertFalse;
2021
import static org.junit.jupiter.api.Assertions.assertNotEquals;
@@ -248,8 +249,8 @@ void testSingleAppendSimpleJson() throws Exception {
248249
.getRows()
249250
.getSerializedRows(0),
250251
expectedProto.toByteString());
251-
assertEquals(
252-
"java-jsonwriter test:empty", testBigQueryWrite.getAppendRequests().get(0).getTraceId());
252+
assertThat(testBigQueryWrite.getAppendRequests().get(0).getTraceId())
253+
.matches("java-jsonwriter(:.+)? test:empty");
253254
}
254255
}
255256

@@ -291,8 +292,8 @@ void testSingleAppendSimpleGson() throws Exception {
291292
.getRows()
292293
.getSerializedRows(0),
293294
expectedProto.toByteString());
294-
assertEquals(
295-
"java-jsonwriter test:empty", testBigQueryWrite.getAppendRequests().get(0).getTraceId());
295+
assertThat(testBigQueryWrite.getAppendRequests().get(0).getTraceId())
296+
.matches("java-jsonwriter(:.+)? test:empty");
296297
}
297298
}
298299

@@ -339,7 +340,8 @@ void testFlexibleColumnAppend() throws Exception {
339340
.getRows()
340341
.getSerializedRows(0),
341342
expectedProto.toByteString());
342-
assertEquals("java-jsonwriter", testBigQueryWrite.getAppendRequests().get(0).getTraceId());
343+
assertThat(testBigQueryWrite.getAppendRequests().get(0).getTraceId())
344+
.matches("java-jsonwriter(:.+)?");
343345
}
344346
}
345347

@@ -561,7 +563,8 @@ void testSingleAppendMultipleSimpleJson() throws Exception {
561563
.getProtoRows()
562564
.getRows()
563565
.getSerializedRowsCount());
564-
assertEquals("java-jsonwriter", testBigQueryWrite.getAppendRequests().get(0).getTraceId());
566+
assertThat(testBigQueryWrite.getAppendRequests().get(0).getTraceId())
567+
.matches("java-jsonwriter(:.+)?");
565568
for (int i = 0; i < 4; i++) {
566569
assertEquals(
567570
testBigQueryWrite

0 commit comments

Comments
 (0)