Skip to content

Commit

Permalink
Retry opening couchbase 3.1 bucket (#12865)
Browse files Browse the repository at this point in the history
  • Loading branch information
laurit authored Dec 9, 2024
1 parent 265cbe4 commit 9cf0973
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@

package io.opentelemetry.javaagent.instrumentation.couchbase.v3_1;

import static org.awaitility.Awaitility.await;

import com.couchbase.client.core.env.TimeoutConfig;
import com.couchbase.client.core.error.DocumentNotFoundException;
import com.couchbase.client.core.error.UnambiguousTimeoutException;
import com.couchbase.client.java.Bucket;
import com.couchbase.client.java.Cluster;
import com.couchbase.client.java.ClusterOptions;
Expand Down Expand Up @@ -62,11 +65,18 @@ static void setup() {
ClusterOptions.clusterOptions(couchbase.getUsername(), couchbase.getPassword())
.environment(environment));

Bucket bucket = cluster.bucket("test");
collection = bucket.defaultCollection();
// wait and retry in the hope that it will help against test flakiness
await()
.atMost(Duration.ofMinutes(2))
.ignoreException(UnambiguousTimeoutException.class)
.until(
() -> {
Bucket bucket = cluster.bucket("test");
collection = bucket.defaultCollection();

// Wait 1 minute due to slow startup contributing to flakiness
bucket.waitUntilReady(Duration.ofMinutes(1));
bucket.waitUntilReady(Duration.ofSeconds(30));
return true;
});
}

@AfterAll
Expand Down

0 comments on commit 9cf0973

Please sign in to comment.