From 15c57a8d0a447222cb3474b23e0ae0ef721337cf Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Mon, 3 Feb 2020 16:50:49 +0100 Subject: [PATCH 1/2] add test and fix warning text --- .../public/components/index_pattern.js | 2 + .../public/components/yes_no.js | 4 +- .../page_objects/visual_builder_page.ts | 13 +++ .../components/rollup_prompt/rollup_prompt.js | 2 +- .../test/functional/apps/rollup_job/index.js | 1 + .../test/functional/apps/rollup_job/tsvb.js | 102 ++++++++++++++++++ 6 files changed, 122 insertions(+), 2 deletions(-) create mode 100644 x-pack/test/functional/apps/rollup_job/tsvb.js diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/components/index_pattern.js b/src/legacy/core_plugins/vis_type_timeseries/public/components/index_pattern.js index de8469adfb8a7..f6530eb22332a 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/components/index_pattern.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/components/index_pattern.js @@ -206,6 +206,7 @@ export const IndexPattern = ({ fields, prefix, onChange, disabled, model: _model })} > { const { name } = props; return () => { @@ -38,6 +38,7 @@ export function YesNo(props) {
{ await comboBox.clearInputField('metricsIndexPatternFieldsSelect'); diff --git a/x-pack/legacy/plugins/rollup/public/index_pattern_creation/components/rollup_prompt/rollup_prompt.js b/x-pack/legacy/plugins/rollup/public/index_pattern_creation/components/rollup_prompt/rollup_prompt.js index 7a944c5e9a5c0..42c950f0b0d74 100644 --- a/x-pack/legacy/plugins/rollup/public/index_pattern_creation/components/rollup_prompt/rollup_prompt.js +++ b/x-pack/legacy/plugins/rollup/public/index_pattern_creation/components/rollup_prompt/rollup_prompt.js @@ -13,7 +13,7 @@ export const RollupPrompt = () => (

Kibana's support for rollup index patterns is in beta. You might encounter issues using these patterns in saved searches, visualizations, and dashboards. They are not supported in - advanced features, such as TSVB, Timelion, and Machine Learning. + some advanced features, such as Timelion, and Machine Learning.

You can match a rollup index pattern against one rollup index and zero or more regular diff --git a/x-pack/test/functional/apps/rollup_job/index.js b/x-pack/test/functional/apps/rollup_job/index.js index 146cc4e8dbdf0..055b239058eac 100644 --- a/x-pack/test/functional/apps/rollup_job/index.js +++ b/x-pack/test/functional/apps/rollup_job/index.js @@ -10,5 +10,6 @@ export default function({ loadTestFile }) { loadTestFile(require.resolve('./rollup_jobs')); loadTestFile(require.resolve('./hybrid_index_pattern')); + loadTestFile(require.resolve('./tsvb')); }); } diff --git a/x-pack/test/functional/apps/rollup_job/tsvb.js b/x-pack/test/functional/apps/rollup_job/tsvb.js new file mode 100644 index 0000000000000..1644a591cd06d --- /dev/null +++ b/x-pack/test/functional/apps/rollup_job/tsvb.js @@ -0,0 +1,102 @@ +/* + * 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 datemath from '@elastic/datemath'; +import expect from '@kbn/expect'; +import mockRolledUpData from './hybrid_index_helper'; + +export default function({ getService, getPageObjects }) { + const es = getService('legacyEs'); + const esArchiver = getService('esArchiver'); + const retry = getService('retry'); + const PageObjects = getPageObjects([ + 'common', + 'settings', + 'visualize', + 'visualBuilder', + 'timePicker', + ]); + + describe('tsvb integration', function() { + //Since rollups can only be created once with the same name (even if you delete it), + //we add the Date.now() to avoid name collision if you run the tests locally back to back. + const rollupJobName = `tsvb-test-rollup-job-${Date.now()}`; + const rollupSourceIndexName = 'rollup-source-data'; + const rollupTargetIndexName = `rollup-target-data`; + const now = new Date(); + const pastDates = [ + datemath.parse('now-1m', { forceNow: now }), + datemath.parse('now-2m', { forceNow: now }), + datemath.parse('now-3m', { forceNow: now }), + ]; + + before(async () => { + // load visualize to have an index pattern ready, otherwise visualize will redirect + await esArchiver.load('visualize/default'); + }); + + it('create rollup tsvb', async () => { + //Create data for rollup job so it doesn't fail + await es.index({ + index: rollupSourceIndexName, + body: { + '@timestamp': new Date().toISOString(), + }, + }); + + await retry.try(async () => { + //Create a rollup for kibana to recognize + await es.transport.request({ + path: `/_rollup/job/${rollupJobName}`, + method: 'PUT', + body: { + index_pattern: rollupSourceIndexName, + rollup_index: rollupTargetIndexName, + cron: '*/10 * * * * ?', + groups: { + date_histogram: { + fixed_interval: '1000ms', + field: '@timestamp', + time_zone: 'UTC', + }, + }, + timeout: '20s', + page_size: 1000, + }, + }); + }); + + await pastDates.map(async day => { + await es.index(mockRolledUpData(rollupJobName, rollupTargetIndexName, day)); + }); + + await PageObjects.visualize.navigateToNewVisualization(); + await PageObjects.visualize.clickVisualBuilder(); + await PageObjects.visualBuilder.checkVisualBuilderIsPresent(); + await PageObjects.timePicker.openQuickSelectTimeMenu(); + await PageObjects.visualBuilder.clickMetric(); + await PageObjects.visualBuilder.checkMetricTabIsPresent(); + await PageObjects.visualBuilder.clickPanelOptions('metric'); + await PageObjects.visualBuilder.setIndexPatternValue(rollupTargetIndexName); + await PageObjects.visualBuilder.setIntervalValue('1d'); + await PageObjects.visualBuilder.setDropLastBucket(false); + const newValue = await PageObjects.visualBuilder.getMetricValue(); + expect(newValue).to.eql('3'); + }); + + after(async () => { + // Delete the rollup job. + await es.transport.request({ + path: `/_rollup/job/${rollupJobName}`, + method: 'DELETE', + }); + + await es.indices.delete({ index: rollupTargetIndexName }); + await es.indices.delete({ index: rollupSourceIndexName }); + await esArchiver.load('empty_kibana'); + }); + }); +} From f80f8cf2d7f56a3bbaac26a49a582c6e22a9b159 Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Tue, 4 Feb 2020 11:55:11 +0100 Subject: [PATCH 2/2] stabilize functional test --- x-pack/test/functional/apps/rollup_job/tsvb.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/x-pack/test/functional/apps/rollup_job/tsvb.js b/x-pack/test/functional/apps/rollup_job/tsvb.js index 1644a591cd06d..f3782c4c91644 100644 --- a/x-pack/test/functional/apps/rollup_job/tsvb.js +++ b/x-pack/test/functional/apps/rollup_job/tsvb.js @@ -12,6 +12,7 @@ export default function({ getService, getPageObjects }) { const es = getService('legacyEs'); const esArchiver = getService('esArchiver'); const retry = getService('retry'); + const testSubjects = getService('testSubjects'); const PageObjects = getPageObjects([ 'common', 'settings', @@ -77,12 +78,14 @@ export default function({ getService, getPageObjects }) { await PageObjects.visualize.clickVisualBuilder(); await PageObjects.visualBuilder.checkVisualBuilderIsPresent(); await PageObjects.timePicker.openQuickSelectTimeMenu(); + await testSubjects.click('superDatePickerCommonlyUsed_Last_24 hours'); await PageObjects.visualBuilder.clickMetric(); await PageObjects.visualBuilder.checkMetricTabIsPresent(); await PageObjects.visualBuilder.clickPanelOptions('metric'); await PageObjects.visualBuilder.setIndexPatternValue(rollupTargetIndexName); await PageObjects.visualBuilder.setIntervalValue('1d'); await PageObjects.visualBuilder.setDropLastBucket(false); + await PageObjects.common.sleep(3000); const newValue = await PageObjects.visualBuilder.getMetricValue(); expect(newValue).to.eql('3'); });