From e2642d9f0750223b7438fb2a6274b97c0a575bca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20Haro?= Date: Mon, 6 May 2024 21:25:25 +0200 Subject: [PATCH] Fix flaky licensing test #148313 (#182712) (cherry picked from commit 6740ffb8761097a35dd9be7b353fff33eef3d0da) --- x-pack/test/licensing_plugin/scenario.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/x-pack/test/licensing_plugin/scenario.ts b/x-pack/test/licensing_plugin/scenario.ts index 1d71af4517569..f824745913f86 100644 --- a/x-pack/test/licensing_plugin/scenario.ts +++ b/x-pack/test/licensing_plugin/scenario.ts @@ -17,6 +17,7 @@ export function createScenario({ getService, getPageObjects }: FtrProviderContex const esSupertestWithoutAuth = getService('esSupertestWithoutAuth'); const security = getService('security'); const PageObjects = getPageObjects(['common', 'security']); + const retry = getService('retry'); const scenario = { async setup() { @@ -109,9 +110,27 @@ export function createScenario({ getService, getPageObjects }: FtrProviderContex }, async waitForPluginToDetectLicenseUpdate() { + const { + body: { license: esLicense }, + } = await esSupertestWithoutAuth + .get('/_license') + .auth('license_manager_user', 'license_manager_user-password') + .expect(200); // > --xpack.licensing.api_polling_frequency set in test config // to wait for Kibana server to re-fetch the license from Elasticsearch - await delay(500); + const pollingFrequency = 500; + + await retry.waitForWithTimeout( + 'waiting for the license.uid to match ES', + 4 * pollingFrequency, + async () => { + const { + body: { license: kbLicense }, + } = await supertest.get('/api/licensing/info').expect(200); + return kbLicense?.uid === esLicense?.uid; + }, + () => delay(pollingFrequency) + ); }, }; return scenario;