Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functional test to surface index version conflicts #22509

Merged
merged 6 commits into from
Aug 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added option[value=url]
Empty file.
102 changes: 102 additions & 0 deletions test/functional/apps/management/_handle_version_conflict.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/


/* Steps for version conflict test
1. Create index pattern
2. Click on scripted field and fill in the values
3. Use es to update the index pattern's title
4. Try to save the scripted field
5. Kibana should display the message - you need to refresh the index pattern

*/

import expect from 'expect.js';

export default function ({ getService, getPageObjects }) {
const esArchiver = getService('esArchiver');
const remote = getService('remote');
const es = getService('es');
const retry = getService('retry');
const scriptedFiledName = 'versionConflictScript';
const PageObjects = getPageObjects(['common', 'home', 'settings', 'discover', 'header']);
const log = getService('log');


describe('index version conflict', function describeIndexTests() {
before(async function () {
await remote.setWindowSize(1200, 800);
await esArchiver.load('discover');
});


it('Should be able to surface version conflict notification while creating scripted field', async function () {
await PageObjects.settings.navigateTo();
await PageObjects.settings.clickKibanaIndices();
await PageObjects.settings.clickOnOnlyIndexPattern();
await PageObjects.settings.clickScriptedFieldsTab();
await PageObjects.settings.clickAddScriptedField();
await PageObjects.settings.setScriptedFieldName(scriptedFiledName);
await PageObjects.settings.setScriptedFieldScript(`doc['bytes'].value`);
const response = await es.update({
index: '.kibana',
type: 'doc',
id: 'index-pattern:logstash-*',
body: {
'doc': { 'index-pattern': { 'fieldFormatMap': '{"geo.src":{"id":"number"}}' } }
}
});
log.debug(JSON.stringify(response));
expect(response.result).to.be('updated');
await PageObjects.settings.setFieldFormat('url');
await PageObjects.settings.clickSaveScriptedField();
await retry.try(async function () {
const message = await PageObjects.common.closeToast();
expect(message).to.contain('Unable');
});
});

it('Should be able to surface version conflict notification while changing field format', async function () {
const fieldName = 'geo.srcdest';
await PageObjects.settings.navigateTo();
await PageObjects.settings.clickKibanaIndices();
await PageObjects.settings.clickOnOnlyIndexPattern();
log.debug('Starting openControlsByName (' + fieldName + ')');
await PageObjects.settings.openControlsByName(fieldName);
log.debug('controls are open');
await PageObjects.settings.setFieldFormat('url');
const response = await es.update({
index: '.kibana',
type: 'doc',
id: 'index-pattern:logstash-*',
body: {
'doc': { 'index-pattern': { 'fieldFormatMap': '{"geo.dest":{"id":"number"}}' } }
}
});
log.debug(JSON.stringify(response));
expect(response.result).to.be('updated');
await PageObjects.settings.controlChangeSave();
await retry.try(async function () {
//await PageObjects.common.sleep(2000);
const message = await PageObjects.common.closeToast();
expect(message).to.contain('Unable');
});
});
});
}
1 change: 1 addition & 0 deletions test/functional/apps/management/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default function ({ getService, loadTestFile }) {
loadTestFile(require.resolve('./_import_objects'));
loadTestFile(require.resolve('./_test_huge_fields'));
loadTestFile(require.resolve('./_handle_alias'));
loadTestFile(require.resolve('./_handle_version_conflict'));
});

}
3 changes: 3 additions & 0 deletions test/functional/page_objects/common_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,10 @@ export function CommonPageProvider({ getService, getPageObjects }) {
async closeToast() {
const toast = await find.byCssSelector('.euiToast');
await remote.moveMouseTo(toast);
const title = await (await find.byCssSelector('.euiToastHeader__title')).getVisibleText();
log.debug(title);
await find.clickByCssSelector('.euiToast__closeButton');
return title;
}

async clearAllToasts() {
Expand Down