From b97261ce6b6a1d2d2e16926f3a70d08761c34a33 Mon Sep 17 00:00:00 2001 From: Rudolf Meijering Date: Tue, 7 Sep 2021 15:49:51 +0200 Subject: [PATCH] Fix flaky migrations tests (#111365) # Conflicts: # src/core/server/saved_objects/migrationsv2/integration_tests/batch_size_bytes.test.ts --- .../integration_tests/batch_size_bytes.test.ts | 2 ++ .../saved_objects/migrationsv2/test_helpers/retry.test.ts | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/core/server/saved_objects/migrationsv2/integration_tests/batch_size_bytes.test.ts b/src/core/server/saved_objects/migrationsv2/integration_tests/batch_size_bytes.test.ts index 015c104731552..ead46627e324d 100644 --- a/src/core/server/saved_objects/migrationsv2/integration_tests/batch_size_bytes.test.ts +++ b/src/core/server/saved_objects/migrationsv2/integration_tests/batch_size_bytes.test.ts @@ -67,6 +67,8 @@ describe('migration v2', () => { await root.setup(); await expect(root.start()).resolves.toBeTruthy(); + // After plugins start, some saved objects are deleted/recreated, so we + // wait a bit for the count to settle. await new Promise((resolve) => setTimeout(resolve, 5000)); const esClient: ElasticsearchClient = esServer.es.getClient(); diff --git a/src/core/server/saved_objects/migrationsv2/test_helpers/retry.test.ts b/src/core/server/saved_objects/migrationsv2/test_helpers/retry.test.ts index ff5bf3d01c641..8294a61caae6e 100644 --- a/src/core/server/saved_objects/migrationsv2/test_helpers/retry.test.ts +++ b/src/core/server/saved_objects/migrationsv2/test_helpers/retry.test.ts @@ -8,8 +8,7 @@ import { retryAsync } from './retry_async'; -// FLAKY: https://github.com/elastic/kibana/issues/110970 -describe.skip('retry', () => { +describe('retry', () => { it('retries throwing functions until they succeed', async () => { let i = 0; await expect( @@ -53,6 +52,8 @@ describe.skip('retry', () => { }, { retryAttempts: 3, retryDelayMs: 100 } ); - expect(Date.now() - now).toBeGreaterThanOrEqual(200); + // Would expect it to take 200ms but seems like timing inaccuracies + // sometimes causes the duration to be measured as 199ms + expect(Date.now() - now).toBeGreaterThanOrEqual(199); }); });