Skip to content

Commit 59e58f3

Browse files
olavloitelqiu96
authored andcommitted
chore: unflake OpenTelemetrySpanTest.transactionRunnerWithFailedAndBeginTransaction (#3254)
Fixes #3253
1 parent c31117a commit 59e58f3

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

google-cloud-spanner/src/test/java/com/google/cloud/spanner/OpenTelemetrySpanTest.java

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -572,22 +572,13 @@ public void transactionRunnerWithError() {
572572
@Test
573573
public void transactionRunnerWithFailedAndBeginTransaction() {
574574
List<String> expectedReadWriteTransactionWithCommitAndBeginTransactionSpans =
575-
isMultiplexedSessionsEnabled()
576-
? ImmutableList.of(
577-
"CloudSpannerOperation.CreateMultiplexedSession",
578-
"CloudSpannerOperation.BeginTransaction",
579-
"CloudSpannerOperation.BatchCreateSessionsRequest",
580-
"CloudSpannerOperation.ExecuteUpdate",
581-
"CloudSpannerOperation.Commit",
582-
"CloudSpannerOperation.BatchCreateSessions",
583-
"CloudSpanner.ReadWriteTransaction")
584-
: ImmutableList.of(
585-
"CloudSpannerOperation.BeginTransaction",
586-
"CloudSpannerOperation.BatchCreateSessionsRequest",
587-
"CloudSpannerOperation.ExecuteUpdate",
588-
"CloudSpannerOperation.Commit",
589-
"CloudSpannerOperation.BatchCreateSessions",
590-
"CloudSpanner.ReadWriteTransaction");
575+
ImmutableList.of(
576+
"CloudSpannerOperation.BeginTransaction",
577+
"CloudSpannerOperation.BatchCreateSessionsRequest",
578+
"CloudSpannerOperation.ExecuteUpdate",
579+
"CloudSpannerOperation.Commit",
580+
"CloudSpannerOperation.BatchCreateSessions",
581+
"CloudSpanner.ReadWriteTransaction");
591582
DatabaseClient client = getClient();
592583
assertEquals(
593584
Long.valueOf(1L),
@@ -612,7 +603,7 @@ public void transactionRunnerWithFailedAndBeginTransaction() {
612603
Stopwatch stopwatch = Stopwatch.createStarted();
613604
while (spanExporter.getFinishedSpanItems().size()
614605
< expectedReadWriteTransactionWithCommitAndBeginTransactionSpans.size()
615-
&& stopwatch.elapsed().compareTo(java.time.Duration.ofMillis(1000)) < 0) {
606+
&& stopwatch.elapsed(TimeUnit.MILLISECONDS) < 2000) {
616607
Thread.yield();
617608
}
618609

@@ -621,7 +612,11 @@ public void transactionRunnerWithFailedAndBeginTransaction() {
621612
.getFinishedSpanItems()
622613
.forEach(
623614
spanItem -> {
624-
actualSpanItems.add(spanItem.getName());
615+
// Ignore multiplexed sessions, as they are not used by this test and can therefore
616+
// best be ignored, as it is not 100% certain that it has already been created.
617+
if (!"CloudSpannerOperation.CreateMultiplexedSession".equals(spanItem.getName())) {
618+
actualSpanItems.add(spanItem.getName());
619+
}
625620
switch (spanItem.getName()) {
626621
case "CloudSpannerOperation.CreateMultiplexedSession":
627622
verifyRequestEvents(

0 commit comments

Comments
 (0)