Skip to content

Commit f11d8dc

Browse files
committed
chore: add retries to flaky test
This test requires loading eventual consistent data, and sometimes it returns undefined even if the connection was successful.
1 parent 0e2331e commit f11d8dc

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

tests/integration/common/connectionManager.oidc.test.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { TestContext } from "vitest";
2-
import { describe, beforeEach, afterAll, it, expect } from "vitest";
2+
import { describe, beforeEach, afterAll, it, expect, vi } from "vitest";
33
import semver from "semver";
44
import process from "process";
55
import type { MongoDBIntegrationTestCase } from "../tools/mongodb/mongodbHelpers.js";
@@ -168,11 +168,22 @@ describe.skipIf(process.platform !== "linux")("ConnectionManager OIDC Tests", as
168168
};
169169
};
170170

171-
const status: ConnectionStatus = (await state.serviceProvider.runCommand("admin", {
172-
connectionStatus: 1,
173-
})) as unknown as ConnectionStatus;
171+
const status: ConnectionStatus = await vi.waitFor(async () => {
172+
const result: ConnectionStatus = (await state.serviceProvider.runCommand("admin", {
173+
connectionStatus: 1,
174+
})) as unknown as ConnectionStatus;
174175

175-
expect(status.authInfo.authenticatedUsers[0]).toEqual({ user: "dev/testuser", db: "$external" });
176+
if (!result) {
177+
throw new Error("Status can not be undefined. Retrying.");
178+
}
179+
180+
return result;
181+
});
182+
183+
expect(status.authInfo.authenticatedUsers[0]).toEqual({
184+
user: "dev/testuser",
185+
db: "$external",
186+
});
176187
expect(status.authInfo.authenticatedUserRoles[0]).toEqual({
177188
role: "dev/mocktaTestServer-group",
178189
db: "admin",

0 commit comments

Comments
 (0)