From 78b304b5072cfe7f2f4dd3cd25eb1b26b8cdd200 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Mon, 17 Aug 2020 16:01:14 +0200 Subject: [PATCH 1/7] Add delay in telemetry test --- .../api_integration/apis/uptime/rest/telemetry_collectors.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts b/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts index f07ddf68152d3..548ccaee5c3f5 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts @@ -9,6 +9,8 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; import { API_URLS } from '../../../../../plugins/uptime/common/constants'; import { makeChecksWithStatus } from './helper/make_checks'; +const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); + export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); const es = getService('legacyEs'); @@ -84,6 +86,7 @@ export default function ({ getService }: FtrProviderContext) { after('unload heartbeat index', () => getService('esArchiver').unload('uptime/blank')); beforeEach(async () => { + await delay(1000); await es.indices.refresh(); }); @@ -119,6 +122,8 @@ export default function ({ getService }: FtrProviderContext) { }); it('should receive expected results after calling overview logging', async () => { + // wait few seconds to make sure data is refreshed, just to avoid flakiness + await delay(2000); // call overview page const { body: result } = await supertest .post(API_URLS.LOG_PAGE_VIEW) From a2d7a0e58e45dfa546d7c229827e8293cf8390c5 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Tue, 18 Aug 2020 16:35:01 +0200 Subject: [PATCH 2/7] simplify test --- .../apis/uptime/rest/telemetry_collectors.ts | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts b/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts index 548ccaee5c3f5..04767f8670b79 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts @@ -15,6 +15,8 @@ export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); const es = getService('legacyEs'); + const retry = getService('retry'); + describe('telemetry collectors', () => { before('generating data', async () => { await getService('esArchiver').load('uptime/blank'); @@ -125,7 +127,7 @@ export default function ({ getService }: FtrProviderContext) { // wait few seconds to make sure data is refreshed, just to avoid flakiness await delay(2000); // call overview page - const { body: result } = await supertest + const { body } = await supertest .post(API_URLS.LOG_PAGE_VIEW) .set('kbn-xsrf', 'true') .send({ @@ -136,21 +138,6 @@ export default function ({ getService }: FtrProviderContext) { autoRefreshEnabled: true, }) .expect(200); - - expect(result).to.eql({ - overview_page: 1, - monitor_page: 1, - no_of_unique_monitors: 4, - settings_page: 0, - monitor_frequency: [120, 0.001, 60, 60], - monitor_name_stats: { min_length: 7, max_length: 22, avg_length: 12 }, - no_of_unique_observer_locations: 3, - observer_location_name_stats: { min_length: 2, max_length: 7, avg_length: 4.8 }, - dateRangeStart: ['now/d', 'now/d'], - dateRangeEnd: ['now/d', 'now-30'], - autoRefreshEnabled: true, - autorefreshInterval: [100, 60], - }); }); }); } From 585838ef9f800fcc19dc15724bc0f5bdac33a933 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Tue, 18 Aug 2020 16:35:59 +0200 Subject: [PATCH 3/7] simplify test --- .../api_integration/apis/uptime/rest/telemetry_collectors.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts b/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts index 04767f8670b79..770876092d6a7 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts @@ -124,8 +124,6 @@ export default function ({ getService }: FtrProviderContext) { }); it('should receive expected results after calling overview logging', async () => { - // wait few seconds to make sure data is refreshed, just to avoid flakiness - await delay(2000); // call overview page const { body } = await supertest .post(API_URLS.LOG_PAGE_VIEW) From 6aa6e523dba49b862fd52b771970f7f3ff7e63c3 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Tue, 18 Aug 2020 16:53:12 +0200 Subject: [PATCH 4/7] fix type --- .../api_integration/apis/uptime/rest/telemetry_collectors.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts b/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts index 770876092d6a7..adc2c1e268d56 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts @@ -15,8 +15,6 @@ export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); const es = getService('legacyEs'); - const retry = getService('retry'); - describe('telemetry collectors', () => { before('generating data', async () => { await getService('esArchiver').load('uptime/blank'); From a2cc84357f5a2e76a1c9571dafcd0710abc906ec Mon Sep 17 00:00:00 2001 From: Shahzad Date: Tue, 18 Aug 2020 16:57:50 +0200 Subject: [PATCH 5/7] fix type --- .../api_integration/apis/uptime/rest/telemetry_collectors.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts b/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts index adc2c1e268d56..26ff3ceb060e9 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts @@ -123,7 +123,7 @@ export default function ({ getService }: FtrProviderContext) { it('should receive expected results after calling overview logging', async () => { // call overview page - const { body } = await supertest + await supertest .post(API_URLS.LOG_PAGE_VIEW) .set('kbn-xsrf', 'true') .send({ From 9d163d80ac9b5852a8697d11e12d32e2e78d1a46 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Wed, 19 Aug 2020 14:52:44 +0200 Subject: [PATCH 6/7] remove delay --- .../api_integration/apis/uptime/rest/telemetry_collectors.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts b/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts index 26ff3ceb060e9..c45a9bb4cec0e 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts @@ -9,8 +9,6 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; import { API_URLS } from '../../../../../plugins/uptime/common/constants'; import { makeChecksWithStatus } from './helper/make_checks'; -const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); - export default function ({ getService }: FtrProviderContext) { const supertest = getService('supertest'); const es = getService('legacyEs'); @@ -86,7 +84,6 @@ export default function ({ getService }: FtrProviderContext) { after('unload heartbeat index', () => getService('esArchiver').unload('uptime/blank')); beforeEach(async () => { - await delay(1000); await es.indices.refresh(); }); From 64fbac83c326f52447254a9159a07b5f949617cc Mon Sep 17 00:00:00 2001 From: Shahzad Date: Fri, 21 Aug 2020 09:50:56 +0200 Subject: [PATCH 7/7] Update telemetry_collectors.ts --- .../api_integration/apis/uptime/rest/telemetry_collectors.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts b/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts index c45a9bb4cec0e..cf1e7ff9f0716 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts @@ -118,7 +118,7 @@ export default function ({ getService }: FtrProviderContext) { }); }); - it('should receive expected results after calling overview logging', async () => { + it('should receive 200 status after overview logging', async () => { // call overview page await supertest .post(API_URLS.LOG_PAGE_VIEW)