Skip to content

Commit db25c73

Browse files
committed
Implement and use a TestShell.eventually
1 parent 35732c9 commit db25c73

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
@@ -300,7 +300,7 @@ describe('Auth e2e', function () {
300300
it('dropAllUsers', async function () {
301301
await shell.executeLine(`use ${dbName}`);
302302
shell.writeInputLine('db.dropAllUsers()');
303-
await eventually(() => {
303+
await shell.eventually(() => {
304304
try {
305305
shell.assertContainsOutput('{ n: 2, ok: 1 }');
306306
} catch {
@@ -510,7 +510,7 @@ describe('Auth e2e', function () {
510510
it('dropAllRoles', async function () {
511511
await shell.executeLine(`use ${dbName}`);
512512
shell.writeInputLine('db.dropAllRoles()');
513-
await eventually(() => {
513+
await shell.eventually(() => {
514514
try {
515515
shell.assertContainsOutput('{ n: 2, ok: 1 }');
516516
} catch {
@@ -739,7 +739,7 @@ describe('Auth e2e', function () {
739739
it('throws if pwd is wrong', async function () {
740740
await shell.executeLine(`use ${dbName}`);
741741
shell.writeInputLine('db.auth("anna", "pwd2")');
742-
await eventually(
742+
await shell.eventually(
743743
() => {
744744
shell.assertContainsError('Authentication failed');
745745
},
@@ -754,7 +754,7 @@ describe('Auth e2e', function () {
754754
shell.writeInputLine(
755755
'db.auth({ user: "anna", pwd: "pwd2", mechanism: "not a mechanism"})'
756756
);
757-
await eventually(
757+
await shell.eventually(
758758
() => {
759759
expect(shell.output).to.match(
760760
/MongoParseError: authMechanism one of .+, got not a mechanism/
@@ -1069,7 +1069,7 @@ describe('Auth e2e', function () {
10691069
'SCRAM-SHA-1',
10701070
],
10711071
});
1072-
await eventually(() => {
1072+
await shell.eventually(() => {
10731073
expect(shell.output).to.match(
10741074
/MongoServerError: Authentication failed|Unable to use SCRAM-SHA-1/
10751075
);
@@ -1090,7 +1090,7 @@ describe('Auth e2e', function () {
10901090
'SCRAM-SHA-256',
10911091
],
10921092
});
1093-
await eventually(() => {
1093+
await shell.eventually(() => {
10941094
expect(shell.output).to.match(
10951095
/MongoServerError: Authentication failed|Unable to use SCRAM-SHA-256/
10961096
);

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(
@@ -197,7 +202,7 @@ describe('e2e direct connection', function () {
197202
await shell.waitForPrompt();
198203
shell.writeInput('db.testc');
199204
await tabtab(shell);
200-
await eventually(() => {
205+
await shell.eventually(() => {
201206
shell.assertContainsOutput('db.testcollection');
202207
});
203208
});
@@ -363,7 +368,7 @@ describe('e2e direct connection', function () {
363368
await shell.waitForPrompt();
364369
shell.writeInput('db.testc');
365370
await tabtab(shell);
366-
await eventually(() => {
371+
await shell.eventually(() => {
367372
shell.assertContainsOutput('db.testcollection');
368373
});
369374
});

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

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

7272
expect(result).to.include('"editor" has been changed');
7373
shell.writeInputLine(shellOriginalInput);
74-
await eventually(() => {
74+
await shell.eventually(() => {
7575
shell.assertContainsOutput(shellModifiedInput);
7676
});
7777
});
@@ -95,7 +95,7 @@ describe('external editor e2e', function () {
9595

9696
expect(result).to.include('"editor" has been changed');
9797
shell.writeInputLine(shellOriginalInput);
98-
await eventually(() => {
98+
await shell.eventually(() => {
9999
shell.assertContainsOutput(shellModifiedInput);
100100
});
101101
});
@@ -116,7 +116,7 @@ describe('external editor e2e', function () {
116116

117117
expect(result).to.include('"editor" has been changed');
118118
shell.writeInputLine(shellOriginalInput);
119-
await eventually(() => {
119+
await shell.eventually(() => {
120120
shell.assertContainsOutput(shellModifiedInput);
121121
});
122122
});
@@ -143,7 +143,7 @@ describe('external editor e2e', function () {
143143

144144
expect(result).to.include('"editor" has been changed');
145145
shell.writeInputLine(shellOriginalInput);
146-
await eventually(() => {
146+
await shell.eventually(() => {
147147
shell.assertContainsOutput(shellModifiedInput);
148148
});
149149
});
@@ -161,7 +161,7 @@ describe('external editor e2e', function () {
161161

162162
expect(result).to.include('"editor" has been changed');
163163
shell.writeInputLine(shellOriginalInput);
164-
await eventually(() => {
164+
await shell.eventually(() => {
165165
shell.assertContainsError('failed with an exit code 1');
166166
});
167167
});
@@ -180,7 +180,7 @@ describe('external editor e2e', function () {
180180

181181
expect(result).to.include('"editor" has been changed');
182182
shell.writeInputLine('edit');
183-
await eventually(() => {
183+
await shell.eventually(() => {
184184
shell.assertContainsOutput(output);
185185
});
186186
});
@@ -214,7 +214,7 @@ describe('external editor e2e', function () {
214214
"const name = 'I want to test a sequence of writeInputLine'"
215215
);
216216
shell.writeInputLine('edit name');
217-
await eventually(() => {
217+
await shell.eventually(() => {
218218
shell.assertContainsOutput(shellModifiedInput);
219219
});
220220
});
@@ -252,7 +252,7 @@ describe('external editor e2e', function () {
252252

253253
expect(result).to.include('"editor" has been changed');
254254
shell.writeInputLine(shellOriginalInput);
255-
await eventually(() => {
255+
await shell.eventually(() => {
256256
shell.assertContainsOutput(shellModifiedInput);
257257
});
258258
});
@@ -277,7 +277,7 @@ describe('external editor e2e', function () {
277277

278278
expect(result).to.include('"editor" has been changed');
279279
shell.writeInputLine(shellOriginalInput);
280-
await eventually(() => {
280+
await shell.eventually(() => {
281281
shell.assertContainsOutput(shellModifiedInput);
282282
});
283283
});
@@ -301,7 +301,7 @@ describe('external editor e2e', function () {
301301

302302
expect(result).to.include('"editor" has been changed');
303303
shell.writeInputLine(shellOriginalInput);
304-
await eventually(() => {
304+
await shell.eventually(() => {
305305
shell.assertContainsOutput(shellModifiedInput);
306306
});
307307
});

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

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

5050
it('allows managing snippets', async function () {
5151
shell.writeInputLine('snippet install analyze-schema');
52-
await eventually(
52+
await shell.eventually(
5353
() => {
5454
shell.assertContainsOutput(
5555
'Installed new snippets analyze-schema. Do you want to load them now?'
@@ -79,7 +79,7 @@ describe('snippet integration tests', function () {
7979
return this.skip(); // https://jira.mongodb.org/browse/MONGOSH-746
8080
}
8181
shell.writeInput('snippet insta\t');
82-
await eventually(() => {
82+
await shell.eventually(() => {
8383
shell.assertContainsOutput('snippet install');
8484
});
8585
});

0 commit comments

Comments
 (0)