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

Paramaterized Discover tests #129684

Merged
merged 11 commits into from
Apr 13, 2022
2 changes: 1 addition & 1 deletion scripts/functional_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

require('../src/setup_node_env');
require('@kbn/test').runTestsCli([
require.resolve('../test/functional/config.ccs.ts'),
require.resolve('../test/functional/config.js'),
require.resolve('../test/functional_ccs/config.ts'),
require.resolve('../test/plugin_functional/config.ts'),
require.resolve('../test/ui_capabilities/newsfeed_err/config.ts'),
require.resolve('../test/new_visualize_flow/config.ts'),
Expand Down
26 changes: 21 additions & 5 deletions test/functional/apps/discover/_data_view_editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Side Public License, v 1.
*/

import { EsArchiver } from '@kbn/es-archiver';
import { FtrProviderContext } from './ftr_provider_context';

export default function ({ getService, getPageObjects }: FtrProviderContext) {
Expand All @@ -14,10 +15,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const kibanaServer = getService('kibanaServer');
const esArchiver = getService('esArchiver');
const security = getService('security');
const config = getService('config');
const PageObjects = getPageObjects(['common', 'discover', 'header', 'timePicker']);
const defaultIndexPatternString = config.get('esTestCluster.ccs')
? 'ftr-remote:logstash-*'
: 'logstash-*';
const defaultSettings = {
defaultIndex: 'logstash-*',
defaultIndex: defaultIndexPatternString,
};
const localArchiveDirectory = 'test/functional/fixtures/kbn_archiver/discover';
const remoteArchiveDirectory = 'test/functional/fixtures/kbn_archiver/ccs/discover';
let esNode: EsArchiver;
let kbnDirectory: string;
spalger marked this conversation as resolved.
Show resolved Hide resolved

const createDataView = async (dataViewName: string) => {
await PageObjects.discover.clickIndexPatternActions();
Expand All @@ -32,22 +41,29 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
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');
if (config.get('esTestCluster.ccs')) {
esNode = getService('remoteEsArchiver' as 'esArchiver');
kbnDirectory = remoteArchiveDirectory;
} else {
esNode = esArchiver;
kbnDirectory = localArchiveDirectory;
}
await esNode.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 kibanaServer.importExport.load(kbnDirectory);
await kibanaServer.uiSettings.replace(defaultSettings);
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.importExport.unload(kbnDirectory);
await kibanaServer.savedObjects.clean({ types: ['saved-search', 'index-pattern'] });
});

it('allows creating a new data view', async function () {
const dataViewToCreate = 'logstash';
const dataViewToCreate = config.get('esTestCluster.ccs') ? 'ftr-remote:logstash' : 'logstash';
await createDataView(dataViewToCreate);
await PageObjects.header.waitUntilLoadingHasFinished();
await retry.waitForWithTimeout(
Expand Down
58 changes: 41 additions & 17 deletions test/functional/apps/discover/_saved_queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Side Public License, v 1.
*/

import { EsArchiver } from '@kbn/es-archiver';
import expect from '@kbn/expect';

import { FtrProviderContext } from '../../ftr_provider_context';
Expand All @@ -21,8 +22,28 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const queryBar = getService('queryBar');
const savedQueryManagementComponent = getService('savedQueryManagementComponent');
const testSubjects = getService('testSubjects');
const config = getService('config');
const localArchiveDirectories = {
nested: 'test/functional/fixtures/kbn_archiver/date_nested.json',
discover: 'test/functional/fixtures/kbn_archiver/discover.json',
};
const remoteArchiveDirectories = {
nested: 'test/functional/fixtures/kbn_archiver/ccs/date_nested.json',
discover: 'test/functional/fixtures/kbn_archiver/ccs/discover.json',
};
const defaultIndexPatternString = config.get('esTestCluster.ccs')
? 'ftr-remote:logstash-*'
: 'logstash-*';
const dateNestedIndexPattern = config.get('esTestCluster.ccs')
? 'ftr-remote:date-nested'
: 'date-nested';
const defaultSettings = {
defaultIndex: 'logstash-*',
defaultIndex: defaultIndexPatternString,
};
let esNode: EsArchiver;
let kbnArchives: {
nested: string;
discover: string;
};

const setUpQueriesWithFilters = async () => {
Expand All @@ -36,18 +57,22 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await queryBar.setQuery('response:200');
};

// Failing: See https://github.com/elastic/kibana/issues/124990
describe.skip('saved queries saved objects', function describeIndexTests() {
describe('saved queries saved objects', function describeIndexTests() {
before(async function () {
log.debug('load kibana index with default index pattern');
if (config.get('esTestCluster.ccs')) {
esNode = getService('remoteEsArchiver' as 'esArchiver');
kbnArchives = remoteArchiveDirectories;
} else {
esNode = esArchiver;
kbnArchives = localArchiveDirectories;
}
await kibanaServer.savedObjects.clean({ types: ['search', 'index-pattern'] });

await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json');
await kibanaServer.importExport.load(
'test/functional/fixtures/kbn_archiver/date_nested.json'
);
await esArchiver.load('test/functional/fixtures/es_archiver/date_nested');
await esArchiver.load('test/functional/fixtures/es_archiver/logstash_functional');
await kibanaServer.importExport.load(kbnArchives.discover);
await kibanaServer.importExport.load(kbnArchives.nested);
await esNode.load('test/functional/fixtures/es_archiver/date_nested');
await esNode.load('test/functional/fixtures/es_archiver/logstash_functional');

await kibanaServer.uiSettings.replace(defaultSettings);
log.debug('discover');
Expand All @@ -56,10 +81,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});

after(async () => {
await kibanaServer.importExport.unload('test/functional/fixtures/kbn_archiver/discover');
await kibanaServer.importExport.unload('test/functional/fixtures/kbn_archiver/date_nested');
await esArchiver.unload('test/functional/fixtures/es_archiver/date_nested');
await esArchiver.unload('test/functional/fixtures/es_archiver/logstash_functional');
await kibanaServer.importExport.unload(kbnArchives.discover);
await kibanaServer.importExport.unload(kbnArchives.nested);
await esNode.unload('test/functional/fixtures/es_archiver/date_nested');
await esNode.unload('test/functional/fixtures/es_archiver/logstash_functional');
await PageObjects.common.unsetTime();
});

Expand All @@ -84,12 +109,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
expect(await filterBar.hasFilter('extension.raw', 'jpg')).to.be(false);
expect(await queryBar.getQueryString()).to.eql('');

await PageObjects.discover.selectIndexPattern('date-nested');
await PageObjects.discover.selectIndexPattern(dateNestedIndexPattern);

expect(await filterBar.hasFilter('extension.raw', 'jpg')).to.be(false);
expect(await queryBar.getQueryString()).to.eql('');

await PageObjects.discover.selectIndexPattern('logstash-*');
await PageObjects.discover.selectIndexPattern(defaultIndexPatternString);

expect(await filterBar.hasFilter('extension.raw', 'jpg')).to.be(false);
expect(await queryBar.getQueryString()).to.eql('');
Expand All @@ -99,8 +124,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
});

// FLAKY: https://github.com/elastic/kibana/issues/124986
describe.skip('saved query management component functionality', function () {
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 () => {
Expand Down
5 changes: 4 additions & 1 deletion test/functional/apps/discover/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
* 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 config = getService('config');

describe('discover app', function () {
this.tags('ciGroup6');
Expand Down Expand Up @@ -55,6 +55,9 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) {
loadTestFile(require.resolve('./_chart_hidden'));
loadTestFile(require.resolve('./_context_encoded_url_param'));
loadTestFile(require.resolve('./_data_view_editor'));
if (config.get('esTestCluster.ccs')) {
loadTestFile(require.resolve('./_data_view_editor'));
}
cuff-links marked this conversation as resolved.
Show resolved Hide resolved
loadTestFile(require.resolve('./_empty_state'));
});
}
10 changes: 8 additions & 2 deletions test/functional_ccs/config.ts → test/functional/config.ccs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
*/

import { FtrConfigProviderContext } from '@kbn/test';
import { services } from './services';
import { RemoteEsArchiverProvider } from './services/remote_es/remote_es_archiver';
import { RemoteEsProvider } from './services/remote_es/remote_es';

// eslint-disable-next-line import/no-default-export
export default async function ({ readConfigFile }: FtrConfigProviderContext) {
const functionalConfig = await readConfigFile(require.resolve('../functional/config'));

Expand All @@ -17,7 +19,11 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) {

testFiles: [require.resolve('./apps/discover')],

services,
services: {
...functionalConfig.get('services'),
remoteEs: RemoteEsProvider,
remoteEsArchiver: RemoteEsArchiverProvider,
},

junit: {
reportName: 'Kibana CCS Tests',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { Client } from '@elastic/elasticsearch';

import { systemIndicesSuperuser, createRemoteEsClientForFtrConfig } from '@kbn/test';
import { FtrProviderContext } from '../ftr_provider_context';
import { FtrProviderContext } from '../../ftr_provider_context';

/**
* Kibana-specific @elastic/elasticsearch client instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
*/

import { EsArchiver } from '@kbn/es-archiver';
import { FtrProviderContext } from '../ftr_provider_context';
import { FtrProviderContext } from '../../ftr_provider_context';

export function RemoteEsArchiverProvider({ getService }: FtrProviderContext): EsArchiver {
const remoteEs = getService('remoteEs');
const remoteEs = getService('remoteEs' as 'es');
const log = getService('log');
const kibanaServer = getService('kibanaServer');

Expand Down
70 changes: 0 additions & 70 deletions test/functional_ccs/apps/discover/data_view_ccs.ts

This file was deleted.

29 changes: 0 additions & 29 deletions test/functional_ccs/apps/discover/index.ts

This file was deleted.

Loading