From 0170326fdb3d47793938e30f66d41acfefa4651a Mon Sep 17 00:00:00 2001 From: shahzad Date: Tue, 25 Feb 2020 13:36:12 +0100 Subject: [PATCH] update test --- .../graphql/fixtures/monitor_charts.json | 275 ------------------ .../fixtures/monitor_charts_empty_set.json | 8 - .../fixtures/monitor_charts_empty_sets.json | 8 - .../apis/uptime/graphql/index.js | 1 - .../apis/uptime/graphql/monitor_charts.js | 57 ---- .../uptime/rest/fixtures/monitor_charts.json | 273 +++++++++++++++++ .../fixtures/monitor_charts_empty_sets.json | 6 + .../api_integration/apis/uptime/rest/index.ts | 1 + .../apis/uptime/rest/monitor_duration.ts | 41 +++ 9 files changed, 321 insertions(+), 349 deletions(-) delete mode 100644 x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_charts.json delete mode 100644 x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_charts_empty_set.json delete mode 100644 x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_charts_empty_sets.json delete mode 100644 x-pack/test/api_integration/apis/uptime/graphql/monitor_charts.js create mode 100644 x-pack/test/api_integration/apis/uptime/rest/fixtures/monitor_charts.json create mode 100644 x-pack/test/api_integration/apis/uptime/rest/fixtures/monitor_charts_empty_sets.json create mode 100644 x-pack/test/api_integration/apis/uptime/rest/monitor_duration.ts diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_charts.json b/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_charts.json deleted file mode 100644 index dbfc17a468796..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_charts.json +++ /dev/null @@ -1,275 +0,0 @@ -{ - "monitorChartsData": { - "locationDurationLines": [ - { - "name": "mpls", - "line": [ - { - "x": 1568172657286, - "y": 16274 - }, - { - "x": 1568172680087, - "y": 16713 - }, - { - "x": 1568172702888, - "y": 34756 - }, - { - "x": 1568172725689, - "y": null - }, - { - "x": 1568172748490, - "y": 22205 - }, - { - "x": 1568172771291, - "y": 6071 - }, - { - "x": 1568172794092, - "y": 15681 - }, - { - "x": 1568172816893, - "y": null - }, - { - "x": 1568172839694, - "y": 1669 - }, - { - "x": 1568172862495, - "y": 956 - }, - { - "x": 1568172885296, - "y": 1435 - }, - { - "x": 1568172908097, - "y": null - }, - { - "x": 1568172930898, - "y": 32906 - }, - { - "x": 1568172953699, - "y": 892 - }, - { - "x": 1568172976500, - "y": 1514 - }, - { - "x": 1568172999301, - "y": null - }, - { - "x": 1568173022102, - "y": 2367 - }, - { - "x": 1568173044903, - "y": 3389 - }, - { - "x": 1568173067704, - "y": 362 - }, - { - "x": 1568173090505, - "y": null - }, - { - "x": 1568173113306, - "y": 3066 - }, - { - "x": 1568173136107, - "y": 44513 - }, - { - "x": 1568173158908, - "y": 6417 - }, - { - "x": 1568173181709, - "y": 1416 - }, - { - "x": 1568173204510, - "y": null - }, - { - "x": 1568173227311, - "y": 24627 - } - ] - } - ], - "status": [ - { - "x": 1568172657286, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568172680087, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568172702888, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568172725689, - "up": null, - "down": null, - "total": 0 - }, - { - "x": 1568172748490, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568172771291, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568172794092, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568172816893, - "up": null, - "down": null, - "total": 0 - }, - { - "x": 1568172839694, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568172862495, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568172885296, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568172908097, - "up": null, - "down": null, - "total": 0 - }, - { - "x": 1568172930898, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568172953699, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568172976500, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568172999301, - "up": null, - "down": null, - "total": 0 - }, - { - "x": 1568173022102, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568173044903, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568173067704, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568173090505, - "up": null, - "down": null, - "total": 0 - }, - { - "x": 1568173113306, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568173136107, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568173158908, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568173181709, - "up": null, - "down": null, - "total": 1 - }, - { - "x": 1568173204510, - "up": null, - "down": null, - "total": 0 - }, - { - "x": 1568173227311, - "up": null, - "down": null, - "total": 1 - } - ], - "statusMaxCount": 0, - "durationMaxValue": 0 - } -} \ No newline at end of file diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_charts_empty_set.json b/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_charts_empty_set.json deleted file mode 100644 index d4257371553d6..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_charts_empty_set.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "monitorChartsData": { - "status": [], - "locationDurationLines": [], - "statusMaxCount": 0, - "durationMaxValue": 0 - } -} diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_charts_empty_sets.json b/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_charts_empty_sets.json deleted file mode 100644 index b0b7d8e17391a..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_charts_empty_sets.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "monitorChartsData": { - "locationDurationLines": [], - "status": [], - "statusMaxCount": 0, - "durationMaxValue": 0 - } -} \ No newline at end of file diff --git a/x-pack/test/api_integration/apis/uptime/graphql/index.js b/x-pack/test/api_integration/apis/uptime/graphql/index.js index 54284377ec430..c2fdc57edede3 100644 --- a/x-pack/test/api_integration/apis/uptime/graphql/index.js +++ b/x-pack/test/api_integration/apis/uptime/graphql/index.js @@ -11,7 +11,6 @@ export default function({ loadTestFile }) { // verifying the pre-loaded documents are returned in a way that // matches the snapshots contained in './fixtures' loadTestFile(require.resolve('./doc_count')); - loadTestFile(require.resolve('./monitor_charts')); loadTestFile(require.resolve('./monitor_states')); loadTestFile(require.resolve('./ping_list')); }); diff --git a/x-pack/test/api_integration/apis/uptime/graphql/monitor_charts.js b/x-pack/test/api_integration/apis/uptime/graphql/monitor_charts.js deleted file mode 100644 index baa7104e02219..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/monitor_charts.js +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { monitorChartsQueryString } from '../../../../../legacy/plugins/uptime/public/queries'; -import { expectFixtureEql } from './helpers/expect_fixture_eql'; - -export default function({ getService }) { - describe('monitorCharts query', () => { - before('load heartbeat data', () => getService('esArchiver').load('uptime/full_heartbeat')); - after('unload heartbeat index', () => getService('esArchiver').unload('uptime/full_heartbeat')); - - const supertest = getService('supertest'); - - it('will fetch a series of data points for monitor duration and status', async () => { - const getMonitorChartsQuery = { - operationName: 'MonitorCharts', - query: monitorChartsQueryString, - variables: { - dateRangeStart: '2019-09-11T03:31:04.380Z', - dateRangeEnd: '2019-09-11T03:40:34.410Z', - monitorId: '0002-up', - }, - }; - const { - body: { data }, - } = await supertest - .post('/api/uptime/graphql') - .set('kbn-xsrf', 'foo') - .send({ ...getMonitorChartsQuery }); - - expectFixtureEql(data, 'monitor_charts'); - }); - - it('will fetch empty sets for a date range with no data', async () => { - const getMonitorChartsQuery = { - operationName: 'MonitorCharts', - query: monitorChartsQueryString, - variables: { - dateRangeStart: '1999-09-11T03:31:04.380Z', - dateRangeEnd: '1999-09-11T03:40:34.410Z', - monitorId: '0002-up', - }, - }; - const { - body: { data }, - } = await supertest - .post('/api/uptime/graphql') - .set('kbn-xsrf', 'foo') - .send({ ...getMonitorChartsQuery }); - - expectFixtureEql(data, 'monitor_charts_empty_sets'); - }); - }); -} diff --git a/x-pack/test/api_integration/apis/uptime/rest/fixtures/monitor_charts.json b/x-pack/test/api_integration/apis/uptime/rest/fixtures/monitor_charts.json new file mode 100644 index 0000000000000..1aa0788a6da05 --- /dev/null +++ b/x-pack/test/api_integration/apis/uptime/rest/fixtures/monitor_charts.json @@ -0,0 +1,273 @@ +{ + "locationDurationLines": [ + { + "name": "mpls", + "line": [ + { + "x": 1568172657286, + "y": 16274 + }, + { + "x": 1568172680087, + "y": 16713 + }, + { + "x": 1568172702888, + "y": 34756 + }, + { + "x": 1568172725689, + "y": null + }, + { + "x": 1568172748490, + "y": 22205 + }, + { + "x": 1568172771291, + "y": 6071 + }, + { + "x": 1568172794092, + "y": 15681 + }, + { + "x": 1568172816893, + "y": null + }, + { + "x": 1568172839694, + "y": 1669 + }, + { + "x": 1568172862495, + "y": 956 + }, + { + "x": 1568172885296, + "y": 1435 + }, + { + "x": 1568172908097, + "y": null + }, + { + "x": 1568172930898, + "y": 32906 + }, + { + "x": 1568172953699, + "y": 892 + }, + { + "x": 1568172976500, + "y": 1514 + }, + { + "x": 1568172999301, + "y": null + }, + { + "x": 1568173022102, + "y": 2367 + }, + { + "x": 1568173044903, + "y": 3389 + }, + { + "x": 1568173067704, + "y": 362 + }, + { + "x": 1568173090505, + "y": null + }, + { + "x": 1568173113306, + "y": 3066 + }, + { + "x": 1568173136107, + "y": 44513 + }, + { + "x": 1568173158908, + "y": 6417 + }, + { + "x": 1568173181709, + "y": 1416 + }, + { + "x": 1568173204510, + "y": null + }, + { + "x": 1568173227311, + "y": 24627 + } + ] + } + ], + "status": [ + { + "x": 1568172657286, + "up": null, + "down": null, + "total": 1 + }, + { + "x": 1568172680087, + "up": null, + "down": null, + "total": 1 + }, + { + "x": 1568172702888, + "up": null, + "down": null, + "total": 1 + }, + { + "x": 1568172725689, + "up": null, + "down": null, + "total": 0 + }, + { + "x": 1568172748490, + "up": null, + "down": null, + "total": 1 + }, + { + "x": 1568172771291, + "up": null, + "down": null, + "total": 1 + }, + { + "x": 1568172794092, + "up": null, + "down": null, + "total": 1 + }, + { + "x": 1568172816893, + "up": null, + "down": null, + "total": 0 + }, + { + "x": 1568172839694, + "up": null, + "down": null, + "total": 1 + }, + { + "x": 1568172862495, + "up": null, + "down": null, + "total": 1 + }, + { + "x": 1568172885296, + "up": null, + "down": null, + "total": 1 + }, + { + "x": 1568172908097, + "up": null, + "down": null, + "total": 0 + }, + { + "x": 1568172930898, + "up": null, + "down": null, + "total": 1 + }, + { + "x": 1568172953699, + "up": null, + "down": null, + "total": 1 + }, + { + "x": 1568172976500, + "up": null, + "down": null, + "total": 1 + }, + { + "x": 1568172999301, + "up": null, + "down": null, + "total": 0 + }, + { + "x": 1568173022102, + "up": null, + "down": null, + "total": 1 + }, + { + "x": 1568173044903, + "up": null, + "down": null, + "total": 1 + }, + { + "x": 1568173067704, + "up": null, + "down": null, + "total": 1 + }, + { + "x": 1568173090505, + "up": null, + "down": null, + "total": 0 + }, + { + "x": 1568173113306, + "up": null, + "down": null, + "total": 1 + }, + { + "x": 1568173136107, + "up": null, + "down": null, + "total": 1 + }, + { + "x": 1568173158908, + "up": null, + "down": null, + "total": 1 + }, + { + "x": 1568173181709, + "up": null, + "down": null, + "total": 1 + }, + { + "x": 1568173204510, + "up": null, + "down": null, + "total": 0 + }, + { + "x": 1568173227311, + "up": null, + "down": null, + "total": 1 + } + ], + "statusMaxCount": 0, + "durationMaxValue": 0 +} diff --git a/x-pack/test/api_integration/apis/uptime/rest/fixtures/monitor_charts_empty_sets.json b/x-pack/test/api_integration/apis/uptime/rest/fixtures/monitor_charts_empty_sets.json new file mode 100644 index 0000000000000..e7245a479a962 --- /dev/null +++ b/x-pack/test/api_integration/apis/uptime/rest/fixtures/monitor_charts_empty_sets.json @@ -0,0 +1,6 @@ +{ + "locationDurationLines": [], + "status": [], + "statusMaxCount": 0, + "durationMaxValue": 0 +} diff --git a/x-pack/test/api_integration/apis/uptime/rest/index.ts b/x-pack/test/api_integration/apis/uptime/rest/index.ts index 30c301c5ecb17..5e26cb9216f45 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/index.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/index.ts @@ -20,6 +20,7 @@ export default function({ getService, loadTestFile }: FtrProviderContext) { loadTestFile(require.resolve('./monitor_latest_status')); loadTestFile(require.resolve('./selected_monitor')); loadTestFile(require.resolve('./ping_histogram')); + loadTestFile(require.resolve('./monitor_duration')); }); }); } diff --git a/x-pack/test/api_integration/apis/uptime/rest/monitor_duration.ts b/x-pack/test/api_integration/apis/uptime/rest/monitor_duration.ts new file mode 100644 index 0000000000000..acc50e9b8f3d6 --- /dev/null +++ b/x-pack/test/api_integration/apis/uptime/rest/monitor_duration.ts @@ -0,0 +1,41 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { expectFixtureEql } from '../graphql/helpers/expect_fixture_eql'; +import { FtrProviderContext } from '../../../ftr_provider_context'; + +export default function({ getService }: FtrProviderContext) { + describe('monitor duration query', () => { + const supertest = getService('supertest'); + + it('will fetch a series of data points for monitor duration and status', async () => { + const dateStart = '2019-09-11T03:31:04.380Z'; + const dateEnd = '2019-09-11T03:40:34.410Z'; + + const monitorId = '0002-up'; + + const apiResponse = await supertest.get( + `/api/uptime/monitor/duration?monitorId=${monitorId}&dateStart=${dateStart}&dateEnd=${dateEnd}` + ); + const data = apiResponse.body; + expectFixtureEql(data, 'monitor_charts'); + }); + + it('will fetch empty sets for a date range with no data', async () => { + const dateStart = '1999-09-11T03:31:04.380Z'; + const dateEnd = '1999-09-11T03:40:34.410Z'; + + const monitorId = '0002-up'; + + const apiResponse = await supertest.get( + `/api/uptime/monitor/duration?monitorId=${monitorId}&dateStart=${dateStart}&dateEnd=${dateEnd}` + ); + const data = apiResponse.body; + + expectFixtureEql(data, 'monitor_charts_empty_sets'); + }); + }); +}