From af3ea4d2119b4e522956f511a8daafa5bce9c8c2 Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Wed, 20 Jan 2021 13:37:37 +0100 Subject: [PATCH] add test to switch layer from regular index to rollup index (#88651) --- x-pack/test/functional/apps/lens/rollup.ts | 23 +++++++++++++++++- .../es_archives/lens/rollup/config/data.json | 24 ++++++++++++++++++- .../es_archives/lens/rollup/data/data.json | 12 ++++++++++ .../lens/rollup/data/mappings.json | 23 ++++++++++++++++++ 4 files changed, 80 insertions(+), 2 deletions(-) diff --git a/x-pack/test/functional/apps/lens/rollup.ts b/x-pack/test/functional/apps/lens/rollup.ts index f6882c8aed214..43be284a36228 100644 --- a/x-pack/test/functional/apps/lens/rollup.ts +++ b/x-pack/test/functional/apps/lens/rollup.ts @@ -8,7 +8,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['visualize', 'lens']); + const PageObjects = getPageObjects(['visualize', 'lens', 'header']); const find = getService('find'); const listingTable = getService('listingTable'); const esArchiver = getService('esArchiver'); @@ -71,5 +71,26 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(await PageObjects.lens.getDatatableHeaderText()).to.eql('Sum of bytes'); expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('16,788'); }); + + it('should allow to switch from regular index to rollup index retaining config', async () => { + await PageObjects.visualize.navigateToNewVisualization(); + await PageObjects.visualize.clickVisType('lens'); + await PageObjects.lens.goToTimeRange(); + await PageObjects.lens.switchDataPanelIndexPattern('lens_regular_data'); + await PageObjects.lens.switchToVisualization('lnsMetric'); + await PageObjects.lens.configureDimension({ + dimension: 'lns-empty-dimension', + operation: 'sum', + field: 'bytes', + }); + await PageObjects.header.waitUntilLoadingHasFinished(); + + await PageObjects.lens.assertMetric('Sum of bytes', '16,788'); + + await PageObjects.lens.switchFirstLayerIndexPattern('lens_rolled_up_data'); + await PageObjects.header.waitUntilLoadingHasFinished(); + + await PageObjects.lens.assertMetric('Sum of bytes', '16,788'); + }); }); } diff --git a/x-pack/test/functional/es_archives/lens/rollup/config/data.json b/x-pack/test/functional/es_archives/lens/rollup/config/data.json index 11645d0d7c575..cd57f4f352a7d 100644 --- a/x-pack/test/functional/es_archives/lens/rollup/config/data.json +++ b/x-pack/test/functional/es_archives/lens/rollup/config/data.json @@ -44,6 +44,28 @@ } } +{ + "type": "doc", + "value": { + "id": "index-pattern:lens-regular-data", + "index": ".kibana_1", + "source": { + "index-pattern" : { + "title" : "lens_regular_data", + "timeFieldName" : "@timestamp", + "fields" : "[]" + }, + "type" : "index-pattern", + "references" : [ ], + "migrationVersion" : { + "index-pattern" : "7.6.0" + }, + "updated_at" : "2020-08-19T08:39:09.998Z" + }, + "type": "_doc" + } +} + { "type": "doc", "value": { @@ -54,7 +76,7 @@ "accessibility:disableAnimations": true, "buildNum": 9007199254740991, "dateFormat:tz": "UTC", - "defaultIndex": "logstash-*" + "defaultIndex": "lens-rolled-up-data" }, "references": [], "type": "config", diff --git a/x-pack/test/functional/es_archives/lens/rollup/data/data.json b/x-pack/test/functional/es_archives/lens/rollup/data/data.json index 36dc10c05f0b9..ae28392b2b758 100644 --- a/x-pack/test/functional/es_archives/lens/rollup/data/data.json +++ b/x-pack/test/functional/es_archives/lens/rollup/data/data.json @@ -56,4 +56,16 @@ "_rollup.id": "lens_rolled_up_data" } } +} + +{ + "type": "doc", + "value": { + "index": "lens_regular_data", + "id": "1", + "source": { + "@timestamp": "2015-09-20T02:00:00.000Z", + "bytes": 16788 + } + } } \ No newline at end of file diff --git a/x-pack/test/functional/es_archives/lens/rollup/data/mappings.json b/x-pack/test/functional/es_archives/lens/rollup/data/mappings.json index 0e47a632bbf3f..01b842ea031b7 100644 --- a/x-pack/test/functional/es_archives/lens/rollup/data/mappings.json +++ b/x-pack/test/functional/es_archives/lens/rollup/data/mappings.json @@ -1,3 +1,26 @@ +{ + "type": "index", + "value": { + "index": "lens_regular_data", + "mappings": { + "properties": { + "@timestamp": { + "type": "date" + }, + "bytes": { + "type": "float" + } + } + }, + "settings": { + "index": { + "number_of_shards": "1", + "number_of_replicas": "0" + } + } + } +} + { "type": "index", "value": {