Skip to content

Commit 6c9a9b4

Browse files
authored
fix(e2e-tests): increase timeouts for AWS tests MONGOSH-1924 (#2286)
This should hopefully address AWS auth test flakiness on s390x, where DNS queries can take multiple seconds each due to the host CI setup.
1 parent 9b2fd8d commit 6c9a9b4

File tree

2 files changed

+73
-43
lines changed

2 files changed

+73
-43
lines changed

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

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ function getConnectionString(username?: string, password?: string): string {
8383
}
8484

8585
describe('e2e AWS AUTH', function () {
86-
this.timeout(60_000); // AWS auth tests can take longer than the default timeout in CI
86+
// AWS auth tests can take longer than the default timeout in CI
87+
// DNS resolution for many hosts in particular can be time-intensive in some
88+
// CI environments
89+
this.timeout(80_000);
90+
const initialWaitForPromptTimeoutOptions = { timeout: 60_000 };
8791
let expectedAssumedRole: string;
8892

8993
before(function () {
@@ -128,7 +132,9 @@ describe('e2e AWS AUTH', function () {
128132
AWS_SECRET_ACCESS_KEY,
129133
],
130134
});
131-
const result = await shell.waitForPromptOrExit();
135+
const result = await shell.waitForPromptOrExit(
136+
initialWaitForPromptTimeoutOptions
137+
);
132138
expect(result.state).to.equal('prompt');
133139

134140
const connectionStatus = await shell.executeLine(
@@ -150,7 +156,9 @@ describe('e2e AWS AUTH', function () {
150156
tokenDetails.token,
151157
],
152158
});
153-
const result = await shell.waitForPromptOrExit();
159+
const result = await shell.waitForPromptOrExit(
160+
initialWaitForPromptTimeoutOptions
161+
);
154162
expect(result.state).to.equal('prompt');
155163

156164
const connectionStatus = await shell.executeLine(
@@ -165,7 +173,9 @@ describe('e2e AWS AUTH', function () {
165173
const shell = this.startTestShell({
166174
args: [getConnectionString(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)],
167175
});
168-
const result = await shell.waitForPromptOrExit();
176+
const result = await shell.waitForPromptOrExit(
177+
initialWaitForPromptTimeoutOptions
178+
);
169179
expect(result.state).to.equal('prompt');
170180

171181
const connectionStatus = await shell.executeLine(
@@ -186,7 +196,9 @@ describe('e2e AWS AUTH', function () {
186196
)}`,
187197
],
188198
});
189-
const result = await shell.waitForPromptOrExit();
199+
const result = await shell.waitForPromptOrExit(
200+
initialWaitForPromptTimeoutOptions
201+
);
190202
expect(result.state).to.equal('prompt');
191203

192204
const connectionStatus = await shell.executeLine(
@@ -208,7 +220,9 @@ describe('e2e AWS AUTH', function () {
208220
AWS_SECRET_ACCESS_KEY,
209221
},
210222
});
211-
const result = await shell.waitForPromptOrExit();
223+
const result = await shell.waitForPromptOrExit(
224+
initialWaitForPromptTimeoutOptions
225+
);
212226
expect(result.state).to.equal('prompt');
213227

214228
const connectionStatus = await shell.executeLine(
@@ -228,7 +242,9 @@ describe('e2e AWS AUTH', function () {
228242
AWS_SESSION_TOKEN: tokenDetails.token,
229243
},
230244
});
231-
const result = await shell.waitForPromptOrExit();
245+
const result = await shell.waitForPromptOrExit(
246+
initialWaitForPromptTimeoutOptions
247+
);
232248
expect(result.state).to.equal('prompt');
233249

234250
const connectionStatus = await shell.executeLine(
@@ -254,7 +270,9 @@ describe('e2e AWS AUTH', function () {
254270
AWS_SECRET_ACCESS_KEY: 'invalid',
255271
},
256272
});
257-
const result = await shell.waitForPromptOrExit();
273+
const result = await shell.waitForPromptOrExit(
274+
initialWaitForPromptTimeoutOptions
275+
);
258276
expect(result.state).to.equal('prompt');
259277

260278
const connectionStatus = await shell.executeLine(
@@ -282,7 +300,9 @@ describe('e2e AWS AUTH', function () {
282300
AWS_SESSION_TOKEN: 'invalid',
283301
},
284302
});
285-
const result = await shell.waitForPromptOrExit();
303+
const result = await shell.waitForPromptOrExit(
304+
initialWaitForPromptTimeoutOptions
305+
);
286306
expect(result.state).to.equal('prompt');
287307

288308
const connectionStatus = await shell.executeLine(

packages/e2e-tests/test/test-shell.ts

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -199,40 +199,46 @@ export class TestShell {
199199
});
200200
}
201201

202-
async waitForPrompt(start = 0): Promise<void> {
203-
await eventually(() => {
204-
const output = this._output.slice(start);
205-
const lines = output.split('\n');
206-
const found = !!lines
207-
.filter((l) => PROMPT_PATTERN.exec(l)) // a line that is the prompt must at least match the pattern
208-
.find((l) => {
209-
// in some situations the prompt occurs multiple times in the line (but only in tests!)
210-
const prompts = l
211-
.trim()
212-
.replace(/>$/g, '')
213-
.split('>')
214-
.map((m) => m.trim());
215-
// if there are multiple prompt parts they must all equal
216-
if (prompts.length > 1) {
217-
for (const p of prompts) {
218-
if (p !== prompts[0]) {
219-
return false;
202+
async waitForPrompt(
203+
start = 0,
204+
opts: { timeout?: number } = {}
205+
): Promise<void> {
206+
await eventually(
207+
() => {
208+
const output = this._output.slice(start);
209+
const lines = output.split('\n');
210+
const found = !!lines
211+
.filter((l) => PROMPT_PATTERN.exec(l)) // a line that is the prompt must at least match the pattern
212+
.find((l) => {
213+
// in some situations the prompt occurs multiple times in the line (but only in tests!)
214+
const prompts = l
215+
.trim()
216+
.replace(/>$/g, '')
217+
.split('>')
218+
.map((m) => m.trim());
219+
// if there are multiple prompt parts they must all equal
220+
if (prompts.length > 1) {
221+
for (const p of prompts) {
222+
if (p !== prompts[0]) {
223+
return false;
224+
}
220225
}
221226
}
222-
}
223-
return true;
224-
});
225-
if (!found) {
226-
throw new assert.AssertionError({
227-
message: 'expected prompt',
228-
expected: PROMPT_PATTERN.toString(),
229-
actual:
230-
this._output.slice(0, start) +
231-
'[prompt search starts here]' +
232-
output,
233-
});
234-
}
235-
});
227+
return true;
228+
});
229+
if (!found) {
230+
throw new assert.AssertionError({
231+
message: 'expected prompt',
232+
expected: PROMPT_PATTERN.toString(),
233+
actual:
234+
this._output.slice(0, start) +
235+
'[prompt search starts here]' +
236+
output,
237+
});
238+
}
239+
},
240+
{ ...opts }
241+
);
236242
}
237243

238244
waitForExit(): Promise<number> {
@@ -248,9 +254,13 @@ export class TestShell {
248254
return this.output;
249255
}
250256

251-
async waitForPromptOrExit(): Promise<TestShellStartupResult> {
257+
async waitForPromptOrExit(
258+
opts: { timeout?: number; start?: number } = {}
259+
): Promise<TestShellStartupResult> {
252260
return Promise.race([
253-
this.waitForPrompt().then(() => ({ state: 'prompt' } as const)),
261+
this.waitForPrompt(opts.start ?? 0, opts).then(
262+
() => ({ state: 'prompt' } as const)
263+
),
254264
this.waitForExit().then((c) => ({ state: 'exit', exitCode: c } as const)),
255265
]);
256266
}

0 commit comments

Comments
 (0)