Skip to content

Commit

Permalink
[ML] Functional tests - add basic license tests (elastic#82147)
Browse files Browse the repository at this point in the history
This PR adds initial functional tests and api integration tests running on a basic license for the ML and Transform apps.
  • Loading branch information
pheyos committed Nov 2, 2020
1 parent 9cd1135 commit 3c041f3
Show file tree
Hide file tree
Showing 29 changed files with 838 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,12 @@ export const MainTabs: FC<Props> = ({ tabId, disableLinks }) => {
const defaultPathId = (TAB_DATA[id].pathId || id) as MlUrlGeneratorState['page'];

return disabled ? (
<EuiTab key={`${id}-key`} className={'mlNavigationMenu__mainTab'} disabled={true}>
<EuiTab
key={`${id}-key`}
className={'mlNavigationMenu__mainTab'}
disabled={true}
data-test-subj={testSubject}
>
{tab.name}
</EuiTab>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,15 @@ export const DatavisualizerSelector: FC = () => {
<EuiButton
target="_blank"
href={`${basePath.get()}/app/management/stack/license_management/home`}
data-test-subj="mlDataVisualizerStartTrialButton"
>
<FormattedMessage
id="xpack.ml.datavisualizer.selector.startTrialButtonLabel"
defaultMessage="Start trial"
/>
</EuiButton>
}
data-test-subj="mlDataVisualizerCardStartTrial"
/>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/ml/public/application/routing/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export const MlRouter: FC<{
<Router history={pageDeps.history}>
<LegacyHashUrlRedirect>
<UrlStateProvider>
<div className="ml-app">
<div className="ml-app" data-test-subj="mlApp">
<MlRoutes pageDeps={pageDeps} />
</div>
</UrlStateProvider>
Expand Down
2 changes: 2 additions & 0 deletions x-pack/scripts/functional_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require('../../src/setup_node_env');

require('@kbn/test').runTestsCli([
require.resolve('../test/functional/config.js'),
require.resolve('../test/functional_basic/config.ts'),
require.resolve('../test/security_solution_endpoint/config.ts'),
require.resolve('../test/plugin_functional/config.ts'),
require.resolve('../test/functional_with_es_ssl/config.ts'),
Expand All @@ -18,6 +19,7 @@ require('@kbn/test').runTestsCli([
require.resolve('../test/api_integration/config_security_basic.ts'),
require.resolve('../test/api_integration/config_security_trial.ts'),
require.resolve('../test/api_integration/config.ts'),
require.resolve('../test/api_integration_basic/config.ts'),
require.resolve('../test/alerting_api_integration/basic/config.ts'),
require.resolve('../test/alerting_api_integration/spaces_only/config.ts'),
require.resolve('../test/alerting_api_integration/security_and_spaces/config.ts'),
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/api_integration/apis/transform/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const transform = getService('transform');

describe('Machine Learning', function () {
describe('transform', function () {
this.tags(['transform']);

before(async () => {
Expand Down
16 changes: 16 additions & 0 deletions x-pack/test/api_integration_basic/apis/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { FtrProviderContext } from '../ftr_provider_context';

export default function ({ loadTestFile }: FtrProviderContext) {
describe('apis', function () {
this.tags('ciGroup2');

loadTestFile(require.resolve('./ml'));
loadTestFile(require.resolve('./transform'));
});
}
14 changes: 14 additions & 0 deletions x-pack/test/api_integration_basic/apis/ml/data_visualizer/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { FtrProviderContext } from '../../../ftr_provider_context';

export default function ({ loadTestFile }: FtrProviderContext) {
describe('data visualizer', function () {
// The data visualizer APIs should work the same as with a trial license
loadTestFile(require.resolve('../../../../api_integration/apis/ml/data_visualizer'));
});
}
39 changes: 39 additions & 0 deletions x-pack/test/api_integration_basic/apis/ml/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService, loadTestFile }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const ml = getService('ml');

describe('machine learning basic license', function () {
this.tags(['mlqa']);

before(async () => {
await ml.securityCommon.createMlRoles();
await ml.securityCommon.createMlUsers();
});

after(async () => {
await ml.securityCommon.cleanMlUsers();
await ml.securityCommon.cleanMlRoles();

await ml.testResources.deleteIndexPatternByTitle('ft_farequote');

await esArchiver.unload('ml/farequote');

await ml.testResources.resetKibanaTimeZone();
});

loadTestFile(require.resolve('./data_visualizer'));
});
}
16 changes: 16 additions & 0 deletions x-pack/test/api_integration_basic/apis/transform/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ loadTestFile }: FtrProviderContext) {
describe('transform basic license', function () {
this.tags(['transform']);

// The transform UI should work the same as with a trial license
loadTestFile(require.resolve('../../../api_integration/apis/transform'));
});
}
32 changes: 32 additions & 0 deletions x-pack/test/api_integration_basic/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { FtrConfigProviderContext } from '@kbn/test/types/ftr';

export default async function ({ readConfigFile }: FtrConfigProviderContext) {
const xpackApiIntegrationConfig = await readConfigFile(
require.resolve('../api_integration/config.ts')
);

return {
// default to the xpack api integration config
...xpackApiIntegrationConfig.getAll(),
esTestCluster: {
...xpackApiIntegrationConfig.get('esTestCluster'),
license: 'basic',
serverArgs: [
'xpack.license.self_generated.type=basic',
'xpack.security.enabled=true',
'xpack.security.authc.api_key.enabled=true',
],
},
testFiles: [require.resolve('./apis')],
junit: {
...xpackApiIntegrationConfig.get('junit'),
reportName: 'Chrome X-Pack UI Functional Tests Basic License',
},
};
}
11 changes: 11 additions & 0 deletions x-pack/test/api_integration_basic/ftr_provider_context.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { GenericFtrProviderContext } from '@kbn/test/types/ftr';

import { services } from '../api_integration/services';

export type FtrProviderContext = GenericFtrProviderContext<typeof services, {}>;
1 change: 1 addition & 0 deletions x-pack/test/functional/apps/ml/data_visualizer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default function ({ loadTestFile }: FtrProviderContext) {
this.tags(['skipFirefox']);

loadTestFile(require.resolve('./index_data_visualizer'));
loadTestFile(require.resolve('./index_data_visualizer_actions_panel'));
loadTestFile(require.resolve('./file_data_visualizer'));
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { FieldVisConfig } from '../../../../../plugins/ml/public/application/dat
interface TestData {
suiteTitle: string;
sourceIndexOrSavedSearch: string;
advancedJobWizardDatafeedQuery: string;
metricFieldsFilter: string;
nonMetricFieldsFilter: string;
nonMetricFieldsTypeFilter: string;
Expand Down Expand Up @@ -45,15 +44,6 @@ export default function ({ getService }: FtrProviderContext) {
const farequoteIndexPatternTestData: TestData = {
suiteTitle: 'index pattern',
sourceIndexOrSavedSearch: 'ft_farequote',
advancedJobWizardDatafeedQuery: `{
"bool": {
"must": [
{
"match_all": {}
}
]
}
}`,
metricFieldsFilter: 'document',
nonMetricFieldsFilter: 'airline',
nonMetricFieldsTypeFilter: 'keyword',
Expand Down Expand Up @@ -128,15 +118,6 @@ export default function ({ getService }: FtrProviderContext) {
const farequoteKQLSearchTestData: TestData = {
suiteTitle: 'KQL saved search',
sourceIndexOrSavedSearch: 'ft_farequote_kuery',
advancedJobWizardDatafeedQuery: `{
"bool": {
"must": [
{
"match_all": {}
}
]
}
}`, // Note query is not currently passed to the wizard
metricFieldsFilter: 'responsetime',
nonMetricFieldsFilter: 'airline',
nonMetricFieldsTypeFilter: 'keyword',
Expand Down Expand Up @@ -211,15 +192,6 @@ export default function ({ getService }: FtrProviderContext) {
const farequoteLuceneSearchTestData: TestData = {
suiteTitle: 'lucene saved search',
sourceIndexOrSavedSearch: 'ft_farequote_lucene',
advancedJobWizardDatafeedQuery: `{
"bool": {
"must": [
{
"match_all": {}
}
]
}
}`, // Note query is not currently passed to the wizard
metricFieldsFilter: 'responsetime',
nonMetricFieldsFilter: 'version',
nonMetricFieldsTypeFilter: 'keyword',
Expand Down Expand Up @@ -425,17 +397,6 @@ export default function ({ getService }: FtrProviderContext) {
});

runTests(farequoteLuceneSearchTestData);

// Test the Create advanced job button.
// Note the search is not currently passed to the wizard, just the index.
it(`${farequoteLuceneSearchTestData.suiteTitle} opens the advanced job wizard`, async () => {
await ml.dataVisualizerIndexBased.clickCreateAdvancedJobButton();
await ml.jobTypeSelection.assertAdvancedJobWizardOpen();
await ml.jobWizardAdvanced.assertDatafeedQueryEditorExists();
await ml.jobWizardAdvanced.assertDatafeedQueryEditorValue(
farequoteLuceneSearchTestData.advancedJobWizardDatafeedQuery
);
});
});
});
}
Original file line number Diff line number Diff line change
@@ -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;
* you may not use this file except in compliance with the Elastic License.
*/

import { FtrProviderContext } from '../../../ftr_provider_context';

export default function ({ getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const ml = getService('ml');

describe('index based actions panel', function () {
this.tags(['mlqa']);

const indexPatternName = 'ft_farequote';
const advancedJobWizardDatafeedQuery = `{
"bool": {
"must": [
{
"match_all": {}
}
]
}
}`; // Note query is not currently passed to the wizard

before(async () => {
await esArchiver.loadIfNeeded('ml/farequote');
await ml.testResources.createIndexPatternIfNeeded(indexPatternName, '@timestamp');
await ml.testResources.setKibanaTimeZoneToUTC();

await ml.securityUI.loginAsMlPowerUser();
});

describe('create advanced job action', function () {
it('loads the source data in the data visualizer', async () => {
await ml.testExecution.logTestStep('loads the data visualizer selector page');
await ml.navigation.navigateToMl();
await ml.navigation.navigateToDataVisualizer();

await ml.testExecution.logTestStep('loads the saved search selection page');
await ml.dataVisualizer.navigateToIndexPatternSelection();

await ml.testExecution.logTestStep('loads the index data visualizer page');
await ml.jobSourceSelection.selectSourceForIndexBasedDataVisualizer(indexPatternName);
});

it('opens the advanced job wizard', async () => {
await ml.testExecution.logTestStep('displays the actions panel with advanced job card');
await ml.dataVisualizerIndexBased.assertActionsPanelExists();
await ml.dataVisualizerIndexBased.assertCreateAdvancedJobCardExists();

// Note the search is not currently passed to the wizard, just the index.
await ml.testExecution.logTestStep('displays the actions panel with advanced job card');
await ml.dataVisualizerIndexBased.clickCreateAdvancedJobButton();
await ml.jobTypeSelection.assertAdvancedJobWizardOpen();
await ml.jobWizardAdvanced.assertDatafeedQueryEditorExists();
await ml.jobWizardAdvanced.assertDatafeedQueryEditorValue(advancedJobWizardDatafeedQuery);
});
});
});
}
27 changes: 25 additions & 2 deletions x-pack/test/functional/apps/ml/permissions/full_ml_access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,32 @@ export default function ({ getService }: FtrProviderContext) {
await ml.navigation.assertKibanaNavMLEntryExists();
});

it('should display tabs in the ML app correctly', async () => {
await ml.testExecution.logTestStep('should load the ML app');
await ml.navigation.navigateToMl();

await ml.testExecution.logTestStep('should display the enabled "Overview" tab');
await ml.navigation.assertOverviewTabEnabled(true);

await ml.testExecution.logTestStep(
'should display the enabled "Anomaly Detection" tab'
);
await ml.navigation.assertAnomalyDetectionTabEnabled(true);

await ml.testExecution.logTestStep(
'should display the enabled "Data Frame Analytics" tab'
);
await ml.navigation.assertDataFrameAnalyticsTabEnabled(true);

await ml.testExecution.logTestStep('should display the enabled "Data Visualizer" tab');
await ml.navigation.assertDataVisualizerTabEnabled(true);

await ml.testExecution.logTestStep('should display the enabled "Settings" tab');
await ml.navigation.assertSettingsTabEnabled(true);
});

it('should display elements on ML Overview page correctly', async () => {
await ml.testExecution.logTestStep('should load the ML overview page');
await ml.navigation.navigateToMl();
await ml.navigation.navigateToOverview();

await ml.testExecution.logTestStep('should display enabled AD create job button');
Expand Down Expand Up @@ -353,7 +376,7 @@ export default function ({ getService }: FtrProviderContext) {
await ml.dataVisualizerFileBased.selectFile(uploadFilePath);

await ml.testExecution.logTestStep(
'should displays components of the file details page'
'should display components of the file details page'
);
await ml.dataVisualizerFileBased.assertFileTitle(expectedUploadFileTitle);
await ml.dataVisualizerFileBased.assertFileContentPanelExists();
Expand Down
Loading

0 comments on commit 3c041f3

Please sign in to comment.