Mgmt saved object test (#22564) (#22744)

merging into 6.x
This commit is contained in:
Rashmi Kulkarni 2018-09-05 16:25:17 -07:00 committed by GitHub
parent df9f5ee204
commit 4766de8e19
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 388 additions and 18 deletions

View file

@ -324,6 +324,7 @@ export class Flyout extends Component {
const options = this.state.indexPatterns.map(indexPattern => ({
text: indexPattern.get('title'),
value: indexPattern.id,
['data-test-subj']: `indexPatternOption-${indexPattern.get('title')}`,
}));
options.unshift({
@ -333,7 +334,7 @@ export class Flyout extends Component {
return (
<EuiSelect
data-test-subj="managementChangeIndexSelection"
data-test-subj={`managementChangeIndexSelection-${id}`}
onChange={e => this.onIndexChanged(id, e)}
options={options}
/>

View file

@ -53,7 +53,7 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.settings.clickKibanaSavedObjects();
await PageObjects.settings.importFile(path.join(__dirname, 'exports', '_import_objects-conflicts.json'));
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.settings.setImportIndexFieldOption(2);
await PageObjects.settings.associateIndexPattern('d1e4c910-a2e6-11e7-bb30-233be9be6a15', 'logstash-*');
await PageObjects.settings.clickConfirmChanges();
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.settings.clickImportDone();
@ -71,7 +71,7 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.settings.importFile(path.join(__dirname, 'exports', '_import_objects_exists.json'), false);
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.settings.setImportIndexFieldOption(2);
await PageObjects.settings.associateIndexPattern('logstash-*', 'logstash-*');
await PageObjects.settings.clickConfirmChanges();
// Override the visualization.
@ -89,7 +89,7 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.settings.importFile(path.join(__dirname, 'exports', '_import_objects_exists.json'), false);
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.settings.setImportIndexFieldOption(2);
await PageObjects.settings.associateIndexPattern('logstash-*', 'logstash-*');
await PageObjects.settings.clickConfirmChanges();
// *Don't* override the visualization.

View file

@ -0,0 +1,59 @@
/*
* 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.
*/
import expect from 'expect.js';
import path from 'path';
export default function ({ getService, getPageObjects }) {
const esArchiver = getService('esArchiver');
const PageObjects = getPageObjects(['common', 'settings', 'header']);
//in 6.4.0 bug the Saved Search conflict would be resolved and get imported but the visualization
//that referenced the saved search was not imported.( https://github.com/elastic/kibana/issues/22238)
describe('mgmt saved objects', function describeIndexTests() {
beforeEach(async function () {
await esArchiver.load('discover');
await PageObjects.settings.navigateTo();
});
afterEach(async function () {
await esArchiver.unload('discover');
});
it('should import saved objects mgmt', async function () {
await PageObjects.settings.clickKibanaSavedObjects();
await PageObjects.settings.importFile(path.join(__dirname, 'exports', 'mgmt_import_objects.json'));
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.settings.associateIndexPattern('4c3f3c30-ac94-11e8-a651-614b2788174a', 'logstash-*');
await PageObjects.settings.clickConfirmChanges();
await PageObjects.settings.clickImportDone();
await PageObjects.settings.waitUntilSavedObjectsTableIsNotLoading();
//instead of asserting on count- am asserting on the titles- which is more accurate than count.
const objects = await PageObjects.settings.getSavedObjectsInTable();
expect(objects.includes('mysavedsearch')).to.be(true);
expect(objects.includes('mysavedviz')).to.be(true);
});
});
}

View file

@ -0,0 +1,37 @@
[
{
"_id": "6aea5700-ac94-11e8-a651-614b2788174a",
"_type": "search",
"_source": {
"title": "mysavedsearch",
"description": "",
"hits": 0,
"columns": [
"_source"
],
"sort": [
"@timestamp",
"desc"
],
"version": 1,
"kibanaSavedObjectMeta": {
"searchSourceJSON": "{\"index\":\"4c3f3c30-ac94-11e8-a651-614b2788174a\",\"highlightAll\":true,\"version\":true,\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[]}"
}
}
},
{
"_id": "8411daa0-ac94-11e8-a651-614b2788174a",
"_type": "visualization",
"_source": {
"title": "mysavedviz",
"visState": "{\"title\":\"mysavedviz\",\"type\":\"pie\",\"params\":{\"type\":\"pie\",\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"isDonut\":true,\"labels\":{\"show\":false,\"values\":true,\"last_level\":true,\"truncate\":100}},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}}]}",
"uiStateJSON": "{}",
"description": "",
"savedSearchId": "6aea5700-ac94-11e8-a651-614b2788174a",
"version": 1,
"kibanaSavedObjectMeta": {
"searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"lucene\"},\"filter\":[]}"
}
}
}
]

View file

@ -44,6 +44,7 @@ export default function ({ getService, loadTestFile }) {
loadTestFile(require.resolve('./_index_pattern_filter'));
loadTestFile(require.resolve('./_scripted_fields_filter'));
loadTestFile(require.resolve('./_import_objects'));
loadTestFile(require.resolve('./_mgmt_import_saved_objects'));
loadTestFile(require.resolve('./_test_huge_fields'));
loadTestFile(require.resolve('./_handle_alias'));
loadTestFile(require.resolve('./_handle_version_conflict'));

Binary file not shown.

View file

@ -0,0 +1,283 @@
{
"type": "index",
"value": {
"index": ".kibana",
"settings": {
"index": {
"number_of_shards": "1",
"auto_expand_replicas": "0-1",
"number_of_replicas": "0"
}
},
"mappings": {
"doc": {
"dynamic": "strict",
"properties": {
"config": {
"dynamic": "true",
"properties": {
"buildNum": {
"type": "keyword"
},
"defaultIndex": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"dashboard": {
"properties": {
"description": {
"type": "text"
},
"hits": {
"type": "integer"
},
"kibanaSavedObjectMeta": {
"properties": {
"searchSourceJSON": {
"type": "text"
}
}
},
"optionsJSON": {
"type": "text"
},
"panelsJSON": {
"type": "text"
},
"refreshInterval": {
"properties": {
"display": {
"type": "keyword"
},
"pause": {
"type": "boolean"
},
"section": {
"type": "integer"
},
"value": {
"type": "integer"
}
}
},
"timeFrom": {
"type": "keyword"
},
"timeRestore": {
"type": "boolean"
},
"timeTo": {
"type": "keyword"
},
"title": {
"type": "text"
},
"uiStateJSON": {
"type": "text"
},
"version": {
"type": "integer"
}
}
},
"graph-workspace": {
"properties": {
"description": {
"type": "text"
},
"kibanaSavedObjectMeta": {
"properties": {
"searchSourceJSON": {
"type": "text"
}
}
},
"numLinks": {
"type": "integer"
},
"numVertices": {
"type": "integer"
},
"title": {
"type": "text"
},
"version": {
"type": "integer"
},
"wsState": {
"type": "text"
}
}
},
"index-pattern": {
"properties": {
"fieldFormatMap": {
"type": "text"
},
"fields": {
"type": "text"
},
"intervalName": {
"type": "keyword"
},
"notExpandable": {
"type": "boolean"
},
"sourceFilters": {
"type": "text"
},
"timeFieldName": {
"type": "keyword"
},
"title": {
"type": "text"
}
}
},
"search": {
"properties": {
"columns": {
"type": "keyword"
},
"description": {
"type": "text"
},
"hits": {
"type": "integer"
},
"kibanaSavedObjectMeta": {
"properties": {
"searchSourceJSON": {
"type": "text"
}
}
},
"sort": {
"type": "keyword"
},
"title": {
"type": "text"
},
"version": {
"type": "integer"
}
}
},
"server": {
"properties": {
"uuid": {
"type": "keyword"
}
}
},
"timelion-sheet": {
"properties": {
"description": {
"type": "text"
},
"hits": {
"type": "integer"
},
"kibanaSavedObjectMeta": {
"properties": {
"searchSourceJSON": {
"type": "text"
}
}
},
"timelion_chart_height": {
"type": "integer"
},
"timelion_columns": {
"type": "integer"
},
"timelion_interval": {
"type": "keyword"
},
"timelion_other_interval": {
"type": "keyword"
},
"timelion_rows": {
"type": "integer"
},
"timelion_sheet": {
"type": "text"
},
"title": {
"type": "text"
},
"version": {
"type": "integer"
}
}
},
"type": {
"type": "keyword"
},
"updated_at": {
"type": "date"
},
"url": {
"properties": {
"accessCount": {
"type": "long"
},
"accessDate": {
"type": "date"
},
"createDate": {
"type": "date"
},
"url": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 2048
}
}
}
}
},
"visualization": {
"properties": {
"description": {
"type": "text"
},
"kibanaSavedObjectMeta": {
"properties": {
"searchSourceJSON": {
"type": "text"
}
}
},
"savedSearchId": {
"type": "keyword"
},
"title": {
"type": "text"
},
"uiStateJSON": {
"type": "text"
},
"version": {
"type": "integer"
},
"visState": {
"type": "text"
}
}
}
}
}
},
"aliases": {}
}
}

View file

@ -570,9 +570,10 @@ export function SettingsPageProvider({ getService, getPageObjects }) {
await testSubjects.click('importSavedObjectsConfirmBtn');
}
async setImportIndexFieldOption(child) {
async associateIndexPattern(oldIndexPatternId, newIndexPatternTitle) {
await find.clickByCssSelector(
`select[data-test-subj="managementChangeIndexSelection"] > option:nth-child(${child})`
`select[data-test-subj="managementChangeIndexSelection-${oldIndexPatternId}"] >
[data-test-subj="indexPatternOption-${newIndexPatternTitle}"]`
);
}
@ -580,18 +581,6 @@ export function SettingsPageProvider({ getService, getPageObjects }) {
await testSubjects.click('changeIndexConfirmButton');
}
async clickVisualizationsTab() {
await testSubjects.click('objectsTab-visualizations');
}
async clickSearchesTab() {
await testSubjects.click('objectsTab-searches');
}
async getVisualizationRows() {
return await testSubjects.findAll(`objectsTableRow`);
}
async waitUntilSavedObjectsTableIsNotLoading() {
return retry.try(async () => {
const exists = await find.existsByDisplayedByCssSelector(