Skip to content

Double timeouts in serverless mode to reduce test execution flakiness. #1441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -830,4 +830,11 @@ public static int getReferenceCountAfterTimeout(final ReferenceCounted reference
public static ClusterSettings.Builder setDirectConnection(final ClusterSettings.Builder builder) {
return builder.mode(ClusterConnectionMode.SINGLE).hosts(singletonList(getPrimary()));
}

public static int applyTimeoutMultiplierForServerless(final int timeoutMs) {
if (ClusterFixture.isServerlessTest()) {
return timeoutMs * 2;
}
return timeoutMs;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import java.util.stream.Collectors;

import static com.mongodb.ClusterFixture.TIMEOUT_DURATION;
import static com.mongodb.ClusterFixture.applyTimeoutMultiplierForServerless;
import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet;
import static com.mongodb.ClusterFixture.isServerlessTest;
import static com.mongodb.ClusterFixture.serverVersionAtLeast;
Expand Down Expand Up @@ -119,12 +120,12 @@ public void testGridFSUploadViaOpenUploadStreamTimeout() {
+ " data: {"
+ " failCommands: [\"insert\"],"
+ " blockConnection: true,"
+ " blockTimeMS: " + (rtt + 405)
+ " blockTimeMS: " + (rtt + applyTimeoutMultiplierForServerless(405))
+ " }"
+ "}");

try (MongoClient client = createReactiveClient(getMongoClientSettingsBuilder()
.timeout(rtt + 400, TimeUnit.MILLISECONDS))) {
.timeout(rtt + applyTimeoutMultiplierForServerless(400), TimeUnit.MILLISECONDS))) {
MongoDatabase database = client.getDatabase(gridFsFileNamespace.getDatabaseName());
GridFSBucket gridFsBucket = createReaciveGridFsBucket(database, GRID_FS_BUCKET_NAME);

Expand Down Expand Up @@ -178,12 +179,12 @@ public void testAbortingGridFsUploadStreamTimeout() throws ExecutionException, I
+ " data: {"
+ " failCommands: [\"delete\"],"
+ " blockConnection: true,"
+ " blockTimeMS: " + (rtt + 405)
+ " blockTimeMS: " + (rtt + applyTimeoutMultiplierForServerless(405))
+ " }"
+ "}");

try (MongoClient client = createReactiveClient(getMongoClientSettingsBuilder()
.timeout(rtt + 400, TimeUnit.MILLISECONDS))) {
.timeout(rtt + applyTimeoutMultiplierForServerless(400), TimeUnit.MILLISECONDS))) {
MongoDatabase database = client.getDatabase(gridFsFileNamespace.getDatabaseName());
GridFSBucket gridFsBucket = createReaciveGridFsBucket(database, GRID_FS_BUCKET_NAME);

Expand Down
Loading