mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
# Backport This will backport the following commits from `main` to `8.18`: - [[UI Counters] fix flaky test retry logic (#224151)](https://github.com/elastic/kibana/pull/224151) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Ahmad Bamieh","email":"ahmad.bamyeh@elastic.co"},"sourceCommit":{"committedDate":"2025-06-17T01:37:37Z","message":"[UI Counters] fix flaky test retry logic (#224151)\n\nRevisit `waitForWithTimeout` to use 5 retries and an initial waiting\ntime\ncloses https://github.com/elastic/kibana/issues/98240\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"699212fa7eb7a5440759c8a01f095e0bf2ca9479","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:prev-minor","backport:prev-major","v9.1.0","v9.0.3"],"title":"[UI Counters] fix flaky test retry logic","number":224151,"url":"https://github.com/elastic/kibana/pull/224151","mergeCommit":{"message":"[UI Counters] fix flaky test retry logic (#224151)\n\nRevisit `waitForWithTimeout` to use 5 retries and an initial waiting\ntime\ncloses https://github.com/elastic/kibana/issues/98240\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"699212fa7eb7a5440759c8a01f095e0bf2ca9479"}},"sourceBranch":"main","suggestedTargetBranches":["9.0"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/224151","number":224151,"mergeCommit":{"message":"[UI Counters] fix flaky test retry logic (#224151)\n\nRevisit `waitForWithTimeout` to use 5 retries and an initial waiting\ntime\ncloses https://github.com/elastic/kibana/issues/98240\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"699212fa7eb7a5440759c8a01f095e0bf2ca9479"}},{"branch":"9.0","label":"v9.0.3","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Ahmad Bamieh <ahmad.bamyeh@elastic.co>
This commit is contained in:
parent
e01dba894d
commit
c1ecf25cce
1 changed files with 46 additions and 32 deletions
|
@ -15,6 +15,8 @@ import { FtrProviderContext } from '../../ftr_provider_context';
|
||||||
|
|
||||||
const APP_NAME = 'myApp';
|
const APP_NAME = 'myApp';
|
||||||
|
|
||||||
|
const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
|
|
||||||
export default function ({ getService }: FtrProviderContext) {
|
export default function ({ getService }: FtrProviderContext) {
|
||||||
const supertest = getService('supertest');
|
const supertest = getService('supertest');
|
||||||
const esArchiver = getService('esArchiver');
|
const esArchiver = getService('esArchiver');
|
||||||
|
@ -91,7 +93,11 @@ export default function ({ getService }: FtrProviderContext) {
|
||||||
const { report } = reportManager.assignReports([counterEvent]);
|
const { report } = reportManager.assignReports([counterEvent]);
|
||||||
|
|
||||||
await sendReport(report);
|
await sendReport(report);
|
||||||
await retry.waitForWithTimeout('reported events to be stored into ES', 8000, async () => {
|
// Wait for the report to be query-able in ES since sending report uses (refresh = false)
|
||||||
|
await delay(3000);
|
||||||
|
await retry.tryWithRetries(
|
||||||
|
'reported events to be stored into ES',
|
||||||
|
async () => {
|
||||||
const savedObjects = await fetchUsageCountersObjects();
|
const savedObjects = await fetchUsageCountersObjects();
|
||||||
|
|
||||||
const countTypeEvents = getCounter(savedObjects, eventName, METRIC_TYPE.COUNT);
|
const countTypeEvents = getCounter(savedObjects, eventName, METRIC_TYPE.COUNT);
|
||||||
|
@ -99,7 +105,9 @@ export default function ({ getService }: FtrProviderContext) {
|
||||||
expect(countTypeEvents.length).to.eql(1);
|
expect(countTypeEvents.length).to.eql(1);
|
||||||
expect(countTypeEvents[0].attributes.count).to.eql(1);
|
expect(countTypeEvents[0].attributes.count).to.eql(1);
|
||||||
return true;
|
return true;
|
||||||
});
|
},
|
||||||
|
{ retryCount: 6, retryDelay: 1500 }
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('supports multiple events', async () => {
|
it('supports multiple events', async () => {
|
||||||
|
@ -115,7 +123,11 @@ export default function ({ getService }: FtrProviderContext) {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
await sendReport(report);
|
await sendReport(report);
|
||||||
await retry.waitForWithTimeout('reported events to be stored into ES', 8000, async () => {
|
// Wait for the report to be query-able in ES since sending report uses (refresh = false)
|
||||||
|
await delay(3000);
|
||||||
|
await retry.tryWithRetries(
|
||||||
|
'reported events to be stored into ES',
|
||||||
|
async () => {
|
||||||
const savedObjects = await fetchUsageCountersObjects();
|
const savedObjects = await fetchUsageCountersObjects();
|
||||||
const firstEventWithCountTypeEvents = getCounter(
|
const firstEventWithCountTypeEvents = getCounter(
|
||||||
savedObjects,
|
savedObjects,
|
||||||
|
@ -141,7 +153,9 @@ export default function ({ getService }: FtrProviderContext) {
|
||||||
expect(secondEventWithCountTypeEvents.length).to.eql(1);
|
expect(secondEventWithCountTypeEvents.length).to.eql(1);
|
||||||
expect(secondEventWithCountTypeEvents[0].attributes.count).to.eql(1);
|
expect(secondEventWithCountTypeEvents[0].attributes.count).to.eql(1);
|
||||||
return true;
|
return true;
|
||||||
});
|
},
|
||||||
|
{ retryCount: 6, retryDelay: 1500 }
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue