Skip to content

Commit 097c660

Browse files
[9.2] Make the test more flexible to entries that might have been rolled over (#240072) (#240240)
# Backport This will backport the following commits from `main` to `9.2`: - [Make the test more flexible to entries that might have been rolled over (#240072)](#240072) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Gerard Soldevila","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-10-23T09:49:45Z","message":"Make the test more flexible to entries that might have been rolled over (#240072)\n\n## Summary\n\nCloses https://github.com/elastic/kibana/issues/232893\n\nDespite the complex time synchronization mechanism, the rollover can\nhappen right in the middle of us logging.\nThe PR makes the test a bit more permissive in that sense.","sha":"7b73ce0c514eaf4ede20982b8bfb52181a95412a","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Core","release_note:skip","test-failure-flaky","backport:all-open","v9.3.0"],"title":"Make the test more flexible to entries that might have been rolled over","number":240072,"url":"https://github.com/elastic/kibana/pull/240072","mergeCommit":{"message":"Make the test more flexible to entries that might have been rolled over (#240072)\n\n## Summary\n\nCloses https://github.com/elastic/kibana/issues/232893\n\nDespite the complex time synchronization mechanism, the rollover can\nhappen right in the middle of us logging.\nThe PR makes the test a bit more permissive in that sense.","sha":"7b73ce0c514eaf4ede20982b8bfb52181a95412a"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/240072","number":240072,"mergeCommit":{"message":"Make the test more flexible to entries that might have been rolled over (#240072)\n\n## Summary\n\nCloses https://github.com/elastic/kibana/issues/232893\n\nDespite the complex time synchronization mechanism, the rollover can\nhappen right in the middle of us logging.\nThe PR makes the test a bit more permissive in that sense.","sha":"7b73ce0c514eaf4ede20982b8bfb52181a95412a"}}]}] BACKPORT--> Co-authored-by: Gerard Soldevila <[email protected]>
1 parent 5879428 commit 097c660

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/core/server/integration_tests/logging/rolling_file_appender.test.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,27 @@ describe('RollingFileAppender', () => {
303303
logger.info(message(3));
304304
logger.info(message(4));
305305

306+
await waitForNextRollingTime();
307+
308+
logger.info(message(5));
309+
logger.info(message(6));
310+
306311
await flush();
307312

308313
const files = await readdir(testDir);
309314

310-
expect(files.sort()).toEqual(['kibana-1.log', 'kibana.log']);
311-
expect(await getFileContent('kibana.log')).toEqual(expectedFileContent([3, 4]));
312-
expect(await getFileContent('kibana-1.log')).toEqual(expectedFileContent([1, 2]));
315+
const sortedLogFiles = files.sort();
316+
expect(sortedLogFiles).toEqual(['kibana-1.log', 'kibana-2.log', 'kibana.log']);
317+
318+
// the "rolling time sync" mechanism above is not perfect, so the test is going to guarantee:
319+
// - that something has been rolled over
320+
// - that no log entries have been lost
321+
const oldestEntries = await getFileContent('kibana-2.log');
322+
const newerEntries = await getFileContent('kibana-1.log');
323+
const newestEntries = await getFileContent('kibana.log');
324+
const allEntries = oldestEntries + newerEntries + newestEntries;
325+
expect(oldestEntries.length + newerEntries.length).toBeGreaterThan(40);
326+
expect(allEntries).toEqual(expectedFileContent([1, 2, 3, 4, 5, 6]));
313327
});
314328
});
315329
});

0 commit comments

Comments
 (0)