Added CCS test for data view functionality. (#124586)

* Added CCS test for data view functionality.

* Changed how we are approaching the test. Just adding a remote to exercise the CCS functionality.

* Adjusted test to use correct port for remote cluster.

* Added and corrected config for the tests to be able to run.

* Changed test title.

* Added functional ccs suite to functional test runner script.

* Changed config.ts to config.js

* Moved es to before clause.

* Added await for an async call.

* Added await for an async call.

* Updated saved queries test to use CCS. One test is failing, all others are passing.

* Merge branch 'main' of github.com:elastic/kibana into CCS_Functional_Test_POC

* Fixed a reference.

* Removed the OSS tests since we created CCS versions of them.

* Removed tests from index file.

* Restored test files per comment with matthias.

* Did some cleanup of comments.

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
John Dorlus 2022-02-24 16:33:11 -05:00 committed by GitHub
parent c914e94841
commit 1e16db4d18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 431 additions and 0 deletions

View file

@ -9,6 +9,7 @@
require('../src/setup_node_env');
require('@kbn/test').runTestsCli([
require.resolve('../test/functional/config.js'),
require.resolve('../test/functional_ccs/config.js'),
require.resolve('../test/plugin_functional/config.ts'),
require.resolve('../test/ui_capabilities/newsfeed_err/config.ts'),
require.resolve('../test/new_visualize_flow/config.ts'),

View file

@ -0,0 +1,15 @@
{
"attributes": {
"fields": "[]",
"timeFieldName": "nested.timestamp",
"title": "remote:date-nested"
},
"coreMigrationVersion": "8.2.0",
"id": "remote:date-nested",
"migrationVersion": {
"index-pattern": "8.0.0"
},
"references": [],
"type": "index-pattern",
"version": "WzIyLDFd"
}

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,62 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { FtrProviderContext } from './ftr_provider_context';
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const retry = getService('retry');
const testSubjects = getService('testSubjects');
const kibanaServer = getService('kibanaServer');
const esArchiver = getService('esArchiver');
const security = getService('security');
const PageObjects = getPageObjects(['common', 'discover', 'header', 'timePicker']);
const createDataView = async (dataViewName: string) => {
await PageObjects.discover.clickIndexPatternActions();
await PageObjects.discover.clickCreateNewDataView();
await testSubjects.setValue('createIndexPatternNameInput', dataViewName, {
clearWithKeyboard: true,
typeCharByChar: true,
});
await testSubjects.click('saveIndexPatternButton');
};
describe('discover integration with data view editor', function describeIndexTests() {
before(async function () {
await security.testUser.setRoles(['kibana_admin', 'test_logstash_reader']);
await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional');
await kibanaServer.savedObjects.clean({ types: ['saved-search', 'index-pattern'] });
await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover');
await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings();
await PageObjects.common.navigateToApp('discover');
});
after(async () => {
await security.testUser.restoreDefaults();
await kibanaServer.importExport.unload('test/functional/fixtures/kbn_archiver/discover');
await kibanaServer.savedObjects.clean({ types: ['saved-search', 'index-pattern'] });
});
it('use ccs to create a new data view', async function () {
const dataViewToCreate = 'remote:logstash';
await createDataView(dataViewToCreate);
await PageObjects.header.waitUntilLoadingHasFinished();
await retry.waitForWithTimeout(
'data view selector to include a newly created dataview',
5000,
async () => {
const dataViewTitle = await PageObjects.discover.getCurrentlySelectedDataView();
// data view editor will add wildcard symbol by default
// so we need to include it in our original title when comparing
return dataViewTitle === `${dataViewToCreate}*`;
}
);
});
});
}

View file

@ -0,0 +1,221 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import expect from '@kbn/expect';
import { FtrProviderContext } from './ftr_provider_context';
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const retry = getService('retry');
const log = getService('log');
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const PageObjects = getPageObjects(['common', 'discover', 'timePicker']);
const browser = getService('browser');
const filterBar = getService('filterBar');
const queryBar = getService('queryBar');
const savedQueryManagementComponent = getService('savedQueryManagementComponent');
const testSubjects = getService('testSubjects');
const defaultSettings = {
defaultIndex: 'logstash-*',
};
const setUpQueriesWithFilters = async () => {
// set up a query with filters and a time filter
log.debug('set up a query with filters to save');
const from = 'Sep 20, 2015 @ 08:00:00.000';
const to = 'Sep 21, 2015 @ 08:00:00.000';
await PageObjects.common.setTime({ from, to });
await PageObjects.common.navigateToApp('discover');
await filterBar.addFilter('extension.raw', 'is one of', 'jpg');
await queryBar.setQuery('response:200');
};
describe('saved queries saved objects', function describeIndexTests() {
before(async function () {
log.debug('load kibana index with default index pattern');
await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] });
await kibanaServer.importExport.load(
'test/functional/fixtures/kbn_archiver/discover_ccs.json'
);
await kibanaServer.importExport.load(
'test/functional/fixtures/kbn_archiver/date_nested_ccs.json'
);
await esArchiver.load('test/functional/fixtures/es_archiver/date_nested');
await esArchiver.load('test/functional/fixtures/es_archiver/logstash_functional');
await kibanaServer.uiSettings.replace(defaultSettings);
log.debug('discover');
await PageObjects.common.navigateToApp('discover');
await PageObjects.timePicker.setDefaultAbsoluteRange();
});
after(async () => {
await kibanaServer.importExport.unload('test/functional/fixtures/kbn_archiver/discover_ccs');
await kibanaServer.importExport.unload(
'test/functional/fixtures/kbn_archiver/date_nested_ccs'
);
await esArchiver.unload('test/functional/fixtures/es_archiver/date_nested');
await esArchiver.unload('test/functional/fixtures/es_archiver/logstash_functional');
await PageObjects.common.unsetTime();
});
describe('saved query selection', () => {
before(async () => await setUpQueriesWithFilters());
it(`should unselect saved query when navigating to a 'new'`, async function () {
await savedQueryManagementComponent.saveNewQuery(
'test-unselect-saved-query',
'mock',
true,
true
);
await queryBar.submitQuery();
expect(await filterBar.hasFilter('extension.raw', 'jpg')).to.be(true);
expect(await queryBar.getQueryString()).to.eql('response:200');
await PageObjects.discover.clickNewSearchButton();
expect(await filterBar.hasFilter('extension.raw', 'jpg')).to.be(false);
expect(await queryBar.getQueryString()).to.eql('');
await PageObjects.discover.selectIndexPattern('remote:date-nested');
expect(await filterBar.hasFilter('extension.raw', 'jpg')).to.be(false);
expect(await queryBar.getQueryString()).to.eql('');
await PageObjects.discover.selectIndexPattern('remote:logstash-*');
expect(await filterBar.hasFilter('extension.raw', 'jpg')).to.be(false);
expect(await queryBar.getQueryString()).to.eql('');
// reset state
await savedQueryManagementComponent.deleteSavedQuery('test-unselect-saved-query');
});
});
describe('saved query management component functionality', function () {
before(async () => await setUpQueriesWithFilters());
it('should show the saved query management component when there are no saved queries', async () => {
await savedQueryManagementComponent.openSavedQueryManagementComponent();
const descriptionText = await testSubjects.getVisibleText('saved-query-management-popover');
expect(descriptionText).to.eql(
'Saved Queries\nThere are no saved queries. Save query text and filters that you want to use again.\nSave current query'
);
});
it('should allow a query to be saved via the saved objects management component', async () => {
await savedQueryManagementComponent.saveNewQuery(
'OkResponse',
'200 responses for .jpg over 24 hours',
true,
true
);
await savedQueryManagementComponent.savedQueryExistOrFail('OkResponse');
await savedQueryManagementComponent.savedQueryTextExist('response:200');
});
it('reinstates filters and the time filter when a saved query has filters and a time filter included', async () => {
await PageObjects.timePicker.setDefaultAbsoluteRange();
await savedQueryManagementComponent.clearCurrentlyLoadedQuery();
await savedQueryManagementComponent.loadSavedQuery('OkResponse');
const timePickerValues = await PageObjects.timePicker.getTimeConfigAsAbsoluteTimes();
expect(await filterBar.hasFilter('extension.raw', 'jpg')).to.be(true);
expect(timePickerValues.start).to.not.eql(PageObjects.timePicker.defaultStartTime);
expect(timePickerValues.end).to.not.eql(PageObjects.timePicker.defaultEndTime);
});
it('preserves the currently loaded query when the page is reloaded', async () => {
await browser.refresh();
const timePickerValues = await PageObjects.timePicker.getTimeConfigAsAbsoluteTimes();
expect(await filterBar.hasFilter('extension.raw', 'jpg')).to.be(true);
expect(timePickerValues.start).to.not.eql(PageObjects.timePicker.defaultStartTime);
expect(timePickerValues.end).to.not.eql(PageObjects.timePicker.defaultEndTime);
await retry.waitFor(
'the right hit count',
async () => (await PageObjects.discover.getHitCount()) === '2,792'
);
expect(await savedQueryManagementComponent.getCurrentlyLoadedQueryID()).to.be('OkResponse');
});
it('allows saving changes to a currently loaded query via the saved query management component', async () => {
await queryBar.setQuery('response:404');
await savedQueryManagementComponent.updateCurrentlyLoadedQuery('OkResponse', false, false);
await savedQueryManagementComponent.savedQueryExistOrFail('OkResponse');
await savedQueryManagementComponent.clearCurrentlyLoadedQuery();
expect(await queryBar.getQueryString()).to.eql('');
await savedQueryManagementComponent.loadSavedQuery('OkResponse');
expect(await queryBar.getQueryString()).to.eql('response:404');
});
it('allows saving the currently loaded query as a new query', async () => {
await savedQueryManagementComponent.saveCurrentlyLoadedAsNewQuery(
'OkResponseCopy',
'200 responses',
false,
false
);
await savedQueryManagementComponent.savedQueryExistOrFail('OkResponseCopy');
});
it('allows deleting the currently loaded saved query in the saved query management component and clears the query', async () => {
await savedQueryManagementComponent.deleteSavedQuery('OkResponseCopy');
await savedQueryManagementComponent.savedQueryMissingOrFail('OkResponseCopy');
expect(await queryBar.getQueryString()).to.eql('');
});
it('does not allow saving a query with a non-unique name', async () => {
// this check allows this test to run stand alone, also should fix occacional flakiness
const savedQueryExists = await savedQueryManagementComponent.savedQueryExist('OkResponse');
if (!savedQueryExists) {
await savedQueryManagementComponent.saveNewQuery(
'OkResponse',
'200 responses for .jpg over 24 hours',
true,
true
);
await savedQueryManagementComponent.clearCurrentlyLoadedQuery();
}
await savedQueryManagementComponent.saveNewQueryWithNameError('OkResponse');
});
it('resets any changes to a loaded query on reloading the same saved query', async () => {
await savedQueryManagementComponent.loadSavedQuery('OkResponse');
await queryBar.setQuery('response:503');
await savedQueryManagementComponent.loadSavedQuery('OkResponse');
expect(await queryBar.getQueryString()).to.eql('response:404');
});
it('allows clearing the currently loaded saved query', async () => {
await savedQueryManagementComponent.loadSavedQuery('OkResponse');
await savedQueryManagementComponent.clearCurrentlyLoadedQuery();
expect(await queryBar.getQueryString()).to.eql('');
});
it('allows clearing if non default language was remembered in localstorage', async () => {
await queryBar.switchQueryLanguage('lucene');
await PageObjects.common.navigateToApp('discover'); // makes sure discovered is reloaded without any state in url
await queryBar.expectQueryLanguageOrFail('lucene'); // make sure lucene is remembered after refresh (comes from localstorage)
await savedQueryManagementComponent.loadSavedQuery('OkResponse');
await queryBar.expectQueryLanguageOrFail('kql');
await savedQueryManagementComponent.clearCurrentlyLoadedQuery();
await queryBar.expectQueryLanguageOrFail('lucene');
});
it('changing language removes saved query', async () => {
await savedQueryManagementComponent.loadSavedQuery('OkResponse');
await queryBar.switchQueryLanguage('lucene');
expect(await queryBar.getQueryString()).to.eql('');
});
});
});
}

View file

@ -0,0 +1,13 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { GenericFtrProviderContext } from '@kbn/test';
import { services } from '../../../functional/services';
import { pageObjects } from '../../../functional/page_objects';
export type FtrProviderContext = GenericFtrProviderContext<typeof services, typeof pageObjects>;

View file

@ -0,0 +1,43 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { FtrProviderContext } from './ftr_provider_context';
export default function ({ getService, loadTestFile }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const browser = getService('browser');
const esClient = getService('es');
describe('discover app css', function () {
this.tags('ciGroup6');
before(async function () {
await esClient.cluster.putSettings({
persistent: {
cluster: {
remote: {
remote: {
skip_unavailable: 'true',
seeds: ['localhost:9300'],
},
},
},
},
});
return browser.setWindowSize(1300, 800);
});
after(function unloadMakelogs() {
// Make sure to clean up the cluster setting from the before above.
return esArchiver.unload('test/functional/fixtures/es_archiver/logstash_functional');
});
loadTestFile(require.resolve('./_data_view_ccs'));
loadTestFile(require.resolve('./_saved_queries_ccs'));
});
}

View file

@ -0,0 +1,25 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { services } from '../functional/services';
export default async function ({ readConfigFile }) {
const functionalConfig = await readConfigFile(require.resolve('../functional/config'));
return {
...functionalConfig.getAll(),
testFiles: [require.resolve('./apps/discover')],
services,
junit: {
reportName: 'Kibana CCS Tests',
},
};
}