Skip to content

Commit 34c287b

Browse files
fix flaky tests?
1 parent da46aea commit 34c287b

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

test/integration/auth/auth.prose.test.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ function makeConnectionString(config, username, password) {
99

1010
const metadata: MongoDBMetadataUI = {
1111
requires: {
12-
auth: 'enabled',
13-
mongodb: '>=3.7.3',
1412
predicate: () =>
1513
process.env.LOAD_BALANCER ? 'TODO(NODE-5631): fix tests to run in load balancer mode.' : true
1614
}
@@ -305,8 +303,7 @@ describe('Authentication Spec Prose Tests', function () {
305303
);
306304
});
307305

308-
// TODO(NODE-6752): Fix flaky SCRAM-SHA-256 tests
309-
describe.skip('Step 4', function () {
306+
describe('Step 4', function () {
310307
/**
311308
* Step 4
312309
* To test SASLprep behavior, create two users:
@@ -343,11 +340,9 @@ describe('Authentication Spec Prose Tests', function () {
343340
utilClient = this.configuration.newClient(this.configuration.url());
344341
const db = utilClient.db('admin');
345342

346-
try {
347-
await Promise.all(users.map(user => db.removeUser(user.username)));
348-
} catch {
349-
/** We ensure that users are deleted. No action needed. */
350-
}
343+
// We do not care if this fails - this is just cleanup for any
344+
// previous test iterations or previous test runs.
345+
await Promise.allSettled(users.map(user => db.removeUser(user.username)));
351346

352347
const createUserCommands = users.map(user => ({
353348
createUser: user.username,
@@ -356,7 +351,15 @@ describe('Authentication Spec Prose Tests', function () {
356351
mechanisms: user.mechanisms
357352
}));
358353

359-
await Promise.all(createUserCommands.map(cmd => db.command(cmd)));
354+
const failures = await Promise.allSettled(
355+
createUserCommands.map(cmd => db.command(cmd))
356+
).then(resolutions => resolutions.filter(resolution => resolution.status === 'rejected'));
357+
358+
if (failures.length) {
359+
throw new Error(
360+
'Error(s) creating users: ' + failures.map(failure => failure.reason).join(' | ')
361+
);
362+
}
360363
});
361364

362365
afterEach(async function () {
@@ -391,7 +394,7 @@ describe('Authentication Spec Prose Tests', function () {
391394
const stats = await client.db('admin').stats();
392395
expect(stats).to.exist;
393396
}
394-
).skipReason = 'TODO(NODE-6752): Fix flaky SCRAM-SHA-256 test';
397+
);
395398

396399
it(
397400
'logs in with normalized username and non-normalized password',

0 commit comments

Comments
 (0)