Migrate Lens Smoke Test To Use CCS Remote (#127426)

This commit is contained in:
John Dorlus 2022-04-01 04:28:11 -04:00 committed by GitHub
parent 308c3f1fa3
commit 40fa6076b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 791 additions and 60 deletions

View file

@ -47,6 +47,9 @@ export class VisualizePageObject extends FtrService {
LOGSTASH_NON_TIME_BASED: 'logstash*',
};
remoteEsPrefix = 'ftr-remote:';
defaultIndexString = 'logstash-*';
public async initTests(isNewLibrary = false) {
await this.kibanaServer.savedObjects.clean({ types: ['visualization'] });
await this.kibanaServer.importExport.load(
@ -54,7 +57,7 @@ export class VisualizePageObject extends FtrService {
);
await this.kibanaServer.uiSettings.replace({
defaultIndex: 'logstash-*',
defaultIndex: this.defaultIndexString,
[FORMATS_UI_SETTINGS.FORMAT_BYTES_DEFAULT_PATTERN]: '0,0.[000]b',
'visualization:visualize:legacyPieChartsLibrary': !isNewLibrary,
'visualization:visualize:legacyHeatmapChartsLibrary': !isNewLibrary,

View file

@ -7,6 +7,7 @@
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_basic/config.ts'),
require.resolve('../test/security_solution_endpoint/config.ts'),

View file

@ -5,84 +5,119 @@
* 2.0.
*/
import { EsArchiver } from '@kbn/es-archiver';
import { FtrProviderContext } from '../../ftr_provider_context';
export default function ({ getService, loadTestFile, getPageObjects }: FtrProviderContext) {
export default ({ getService, loadTestFile, getPageObjects }: FtrProviderContext) => {
const browser = getService('browser');
const log = getService('log');
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const PageObjects = getPageObjects(['timePicker']);
const config = getService('config');
let remoteEsArchiver;
describe('lens app', () => {
const esArchive = 'x-pack/test/functional/es_archives/logstash_functional';
const localIndexPatternString = 'logstash-*';
const remoteIndexPatternString = 'ftr-remote:logstash-*';
const localFixtures = {
lensBasic: 'x-pack/test/functional/fixtures/kbn_archiver/lens/lens_basic.json',
lensDefault: 'x-pack/test/functional/fixtures/kbn_archiver/lens/default',
};
const remoteFixtures = {
lensBasic: 'x-pack/test/functional/fixtures/kbn_archiver/lens/ccs/lens_basic.json',
lensDefault: 'x-pack/test/functional/fixtures/kbn_archiver/lens/ccs/default',
};
let esNode: EsArchiver;
let fixtureDirs: {
lensBasic: string;
lensDefault: string;
};
let indexPatternString: string;
before(async () => {
log.debug('Starting lens before method');
await log.debug('Starting lens before method');
await browser.setWindowSize(1280, 1200);
await esArchiver.load('x-pack/test/functional/es_archives/logstash_functional');
try {
config.get('esTestCluster.ccs');
remoteEsArchiver = getService('remoteEsArchiver' as 'esArchiver');
esNode = remoteEsArchiver;
fixtureDirs = remoteFixtures;
indexPatternString = remoteIndexPatternString;
} catch (error) {
esNode = esArchiver;
fixtureDirs = localFixtures;
indexPatternString = localIndexPatternString;
}
await esNode.load(esArchive);
// changing the timepicker default here saves us from having to set it in Discover (~8s)
await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings();
await kibanaServer.uiSettings.update({ defaultIndex: 'logstash-*', 'dateFormat:tz': 'UTC' });
await kibanaServer.importExport.load(
'x-pack/test/functional/fixtures/kbn_archiver/lens/lens_basic.json'
);
await kibanaServer.importExport.load(
'x-pack/test/functional/fixtures/kbn_archiver/lens/default'
);
await kibanaServer.uiSettings.update({
defaultIndex: indexPatternString,
'dateFormat:tz': 'UTC',
});
await kibanaServer.importExport.load(fixtureDirs.lensBasic);
await kibanaServer.importExport.load(fixtureDirs.lensDefault);
});
after(async () => {
await esArchiver.unload('x-pack/test/functional/es_archives/logstash_functional');
await esArchiver.unload(esArchive);
await PageObjects.timePicker.resetDefaultAbsoluteRangeViaUiSettings();
await kibanaServer.importExport.unload(
'x-pack/test/functional/fixtures/kbn_archiver/lens/lens_basic.json'
);
await kibanaServer.importExport.unload(
'x-pack/test/functional/fixtures/kbn_archiver/lens/default'
);
await kibanaServer.importExport.unload(fixtureDirs.lensBasic);
await kibanaServer.importExport.unload(fixtureDirs.lensDefault);
});
describe('', function () {
this.tags(['ciGroup3', 'skipFirefox']);
loadTestFile(require.resolve('./smokescreen'));
loadTestFile(require.resolve('./persistent_context'));
});
if (config.get('esTestCluster.ccs')) {
describe('', function () {
this.tags(['ciGroup3', 'skipFirefox']);
loadTestFile(require.resolve('./smokescreen'));
});
} else {
describe('', function () {
this.tags(['ciGroup3', 'skipFirefox']);
loadTestFile(require.resolve('./smokescreen'));
loadTestFile(require.resolve('./persistent_context'));
});
describe('', function () {
this.tags(['ciGroup16', 'skipFirefox']);
describe('', function () {
this.tags(['ciGroup16', 'skipFirefox']);
loadTestFile(require.resolve('./add_to_dashboard'));
loadTestFile(require.resolve('./table_dashboard'));
loadTestFile(require.resolve('./table'));
loadTestFile(require.resolve('./runtime_fields'));
loadTestFile(require.resolve('./dashboard'));
loadTestFile(require.resolve('./multi_terms'));
loadTestFile(require.resolve('./epoch_millis'));
loadTestFile(require.resolve('./show_underlying_data'));
loadTestFile(require.resolve('./show_underlying_data_dashboard'));
});
loadTestFile(require.resolve('./add_to_dashboard'));
loadTestFile(require.resolve('./table_dashboard'));
loadTestFile(require.resolve('./table'));
loadTestFile(require.resolve('./runtime_fields'));
loadTestFile(require.resolve('./dashboard'));
loadTestFile(require.resolve('./multi_terms'));
loadTestFile(require.resolve('./epoch_millis'));
loadTestFile(require.resolve('./show_underlying_data'));
loadTestFile(require.resolve('./show_underlying_data_dashboard'));
});
describe('', function () {
this.tags(['ciGroup4', 'skipFirefox']);
describe('', function () {
this.tags(['ciGroup4', 'skipFirefox']);
loadTestFile(require.resolve('./colors'));
loadTestFile(require.resolve('./chart_data'));
loadTestFile(require.resolve('./time_shift'));
loadTestFile(require.resolve('./drag_and_drop'));
loadTestFile(require.resolve('./disable_auto_apply'));
loadTestFile(require.resolve('./geo_field'));
loadTestFile(require.resolve('./formula'));
loadTestFile(require.resolve('./heatmap'));
loadTestFile(require.resolve('./gauge'));
loadTestFile(require.resolve('./metrics'));
loadTestFile(require.resolve('./reference_lines'));
loadTestFile(require.resolve('./annotations'));
loadTestFile(require.resolve('./inspector'));
loadTestFile(require.resolve('./error_handling'));
loadTestFile(require.resolve('./lens_tagging'));
loadTestFile(require.resolve('./lens_reporting'));
loadTestFile(require.resolve('./tsvb_open_in_lens'));
// has to be last one in the suite because it overrides saved objects
loadTestFile(require.resolve('./rollup'));
});
loadTestFile(require.resolve('./colors'));
loadTestFile(require.resolve('./chart_data'));
loadTestFile(require.resolve('./time_shift'));
loadTestFile(require.resolve('./drag_and_drop'));
loadTestFile(require.resolve('./disable_auto_apply'));
loadTestFile(require.resolve('./geo_field'));
loadTestFile(require.resolve('./formula'));
loadTestFile(require.resolve('./heatmap'));
loadTestFile(require.resolve('./gauge'));
loadTestFile(require.resolve('./metrics'));
loadTestFile(require.resolve('./reference_lines'));
loadTestFile(require.resolve('./annotations'));
loadTestFile(require.resolve('./inspector'));
loadTestFile(require.resolve('./error_handling'));
loadTestFile(require.resolve('./lens_tagging'));
loadTestFile(require.resolve('./lens_reporting'));
loadTestFile(require.resolve('./tsvb_open_in_lens'));
// has to be last one in the suite because it overrides saved objects
loadTestFile(require.resolve('./rollup'));
});
}
});
}
};

View file

@ -17,6 +17,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const elasticChart = getService('elasticChart');
const filterBar = getService('filterBar');
const retry = getService('retry');
const config = getService('config');
describe('lens smokescreen tests', () => {
it('should allow creation of lens xy chart', async () => {
@ -686,8 +687,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
it('should allow to change index pattern', async () => {
await PageObjects.lens.switchFirstLayerIndexPattern('log*');
expect(await PageObjects.lens.getFirstLayerIndexPattern()).to.equal('log*');
let indexPatternString;
if (config.get('esTestCluster.ccs')) {
indexPatternString = 'ftr-remote:log*';
} else {
indexPatternString = 'log*';
}
await PageObjects.lens.switchFirstLayerIndexPattern(indexPatternString);
expect(await PageObjects.lens.getFirstLayerIndexPattern()).to.equal(indexPatternString);
});
it('should show a download button only when the configuration is valid', async () => {

View file

@ -0,0 +1,54 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { FtrConfigProviderContext } from '@kbn/test';
import { RemoteEsArchiverProvider } from './services/remote_es/remote_es_archiver';
import { RemoteEsProvider } from './services/remote_es/remote_es';
export default async function ({ readConfigFile }: FtrConfigProviderContext) {
const functionalConfig = await readConfigFile(require.resolve('./config'));
return {
...functionalConfig.getAll(),
testFiles: [require.resolve('./apps/lens')],
junit: {
reportName: 'X-Pack CCS Tests',
},
security: {
...functionalConfig.get('security'),
remoteEsRoles: {
ccs_remote_search: {
indices: [
{
names: ['*'],
privileges: ['read', 'view_index_metadata', 'read_cross_cluster'],
},
],
},
},
defaultRoles: [...(functionalConfig.get('security.defaultRoles') ?? []), 'ccs_remote_search'],
},
esTestCluster: {
...functionalConfig.get('esTestCluster'),
ccs: {
remoteClusterUrl:
process.env.REMOTE_CLUSTER_URL ??
'http://elastic:changeme@localhost:' +
`${functionalConfig.get('servers.elasticsearch.port') + 1}`,
},
},
services: {
...functionalConfig.get('services'),
remoteEs: RemoteEsProvider,
remoteEsArchiver: RemoteEsArchiverProvider,
},
};
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,23 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { Client } from '@elastic/elasticsearch';
import { systemIndicesSuperuser, createRemoteEsClientForFtrConfig } from '@kbn/test';
import { FtrProviderContext } from '../../ftr_provider_context';
/**
* Kibana-specific @elastic/elasticsearch client instance.
*/
export function RemoteEsProvider({ getService }: FtrProviderContext): Client {
const config = getService('config');
return createRemoteEsClientForFtrConfig(config, {
// Use system indices user so tests can write to system indices
authOverride: systemIndicesSuperuser,
});
}

View file

@ -0,0 +1,21 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { EsArchiver } from '@kbn/es-archiver';
import { FtrProviderContext } from '../../ftr_provider_context';
export function RemoteEsArchiverProvider({ getService }: FtrProviderContext): EsArchiver {
const remoteEs = getService('remoteEs' as 'es');
const log = getService('log');
const kibanaServer = getService('kibanaServer');
return new EsArchiver({
client: remoteEs,
log,
kbnClient: kibanaServer,
});
}