From e2b7aea899b56bd6c69dadf06f1a17ca8a11a65c Mon Sep 17 00:00:00 2001 From: LeeDr Date: Tue, 30 Aug 2016 10:28:14 -0500 Subject: [PATCH 1/6] Work-around #7496 and/or #7055 by re-setting default index pattern --- test/support/page_objects/common.js | 23 +++++++++++++++++++---- test/support/utils/es_client.js | 29 ++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/test/support/page_objects/common.js b/test/support/page_objects/common.js index 661ff8f865d35..bb32358ee3a9e 100644 --- a/test/support/page_objects/common.js +++ b/test/support/page_objects/common.js @@ -15,17 +15,19 @@ import { import util from 'util'; import getUrl from '../../utils/get_url'; + import { config, defaultTryTimeout, defaultFindTimeout, remote, - shieldPage + shieldPage, + esClient } from '../index'; import { Log, - Try, + Try } from '../utils'; const mkdirpAsync = promisify(mkdirp); @@ -83,8 +85,21 @@ export default class Common { function navigateTo(url) { return self.try(function () { // since we're using hash URLs, always reload first to force re-render - self.debug('navigate to: ' + url); - return self.remote.get(url) + return esClient.getDefaultIndex() + .then(function (defaultIndex) { + if (appName === 'discover' || appName === 'visualize' || appName === 'dashboard') { + if (!defaultIndex) { + // https://github.com/elastic/kibana/issues/7496 + // Even though most tests are using esClient to set the default index, sometimes Kibana clobbers + // that change. If we got here, fix it. + self.debug(' >>>>>>>> WARNING Navigating to [' + appName + '] with defaultIndex=' + defaultIndex); + self.debug(' >>>>>>>> Setting defaultIndex to "logstash-*""'); + esClient.updateConfigDoc({'dateFormat:tz':'UTC', 'defaultIndex':'logstash-*'}); + } + } + self.debug('navigate to: ' + url); + return self.remote.get(url); + }) .then(function () { return self.sleep(700); }) diff --git a/test/support/utils/es_client.js b/test/support/utils/es_client.js index 10a85f9fcec39..1edbaefe0a27d 100644 --- a/test/support/utils/es_client.js +++ b/test/support/utils/es_client.js @@ -68,12 +68,39 @@ export default (function () { ); } else { configId = response.hits.hits[0]._id; - Log.debug('config._id =' + configId); + Log.debug('config._id = ' + configId); return configId; } }); }, + /* + ** Gets defaultIndex from the config doc. + */ + getDefaultIndex: function () { + var defaultIndex; + + return this.client.search({ + index: '.kibana', + type: 'config' + }) + .then(function (response) { + if (response.errors) { + throw new Error( + 'get config failed\n' + + response.items + .map(i => i[Object.keys(i)[0]].error) + .filter(Boolean) + .map(err => ' ' + JSON.stringify(err)) + .join('\n') + ); + } else { + defaultIndex = response.hits.hits[0]._source.defaultIndex; + Log.debug('config.defaultIndex = ' + defaultIndex); + return defaultIndex; + } + }); + }, /** * Add fields to the config doc (like setting timezone and defaultIndex) From 6c668d7ae1da167862d563e5789480f59f647dd8 Mon Sep 17 00:00:00 2001 From: LeeDr Date: Tue, 30 Aug 2016 11:29:37 -0500 Subject: [PATCH 2/6] return promise from updateConfigDoc --- test/support/page_objects/common.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/support/page_objects/common.js b/test/support/page_objects/common.js index bb32358ee3a9e..0bcf19bcca102 100644 --- a/test/support/page_objects/common.js +++ b/test/support/page_objects/common.js @@ -94,9 +94,11 @@ export default class Common { // that change. If we got here, fix it. self.debug(' >>>>>>>> WARNING Navigating to [' + appName + '] with defaultIndex=' + defaultIndex); self.debug(' >>>>>>>> Setting defaultIndex to "logstash-*""'); - esClient.updateConfigDoc({'dateFormat:tz':'UTC', 'defaultIndex':'logstash-*'}); + return esClient.updateConfigDoc({'dateFormat:tz':'UTC', 'defaultIndex':'logstash-*'}); } } + }) + .then(function () { self.debug('navigate to: ' + url); return self.remote.get(url); }) From a1fb3239f1636045701c4425457586d28597a53e Mon Sep 17 00:00:00 2001 From: spalger Date: Mon, 29 Aug 2016 18:46:39 -0700 Subject: [PATCH 3/6] remove config.set() call to avoid race Several tests have been failing recently with "Error: Unexpected request: POST /api/kibana/settings/shortDots:enable, No more request expected" which seems to be caused by the field chooser tests calling `config.set('shortDots:enable', origValue)` in the test cleanup task. Rather than investigate it further I avoided the need to call `config.set()` by stubbing the `config.get()` method. --- .../__tests__/directives/field_chooser.js | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/core_plugins/kibana/public/discover/__tests__/directives/field_chooser.js b/src/core_plugins/kibana/public/discover/__tests__/directives/field_chooser.js index 8f555b96b90d2..bbe845cf9a338 100644 --- a/src/core_plugins/kibana/public/discover/__tests__/directives/field_chooser.js +++ b/src/core_plugins/kibana/public/discover/__tests__/directives/field_chooser.js @@ -13,18 +13,13 @@ import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logsta let $parentScope; let $scope; -let config; let hits; let indexPattern; let indexPatternList; -let shortDotsValue; // Sets up the directive, take an element, and a list of properties to attach to the parent scope. const init = function ($elem, props) { - ngMock.inject(function ($rootScope, $compile, $timeout, _config_) { - shortDotsValue = _config_.get('shortDots:enable'); - config = _config_; - config.set('shortDots:enable', false); + ngMock.inject(function ($rootScope, $compile, $timeout) { $parentScope = $rootScope; _.assign($parentScope, props); $compile($elem)($parentScope); @@ -39,7 +34,6 @@ const init = function ($elem, props) { const destroy = function () { $scope.$destroy(); $parentScope.$destroy(); - config.set('shortDots:enable', shortDotsValue); }; describe('discover field chooser directives', function () { @@ -56,7 +50,21 @@ describe('discover field chooser directives', function () { '' ); - beforeEach(ngMock.module('kibana')); + beforeEach(ngMock.module('kibana', ($provide) => { + $provide.decorator('config', ($delegate) => { + // disable shortDots for these tests + $delegate.get = _.wrap($delegate.get, function (origGet, name) { + if (name === 'shortDots:enable') { + return false; + } else { + return origGet.call(this, name); + } + }); + + return $delegate; + }); + })); + beforeEach(ngMock.inject(function (Private) { hits = Private(FixturesHitsProvider); indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); From 4bc86f4327c8951a68857b5b021b02d98ad8cfda Mon Sep 17 00:00:00 2001 From: LeeDr Date: Tue, 30 Aug 2016 14:19:15 -0500 Subject: [PATCH 4/6] Changed required field data pane width and increased window width for changes in side bar. --- .../apps/discover/_collapse_expand.js | 4 +-- test/functional/apps/visualize/_tile_map.js | 2 +- test/functional/apps/visualize/index.js | 2 +- test/support/page_objects/discover_page.js | 25 +++++++++++++++---- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/test/functional/apps/discover/_collapse_expand.js b/test/functional/apps/discover/_collapse_expand.js index 1f44f0bd10845..3eaf45e83144b 100644 --- a/test/functional/apps/discover/_collapse_expand.js +++ b/test/functional/apps/discover/_collapse_expand.js @@ -41,7 +41,7 @@ bdd.describe('discover tab', function describeIndexTests() { return PageObjects.discover.getSidebarWidth() .then(function (width) { PageObjects.common.debug('expanded sidebar width = ' + width); - expect(width > 180).to.be(true); + expect(width > 20).to.be(true); }); }); @@ -66,7 +66,7 @@ bdd.describe('discover tab', function describeIndexTests() { }) .then(function (width) { PageObjects.common.debug('expanded sidebar width = ' + width); - expect(width > 180).to.be(true); + expect(width > 20).to.be(true); }); }); }); diff --git a/test/functional/apps/visualize/_tile_map.js b/test/functional/apps/visualize/_tile_map.js index 6381ec32a393a..901b161b39804 100644 --- a/test/functional/apps/visualize/_tile_map.js +++ b/test/functional/apps/visualize/_tile_map.js @@ -142,7 +142,7 @@ bdd.describe('visualize app', function describeIndexTests() { }); }); - bdd.it('"Fit data bounds" should zoom to level 3', function pageHeader() { + bdd.it('Fit data bounds should zoom to level 3', function pageHeader() { var expectedPrecision2ZoomCircles = [ { color: '#750000', radius: 192 }, { color: '#750000', radius: 191 }, { color: '#750000', radius: 177 }, diff --git a/test/functional/apps/visualize/index.js b/test/functional/apps/visualize/index.js index 9ae80a96a4235..e3dd74b79cec6 100644 --- a/test/functional/apps/visualize/index.js +++ b/test/functional/apps/visualize/index.js @@ -17,7 +17,7 @@ bdd.describe('visualize app', function () { bdd.before(function () { var self = this; - remote.setWindowSize(1200,800); + remote.setWindowSize(1280,800); PageObjects.common.debug('Starting visualize before method'); var logstash = scenarioManager.loadIfEmpty('logstashFunctional'); diff --git a/test/support/page_objects/discover_page.js b/test/support/page_objects/discover_page.js index 0ffe20ed99257..d7952f7622ab5 100644 --- a/test/support/page_objects/discover_page.js +++ b/test/support/page_objects/discover_page.js @@ -51,6 +51,9 @@ export default class DiscoverPage { return this.clickLoadSavedSearchButton() .then(() => { this.findTimeout.findByLinkText(searchName).click(); + }) + .then(() => { + return PageObjects.header.getSpinnerDone(); }); } @@ -79,8 +82,11 @@ export default class DiscoverPage { } getBarChartData() { - return this.findTimeout - .findAllByCssSelector('rect[data-label="Count"]') + return PageObjects.header.getSpinnerDone() + .then(() => { + return this.findTimeout + .findAllByCssSelector('rect[data-label="Count"]'); + }) .then(function (chartData) { function getChartData(chart) { @@ -128,13 +134,19 @@ export default class DiscoverPage { return this.findTimeout .findByCssSelector('option[label="' + interval + '"]') .click(); + }) + .then(() => { + return PageObjects.header.getSpinnerDone(); }); } getHitCount() { - return this.findTimeout - .findByCssSelector('strong.discover-info-hits') - .getVisibleText(); + return PageObjects.header.getSpinnerDone() + .then(() => { + return this.findTimeout + .findByCssSelector('strong.discover-info-hits') + .getVisibleText(); + }); } query(queryString) { @@ -146,6 +158,9 @@ export default class DiscoverPage { return this.findTimeout .findByCssSelector('button[aria-label="Search"]') .click(); + }) + .then(() => { + return PageObjects.header.getSpinnerDone(); }); } From 4cad85613601af11532966183b921460be9bb5ce Mon Sep 17 00:00:00 2001 From: LeeDr Date: Tue, 30 Aug 2016 10:28:14 -0500 Subject: [PATCH 5/6] Work-around #7496 and/or #7055 by re-setting default index pattern --- test/support/page_objects/common.js | 23 +++++++++++++++++++---- test/support/utils/es_client.js | 29 ++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/test/support/page_objects/common.js b/test/support/page_objects/common.js index 661ff8f865d35..bb32358ee3a9e 100644 --- a/test/support/page_objects/common.js +++ b/test/support/page_objects/common.js @@ -15,17 +15,19 @@ import { import util from 'util'; import getUrl from '../../utils/get_url'; + import { config, defaultTryTimeout, defaultFindTimeout, remote, - shieldPage + shieldPage, + esClient } from '../index'; import { Log, - Try, + Try } from '../utils'; const mkdirpAsync = promisify(mkdirp); @@ -83,8 +85,21 @@ export default class Common { function navigateTo(url) { return self.try(function () { // since we're using hash URLs, always reload first to force re-render - self.debug('navigate to: ' + url); - return self.remote.get(url) + return esClient.getDefaultIndex() + .then(function (defaultIndex) { + if (appName === 'discover' || appName === 'visualize' || appName === 'dashboard') { + if (!defaultIndex) { + // https://github.com/elastic/kibana/issues/7496 + // Even though most tests are using esClient to set the default index, sometimes Kibana clobbers + // that change. If we got here, fix it. + self.debug(' >>>>>>>> WARNING Navigating to [' + appName + '] with defaultIndex=' + defaultIndex); + self.debug(' >>>>>>>> Setting defaultIndex to "logstash-*""'); + esClient.updateConfigDoc({'dateFormat:tz':'UTC', 'defaultIndex':'logstash-*'}); + } + } + self.debug('navigate to: ' + url); + return self.remote.get(url); + }) .then(function () { return self.sleep(700); }) diff --git a/test/support/utils/es_client.js b/test/support/utils/es_client.js index 10a85f9fcec39..1edbaefe0a27d 100644 --- a/test/support/utils/es_client.js +++ b/test/support/utils/es_client.js @@ -68,12 +68,39 @@ export default (function () { ); } else { configId = response.hits.hits[0]._id; - Log.debug('config._id =' + configId); + Log.debug('config._id = ' + configId); return configId; } }); }, + /* + ** Gets defaultIndex from the config doc. + */ + getDefaultIndex: function () { + var defaultIndex; + + return this.client.search({ + index: '.kibana', + type: 'config' + }) + .then(function (response) { + if (response.errors) { + throw new Error( + 'get config failed\n' + + response.items + .map(i => i[Object.keys(i)[0]].error) + .filter(Boolean) + .map(err => ' ' + JSON.stringify(err)) + .join('\n') + ); + } else { + defaultIndex = response.hits.hits[0]._source.defaultIndex; + Log.debug('config.defaultIndex = ' + defaultIndex); + return defaultIndex; + } + }); + }, /** * Add fields to the config doc (like setting timezone and defaultIndex) From a66fc9d52dfab342869f907208597c878741ff8e Mon Sep 17 00:00:00 2001 From: LeeDr Date: Tue, 30 Aug 2016 11:29:37 -0500 Subject: [PATCH 6/6] return promise from updateConfigDoc --- test/support/page_objects/common.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/support/page_objects/common.js b/test/support/page_objects/common.js index bb32358ee3a9e..0bcf19bcca102 100644 --- a/test/support/page_objects/common.js +++ b/test/support/page_objects/common.js @@ -94,9 +94,11 @@ export default class Common { // that change. If we got here, fix it. self.debug(' >>>>>>>> WARNING Navigating to [' + appName + '] with defaultIndex=' + defaultIndex); self.debug(' >>>>>>>> Setting defaultIndex to "logstash-*""'); - esClient.updateConfigDoc({'dateFormat:tz':'UTC', 'defaultIndex':'logstash-*'}); + return esClient.updateConfigDoc({'dateFormat:tz':'UTC', 'defaultIndex':'logstash-*'}); } } + }) + .then(function () { self.debug('navigate to: ' + url); return self.remote.get(url); })