Skip to content

Commit 640d660

Browse files
committed
Implement and use a TestShell.eventually
1 parent b7258a8 commit 640d660

File tree

6 files changed

+112
-49
lines changed

6 files changed

+112
-49
lines changed

packages/e2e-tests/test/e2e-auth.spec.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ describe('Auth e2e', function () {
298298
it('dropAllUsers', async function () {
299299
await shell.executeLine(`use ${dbName}`);
300300
shell.writeInputLine('db.dropAllUsers()');
301-
await eventually(() => {
301+
await shell.eventually(() => {
302302
try {
303303
shell.assertContainsOutput('{ n: 2, ok: 1 }');
304304
} catch {
@@ -508,7 +508,7 @@ describe('Auth e2e', function () {
508508
it('dropAllRoles', async function () {
509509
await shell.executeLine(`use ${dbName}`);
510510
shell.writeInputLine('db.dropAllRoles()');
511-
await eventually(() => {
511+
await shell.eventually(() => {
512512
try {
513513
shell.assertContainsOutput('{ n: 2, ok: 1 }');
514514
} catch {
@@ -737,7 +737,7 @@ describe('Auth e2e', function () {
737737
it('throws if pwd is wrong', async function () {
738738
await shell.executeLine(`use ${dbName}`);
739739
shell.writeInputLine('db.auth("anna", "pwd2")');
740-
await eventually(
740+
await shell.eventually(
741741
() => {
742742
shell.assertContainsError('Authentication failed');
743743
},
@@ -752,7 +752,7 @@ describe('Auth e2e', function () {
752752
shell.writeInputLine(
753753
'db.auth({ user: "anna", pwd: "pwd2", mechanism: "not a mechanism"})'
754754
);
755-
await eventually(
755+
await shell.eventually(
756756
() => {
757757
expect(shell.output).to.match(
758758
/MongoParseError: authMechanism one of .+, got not a mechanism/
@@ -1067,7 +1067,7 @@ describe('Auth e2e', function () {
10671067
'SCRAM-SHA-1',
10681068
],
10691069
});
1070-
await eventually(() => {
1070+
await shell.eventually(() => {
10711071
expect(shell.output).to.match(
10721072
/MongoServerError: Authentication failed|Unable to use SCRAM-SHA-1/
10731073
);
@@ -1088,7 +1088,7 @@ describe('Auth e2e', function () {
10881088
'SCRAM-SHA-256',
10891089
],
10901090
});
1091-
await eventually(() => {
1091+
await shell.eventually(() => {
10921092
expect(shell.output).to.match(
10931093
/MongoServerError: Authentication failed|Unable to use SCRAM-SHA-256/
10941094
);

packages/e2e-tests/test/e2e-direct.spec.ts

+13-8
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,17 @@ describe('e2e direct connection', function () {
6464
`rs.initiate(${JSON.stringify(replSetConfig)})`
6565
);
6666
shell.assertContainsOutput('ok: 1');
67-
await eventually(async () => {
68-
await shell.executeLine('db.isMaster()');
69-
shell.assertContainsOutput('ismaster: true');
70-
shell.assertContainsOutput(`me: '${await rs0.hostport()}'`);
71-
shell.assertContainsOutput(`setName: '${replSetId}'`);
72-
});
67+
await eventually(
68+
async () => {
69+
const output = await shell.executeLine('db.isMaster()');
70+
expect(output).contains('ismaster: true');
71+
expect(output).contains(`me: '${await rs0.hostport()}'`);
72+
expect(output).contains(`setName: '${replSetId}'`);
73+
},
74+
{
75+
timeout: 20_000,
76+
}
77+
);
7378

7479
await shell.executeLine('use admin');
7580
await shell.executeLine(
@@ -204,7 +209,7 @@ describe('e2e direct connection', function () {
204209
await shell.waitForPrompt();
205210
shell.writeInput('db.testc');
206211
await tabtab(shell);
207-
await eventually(() => {
212+
await shell.eventually(() => {
208213
shell.assertContainsOutput('db.testcollection');
209214
});
210215
});
@@ -370,7 +375,7 @@ describe('e2e direct connection', function () {
370375
await shell.waitForPrompt();
371376
shell.writeInput('db.testc');
372377
await tabtab(shell);
373-
await eventually(() => {
378+
await shell.eventually(() => {
374379
shell.assertContainsOutput('db.testcollection');
375380
});
376381
});

packages/e2e-tests/test/e2e-editor.spec.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ describe('external editor e2e', function () {
7373

7474
expect(result).to.include('"editor" has been changed');
7575
shell.writeInputLine(shellOriginalInput);
76-
await eventually(() => {
76+
await shell.eventually(() => {
7777
shell.assertContainsOutput(shellModifiedInput);
7878
});
7979
});
@@ -97,7 +97,7 @@ describe('external editor e2e', function () {
9797

9898
expect(result).to.include('"editor" has been changed');
9999
shell.writeInputLine(shellOriginalInput);
100-
await eventually(() => {
100+
await shell.eventually(() => {
101101
shell.assertContainsOutput(shellModifiedInput);
102102
});
103103
});
@@ -118,7 +118,7 @@ describe('external editor e2e', function () {
118118

119119
expect(result).to.include('"editor" has been changed');
120120
shell.writeInputLine(shellOriginalInput);
121-
await eventually(() => {
121+
await shell.eventually(() => {
122122
shell.assertContainsOutput(shellModifiedInput);
123123
});
124124
});
@@ -145,7 +145,7 @@ describe('external editor e2e', function () {
145145

146146
expect(result).to.include('"editor" has been changed');
147147
shell.writeInputLine(shellOriginalInput);
148-
await eventually(() => {
148+
await shell.eventually(() => {
149149
shell.assertContainsOutput(shellModifiedInput);
150150
});
151151
});
@@ -163,7 +163,7 @@ describe('external editor e2e', function () {
163163

164164
expect(result).to.include('"editor" has been changed');
165165
shell.writeInputLine(shellOriginalInput);
166-
await eventually(() => {
166+
await shell.eventually(() => {
167167
shell.assertContainsError('failed with an exit code 1');
168168
});
169169
});
@@ -182,7 +182,7 @@ describe('external editor e2e', function () {
182182

183183
expect(result).to.include('"editor" has been changed');
184184
shell.writeInputLine('edit');
185-
await eventually(() => {
185+
await shell.eventually(() => {
186186
shell.assertContainsOutput(output);
187187
});
188188
});
@@ -216,7 +216,7 @@ describe('external editor e2e', function () {
216216
"const name = 'I want to test a sequence of writeInputLine'"
217217
);
218218
shell.writeInputLine('edit name');
219-
await eventually(() => {
219+
await shell.eventually(() => {
220220
shell.assertContainsOutput(shellModifiedInput);
221221
});
222222
});
@@ -254,7 +254,7 @@ describe('external editor e2e', function () {
254254

255255
expect(result).to.include('"editor" has been changed');
256256
shell.writeInputLine(shellOriginalInput);
257-
await eventually(() => {
257+
await shell.eventually(() => {
258258
shell.assertContainsOutput(shellModifiedInput);
259259
});
260260
});
@@ -279,7 +279,7 @@ describe('external editor e2e', function () {
279279

280280
expect(result).to.include('"editor" has been changed');
281281
shell.writeInputLine(shellOriginalInput);
282-
await eventually(() => {
282+
await shell.eventually(() => {
283283
shell.assertContainsOutput(shellModifiedInput);
284284
});
285285
});
@@ -303,7 +303,7 @@ describe('external editor e2e', function () {
303303

304304
expect(result).to.include('"editor" has been changed');
305305
shell.writeInputLine(shellOriginalInput);
306-
await eventually(() => {
306+
await shell.eventually(() => {
307307
shell.assertContainsOutput(shellModifiedInput);
308308
});
309309
});

packages/e2e-tests/test/e2e-snippet.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describe('snippet integration tests', function () {
4747

4848
it('allows managing snippets', async function () {
4949
shell.writeInputLine('snippet install analyze-schema');
50-
await eventually(
50+
await shell.eventually(
5151
() => {
5252
shell.assertContainsOutput(
5353
'Installed new snippets analyze-schema. Do you want to load them now?'
@@ -77,7 +77,7 @@ describe('snippet integration tests', function () {
7777
return this.skip(); // https://jira.mongodb.org/browse/MONGOSH-746
7878
}
7979
shell.writeInput('snippet insta\t');
80-
await eventually(() => {
80+
await shell.eventually(() => {
8181
shell.assertContainsOutput('snippet install');
8282
});
8383
});

0 commit comments

Comments
 (0)