Rollup job Functional UI test (#30280) (#30571)

This commit is contained in:
Rashmi Kulkarni 2019-02-08 14:09:47 -08:00 committed by GitHub
parent e82c94f577
commit 90820a5cc7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 188 additions and 4 deletions

View file

@ -292,6 +292,7 @@ export class JobCreateUi extends Component {
!this.canGoToStep(stepId)
|| stepIds.indexOf(stepId) > stepIds.indexOf(checkpointStepId)
),
'data-test-subj': index === indexOfCurrentStep ? `createRollupStep${index + 1}--active` : `createRollupStep${index + 1}`,
}));
}

View file

@ -52,6 +52,7 @@ const NavigationUi = ({
<EuiButtonEmpty
iconType="arrowLeft"
onClick={goToPreviousStep}
data-test-subj="rollupJobBackButton"
>
<FormattedMessage
id="xpack.rollupJobs.create.backButton.label"
@ -72,6 +73,7 @@ const NavigationUi = ({
onClick={goToNextStep}
isDisabled={!canGoToNextStep}
fill
data-test-subj="rollupJobNextButton"
>
<FormattedMessage
id="xpack.rollupJobs.create.nextButton.label"
@ -88,6 +90,7 @@ const NavigationUi = ({
iconType="check"
onClick={save}
fill
data-test-subj="rollupJobSaveButton"
>
<FormattedMessage
id="xpack.rollupJobs.create.saveButton.label"

View file

@ -291,6 +291,7 @@ export class StepDateHistogramUi extends Component {
onChange={e => onFieldsChange({ dateHistogramInterval: e.target.value })}
isInvalid={Boolean(areStepErrorsVisible && errorDateHistogramInterval)}
fullWidth
data-test-subj="rollupJobInterval"
/>
</EuiFormRow>

View file

@ -71,7 +71,7 @@ export class StepLogisticsUi extends Component {
if(!isValidatingIndexPattern && hasMatchingIndices) {
return (
<EuiTextColor color="secondary">
<EuiTextColor color="secondary" data-test-subj="fieldIndexPatternSuccessMessage">
<p>
<FormattedMessage
id="xpack.rollupJobs.create.stepLogistics.fieldIndexPattern.helpHasMatchesLabel"
@ -323,6 +323,7 @@ export class StepLogisticsUi extends Component {
value={id}
onChange={e => onFieldsChange({ id: e.target.value })}
fullWidth
data-test-subj="rollupJobName"
/>
</EuiFormRow>
</EuiDescribedFormGroup>
@ -364,6 +365,7 @@ export class StepLogisticsUi extends Component {
isInvalid={Boolean(areStepErrorsVisible && errorIndexPattern) || Boolean(indexPatternAsyncErrors)}
isLoading={isValidatingIndexPattern}
fullWidth
data-test-subj="rollupIndexPattern"
/>
</EuiFormRow>
@ -390,6 +392,7 @@ export class StepLogisticsUi extends Component {
onChange={e => onFieldsChange({ rollupIndex: e.target.value })}
isInvalid={Boolean(areStepErrorsVisible && errorRollupIndex)}
fullWidth
data-test-subj="rollupIndexName"
/>
</EuiFormRow>
</EuiDescribedFormGroup>

View file

@ -182,6 +182,7 @@ export class JobListUi extends Component {
}
actions={
<EuiButton
data-test-subj="createRollupJobButton"
{...getRouterLinkProps(`${CRUD_APP_BASE_PATH}/create`)}
fill
iconType="plusInCircle"
@ -278,4 +279,3 @@ export class JobListUi extends Component {
}
export const JobList = injectI18n(JobListUi);

View file

@ -8,6 +8,7 @@ import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types';
import { i18n } from '@kbn/i18n';
import { injectI18n } from '@kbn/i18n/react';
import _ from 'lodash';
import {
EuiCheckbox,
@ -253,7 +254,6 @@ export class JobTableUi extends Component {
if (name === 'ID') {
content = (
<EuiLink
data-test-subj="rollupTableJobLink"
onClick={() => {
openDetailPanel(job.id);
}}
@ -280,7 +280,7 @@ export class JobTableUi extends Component {
return (
<EuiTableRowCell
key={`${job.id}-${name}`}
data-test-subj={`jobTableCell-${name}`}
data-test-subj={`jobTableCell-${_.camelCase(name)}`}
truncateText={truncateText}
>
{wrappedContent}
@ -298,6 +298,7 @@ export class JobTableUi extends Component {
return (
<EuiTableRow
key={`${id}-row`}
data-test-subj="jobTableRow"
>
<EuiTableRowCellCheckbox key={`checkbox-${id}`}>
<EuiCheckbox

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;
* you may not use this file except in compliance with the Elastic License.
*/
export default function ({ loadTestFile }) {
describe('rollup job', function () {
this.tags('ciGroup1');
loadTestFile(require.resolve('./rollup_jobs'));
});
}

View file

@ -0,0 +1,68 @@
/*
* 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 expect from 'expect.js';
import { indexBy } from 'lodash';
export default function ({ getService, getPageObjects }) {
const esArchiver = getService('esArchiver');
const log = getService('log');
const PageObjects = getPageObjects(['security', 'rollup', 'common', 'header']);
describe('rollup job', async () => {
before(async () => {
// init data
await Promise.all([
esArchiver.loadIfNeeded('logstash_functional'),
esArchiver.load('canvas/default'),
]);
await PageObjects.common.navigateToApp('rollupJob');
});
after(async () => await esArchiver.unload('logstash_functional'));
it('create and save a new job', async () => {
const jobName = 'Testjob1';
const indexPattern = '.kibana*';
const indexName = 'rollup_index';
const interval = '1000ms';
await PageObjects.rollup.createNewRollUpJob();
await PageObjects.rollup.verifyStepIsActive(1);
await PageObjects.rollup.addRoleNameandIndexPattern(jobName, indexPattern);
await PageObjects.rollup.verifyIndexPatternAccepted();
await PageObjects.rollup.setIndexName(indexName);
await PageObjects.rollup.moveToNextStep();
//now navigate to histogram
await PageObjects.rollup.verifyStepIsActive(2);
await PageObjects.rollup.setJobInterval(interval);
await PageObjects.rollup.moveToNextStep();
//Terms (optional)
await PageObjects.rollup.verifyStepIsActive(3);
await PageObjects.rollup.moveToNextStep();
//Histogram(optional)
await PageObjects.rollup.verifyStepIsActive(4);
await PageObjects.rollup.moveToNextStep();
//Metrics(optional)
await PageObjects.rollup.verifyStepIsActive(5);
await PageObjects.rollup.moveToNextStep();
//saveJob and verify the name in the list
await PageObjects.rollup.verifyStepIsActive(6);
await PageObjects.rollup.saveJob();
// verify jobListTitle
const jobList = indexBy(await PageObjects.rollup.getJobList(), 'jobName');
log.debug(JSON.stringify(jobList));
log.debug(Object.keys(jobList));
expect(Object.keys(jobList)).to.have.length(1);
});
});
}

View file

@ -22,7 +22,9 @@ import {
GisPageProvider,
StatusPagePageProvider,
UpgradeAssistantProvider,
RollupPageProvider,
UptimePageProvider,
} from './page_objects';
import {
@ -54,6 +56,7 @@ import {
GrokDebuggerProvider,
UserMenuProvider,
UptimeProvider,
} from './services';
// the default export of config files must be a config provider
@ -82,6 +85,7 @@ export default async function ({ readConfigFile }) {
resolve(__dirname, './apps/logstash'),
resolve(__dirname, './apps/grok_debugger'),
resolve(__dirname, './apps/infra'),
resolve(__dirname, './apps/rollup_job'),
resolve(__dirname, './apps/maps'),
resolve(__dirname, './apps/status_page'),
resolve(__dirname, './apps/upgrade_assistant'),
@ -122,6 +126,7 @@ export default async function ({ readConfigFile }) {
grokDebugger: GrokDebuggerProvider,
userMenu: UserMenuProvider,
uptime: UptimeProvider,
rollup: RollupPageProvider,
},
// just like services, PageObjects are defined as a map of
@ -142,6 +147,7 @@ export default async function ({ readConfigFile }) {
statusPage: StatusPagePageProvider,
upgradeAssistant: UpgradeAssistantProvider,
uptime: UptimePageProvider,
rollup: RollupPageProvider
},
servers: kibanaFunctionalConfig.get('servers'),
@ -205,6 +211,10 @@ export default async function ({ readConfigFile }) {
},
uptime: {
pathname: '/app/uptime',
},
rollupJob: {
pathname: '/app/kibana',
hash: '/management/elasticsearch/rollup_jobs/'
}
},
@ -223,4 +233,5 @@ export default async function ({ readConfigFile }) {
rootDirectory: resolve(__dirname, '../../'),
},
};
}

View file

@ -17,4 +17,5 @@ export { InfraHomePageProvider } from './infra_home_page';
export { GisPageProvider } from './gis_page';
export { StatusPagePageProvider } from './status_page';
export { UpgradeAssistantProvider } from './upgrade_assistant';
export { RollupPageProvider } from './rollup_page';
export { UptimePageProvider } from './uptime_page';

View file

@ -0,0 +1,82 @@
/*
* 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 expect from 'expect.js';
import { map as mapAsync } from 'bluebird';
export function RollupPageProvider({ getService, getPageObjects }) {
const testSubjects = getService('testSubjects');
const log = getService('log');
const PageObjects = getPageObjects(['header', 'common']);
class RollupJobPage {
async createNewRollUpJob() {
await testSubjects.click('createRollupJobButton');
}
async verifyStepIsActive(stepNumber) {
await testSubjects.exists(`createRollupStep${stepNumber}--active`);
}
async addRoleNameandIndexPattern(name, indexPattern) {
log.debug(`Adding name ${name} to form`);
await testSubjects.setValue('rollupJobName', name);
await testSubjects.setValue('rollupIndexPattern', indexPattern);
}
async verifyIndexPatternAccepted() {
const span = await testSubjects.find('fieldIndexPatternSuccessMessage');
const message = await span.findByCssSelector('p');
const text = await message.getVisibleText();
expect(text).to.be.equal('Success! Index pattern has matching indices.');
}
async setIndexName(name) {
await testSubjects.setValue('rollupIndexName', name);
}
async moveToNextStep() {
await testSubjects.click('rollupJobNextButton');
}
async setJobInterval(time) {
await testSubjects.setValue('rollupJobInterval', time);
}
async saveJob() {
await testSubjects.click('rollupJobSaveButton');
await PageObjects.header.waitUntilLoadingHasFinished();
}
async getJobList() {
const jobs = await testSubjects.findAll('jobTableRow');
return mapAsync(jobs, async job => {
const jobNameElement = await job.findByCssSelector('[data-test-subj="jobTableCell-id"]');
const jobStatusElement = await job.findByCssSelector('[data-test-subj="jobTableCell-status"]');
const jobIndexPatternElement = await job.findByCssSelector('[data-test-subj="jobTableCell-indexPattern"]');
const jobRollUpIndexPatternElement = await job.findByCssSelector('[data-test-subj="jobTableCell-rollupIndex"]');
const jobDelayElement = await job.findByCssSelector('[data-test-subj="jobTableCell-delay"]');
const jobIntervalElement = await job.findByCssSelector('[data-test-subj="jobTableCell-interval"]');
const jobGroupElement = await job.findByCssSelector('[data-test-subj="jobTableCell-groups"]');
const jobMetricsElement = await job.findByCssSelector('[data-test-subj="jobTableCell-metrics"]');
return {
jobName: await jobNameElement.getVisibleText(),
jobStatus: await jobStatusElement.getVisibleText(),
jobIndexPattern: await jobIndexPatternElement.getVisibleText(),
jobRollUpIndexPattern: await jobRollUpIndexPatternElement.getVisibleText(),
jobDelayElement: await jobDelayElement.getVisibleText(),
jobInterval: await jobIntervalElement.getVisibleText(),
jobGroup: await jobGroupElement.getVisibleText(),
jobMetrics: await jobMetricsElement.getVisibleText()
};
});
}
}
return new RollupJobPage();
}