Skip to content

Commit e894942

Browse files
authored
fix(e2e-tests): handle flakiness of logging retention tests MONGOSH-2050 (#2431)
Our logging retention e2e tests are flaky, most likely because we do not wait for the shell process to finish cleaning up files before checking their existence. This wraps them in eventually, allowing us to retry accordingly.
1 parent 3cf6224 commit e894942

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

Diff for: packages/e2e-tests/test/e2e.spec.ts

+21-11
Original file line numberDiff line numberDiff line change
@@ -1821,8 +1821,11 @@ describe('e2e', function () {
18211821

18221822
// Add the newly created log file
18231823
paths.push(path.join(customLogDir.path, getLogName(shell.logId)));
1824-
// Expect 6 files to be deleted and 5 to remain (including the new log file)
1825-
expect(await getFilesState(paths)).equals('00000011111');
1824+
1825+
await eventually(async () => {
1826+
// Expect 6 files to be deleted and 5 to remain (including the new log file)
1827+
expect(await getFilesState(paths)).equals('00000011111');
1828+
});
18261829
});
18271830
});
18281831

@@ -1874,10 +1877,13 @@ describe('e2e', function () {
18741877
await shell.waitForPrompt();
18751878

18761879
paths.push(path.join(customLogDir.path, getLogName(shell.logId)));
1877-
// 3 log files without mongosh_ prefix should remain
1878-
// 2 log file with mongosh_ prefix should be deleted
1879-
// 2 log files with mongosh_ prefix should remain (including the new log)
1880-
expect(await getFilesState(paths)).to.equal('1110011');
1880+
1881+
await eventually(async () => {
1882+
// 3 log files without mongosh_ prefix should remain
1883+
// 2 log file with mongosh_ prefix should be deleted
1884+
// 2 log files with mongosh_ prefix should remain (including the new log)
1885+
expect(await getFilesState(paths)).to.equal('1110011');
1886+
});
18811887
});
18821888

18831889
it('should delete files once it is above logMaxFileCount', async function () {
@@ -1913,8 +1919,10 @@ describe('e2e', function () {
19131919
await shell.executeLine('config.get("logMaxFileCount")')
19141920
).contains('4');
19151921

1916-
// Expect 7 files to be deleted and 4 to remain (including the new log file)
1917-
expect(await getFilesState(paths)).to.equal('00000001111');
1922+
await eventually(async () => {
1923+
// Expect 7 files to be deleted and 4 to remain (including the new log file)
1924+
expect(await getFilesState(paths)).to.equal('00000001111');
1925+
});
19181926
});
19191927
});
19201928

@@ -1959,9 +1967,11 @@ describe('e2e', function () {
19591967
await shell.executeLine('config.get("logRetentionGB")')
19601968
).contains(`${4 / 1024}`);
19611969

1962-
// Expect 6 files to be deleted and 4 to remain
1963-
// (including the new log file which should be <1 MB)
1964-
expect(await getFilesState(paths)).to.equal('00000001111');
1970+
await eventually(async () => {
1971+
// Expect 6 files to be deleted and 4 to remain
1972+
// (including the new log file which should be <1 MB)
1973+
expect(await getFilesState(paths)).to.equal('00000001111');
1974+
});
19651975
});
19661976
});
19671977

0 commit comments

Comments
 (0)