From 19098808ef7975c61f57e0782f13b59b92239c5a Mon Sep 17 00:00:00 2001 From: Mateusz Kwasniewski Date: Tue, 24 Oct 2023 14:31:38 +0200 Subject: [PATCH] test: speed up the tests (#5140) --- .../e2e/api/auth/simple-password-provider.e2e.test.ts | 9 ++++++++- src/test/e2e/api/proxy/proxy.concurrency.e2e.test.ts | 2 +- src/test/e2e/stores/client-application-store.e2e.test.ts | 4 ++-- src/test/e2e/stores/client-metrics-store-v2.e2e.test.ts | 8 ++++++-- .../e2e/stores/feature-environment-store.e2e.test.ts | 4 ++-- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/test/e2e/api/auth/simple-password-provider.e2e.test.ts b/src/test/e2e/api/auth/simple-password-provider.e2e.test.ts index bca31bf1fc90..f0ca345fcfeb 100644 --- a/src/test/e2e/api/auth/simple-password-provider.e2e.test.ts +++ b/src/test/e2e/api/auth/simple-password-provider.e2e.test.ts @@ -31,7 +31,7 @@ const password = 'DtUYwi&l5I1KX4@Le'; let userService: UserService; let adminUser: IUser; -beforeEach(async () => { +beforeAll(async () => { db = await dbInit('simple_password_provider_api_serial', getLogger); stores = db.stores; app = await setupApp(stores); @@ -61,8 +61,15 @@ beforeEach(async () => { }); }); +beforeEach(async () => { + app = await setupApp(stores); +}); + afterEach(async () => { await app.destroy(); +}); + +afterAll(async () => { await db.destroy(); }); diff --git a/src/test/e2e/api/proxy/proxy.concurrency.e2e.test.ts b/src/test/e2e/api/proxy/proxy.concurrency.e2e.test.ts index 65ff72634faf..68c0dc214f15 100644 --- a/src/test/e2e/api/proxy/proxy.concurrency.e2e.test.ts +++ b/src/test/e2e/api/proxy/proxy.concurrency.e2e.test.ts @@ -52,7 +52,7 @@ test('multiple parallel calls to api/frontend should not create multiple instanc }); await Promise.all( - Array.from(Array(15).keys()).map(() => + Array.from(Array(10).keys()).map(() => app.request .get('/api/frontend') .set('Authorization', frontendTokenDefault.secret) diff --git a/src/test/e2e/stores/client-application-store.e2e.test.ts b/src/test/e2e/stores/client-application-store.e2e.test.ts index 1a44f087feab..e1d3c9c5bf7c 100644 --- a/src/test/e2e/stores/client-application-store.e2e.test.ts +++ b/src/test/e2e/stores/client-application-store.e2e.test.ts @@ -6,13 +6,13 @@ let db; let stores; let clientApplicationsStore; -beforeEach(async () => { +beforeAll(async () => { db = await dbInit('client_application_store_e2e_serial', getLogger); stores = db.stores; clientApplicationsStore = stores.clientApplicationsStore; }); -afterEach(async () => { +afterAll(async () => { await db.destroy(); }); diff --git a/src/test/e2e/stores/client-metrics-store-v2.e2e.test.ts b/src/test/e2e/stores/client-metrics-store-v2.e2e.test.ts index af2b6d908a5e..0160cd24f727 100644 --- a/src/test/e2e/stores/client-metrics-store-v2.e2e.test.ts +++ b/src/test/e2e/stores/client-metrics-store-v2.e2e.test.ts @@ -11,16 +11,20 @@ let db; let stores: IUnleashStores; let clientMetricsStore: IClientMetricsStoreV2; -beforeEach(async () => { +beforeAll(async () => { db = await dbInit('client_metrics_store_v2_e2e_serial', getLogger); stores = db.stores; clientMetricsStore = stores.clientMetricsStoreV2; }); -afterEach(async () => { +afterAll(async () => { await db.destroy(); }); +beforeEach(async () => { + await stores.clientMetricsStoreV2.deleteAll(); +}); + test('Should store single list of metrics', async () => { const metrics: IClientMetricsEnv[] = [ { diff --git a/src/test/e2e/stores/feature-environment-store.e2e.test.ts b/src/test/e2e/stores/feature-environment-store.e2e.test.ts index 3c91e0a40697..0a499de46a22 100644 --- a/src/test/e2e/stores/feature-environment-store.e2e.test.ts +++ b/src/test/e2e/stores/feature-environment-store.e2e.test.ts @@ -11,7 +11,7 @@ let featureEnvironmentStore: IFeatureEnvironmentStore; let featureStore: IFeatureToggleStore; let environmentStore: IEnvironmentStore; -beforeEach(async () => { +beforeAll(async () => { db = await dbInit('feature_environment_store_serial', getLogger); stores = db.stores; featureEnvironmentStore = stores.featureEnvironmentStore; @@ -19,7 +19,7 @@ beforeEach(async () => { featureStore = stores.featureToggleStore; }); -afterEach(async () => { +afterAll(async () => { await db.destroy(); });