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

[ML] Add AD job validation UI tests #179358

Merged
merged 83 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
4f9a588
[ML] Add AD job validation UI tests
wayneseymour Mar 25, 2024
215d757
Merge branch 'main' of github.com:elastic/kibana into ml-add-job-vali…
wayneseymour Mar 27, 2024
49c3901
Merge branch 'main' of github.com:elastic/kibana into ml-add-job-vali…
wayneseymour Mar 27, 2024
057da93
Truncate test subj for validation callout, from msg contents.
wayneseymour Mar 27, 2024
2667c93
Merge branch 'main' of github.com:elastic/kibana into ml-add-job-vali…
wayneseymour Mar 27, 2024
d5bc5a5
Merge branch 'main' of github.com:elastic/kibana into ml-add-job-vali…
wayneseymour Apr 1, 2024
433aad8
Graft it block to existing suite, per cr.
wayneseymour Apr 2, 2024
21c1f50
Graft next it block to exisiting suite, per cr.
wayneseymour Apr 2, 2024
f1bb227
Graft next it block to existing suite.
wayneseymour Apr 2, 2024
30a59c6
Drop new suite.
wayneseymour Apr 2, 2024
affd426
Update x-pack/test/functional/services/ml/job_wizard_common.ts
wayneseymour Apr 2, 2024
9dc3b15
Merge branch 'ml-add-job-validation-ui-tests' of github.com:wayneseym…
wayneseymour Apr 2, 2024
f5cd43b
Change symbol name, per cr.
wayneseymour Apr 2, 2024
6602b29
More cr fixups
wayneseymour Apr 2, 2024
ef73e43
Update x-pack/plugins/ml/public/application/components/callout/callou…
wayneseymour Apr 2, 2024
e1e75d1
Merge branch 'ml-add-job-validation-ui-tests' of github.com:wayneseym…
wayneseymour Apr 2, 2024
bdd577b
Change for test subjs, per cr.
wayneseymour Apr 3, 2024
57ed9df
Fixup assertions, per cr.
wayneseymour Apr 3, 2024
b33540c
assert test subj and text
wayneseymour Apr 3, 2024
b1385ce
Merge branch 'main' into ml-add-job-validation-ui-tests
kibanamachine Apr 3, 2024
5a8d112
Merge branch 'main' of github.com:elastic/kibana into ml-add-job-vali…
wayneseymour Apr 4, 2024
4e73965
Update x-pack/plugins/ml/public/application/jobs/new_job/pages/new_jo…
wayneseymour Apr 5, 2024
d0eab64
Merge branch 'main' of github.com:elastic/kibana into ml-add-job-vali…
wayneseymour Apr 11, 2024
28b0228
Merge branch 'ml-add-job-validation-ui-tests' of github.com:wayneseym…
wayneseymour Apr 11, 2024
a859e3d
Merge branch 'main' of github.com:elastic/kibana into ml-add-job-vali…
wayneseymour Apr 11, 2024
0fca96c
fixup test subjects && make tsc happy with adding a test subj to the …
wayneseymour Apr 11, 2024
3664a94
Use optional chaining to make tsc happy.
wayneseymour Apr 11, 2024
347173a
Merge branch 'main' of github.com:elastic/kibana into ml-add-job-vali…
wayneseymour Apr 12, 2024
01be0f4
switch to regex as some of the numbers vary
wayneseymour Apr 12, 2024
2c17a27
Merge branch 'main' of github.com:elastic/kibana into ml-add-job-vali…
wayneseymour Apr 12, 2024
d57bc59
Use an inline level element instead and
wayneseymour Apr 12, 2024
0973dce
Merge branch 'main' of github.com:elastic/kibana into ml-add-job-vali…
wayneseymour Apr 15, 2024
9ea07a3
switch to method
wayneseymour Apr 15, 2024
db7ff28
Fixup test subj
wayneseymour Apr 15, 2024
e3d5652
update test subj
wayneseymour Apr 15, 2024
1bfe1b3
change name
wayneseymour Apr 15, 2024
4fcc3b9
Merge branch 'main' of github.com:elastic/kibana into ml-add-job-vali…
wayneseymour Apr 16, 2024
2204171
Merge branch 'main' of github.com:elastic/kibana into ml-add-job-vali…
wayneseymour Apr 17, 2024
1f9611a
Use popper props per Lene G.
wayneseymour Apr 17, 2024
6c22755
cleanup
wayneseymour Apr 17, 2024
2af4109
Merge branch 'main' into ml-add-job-validation-ui-tests
kibanamachine Apr 18, 2024
1937d40
Merge branch 'main' into ml-add-job-validation-ui-tests
kibanamachine Apr 18, 2024
97995c1
Merge branch 'main' of github.com:elastic/kibana into ml-add-job-vali…
wayneseymour Apr 22, 2024
18d214c
Merge branch 'main' into ml-add-job-validation-ui-tests
kibanamachine Apr 22, 2024
3d2720a
Merge branch 'main' into ml-add-job-validation-ui-tests
kibanamachine Apr 24, 2024
c30644a
Merge branch 'main' into ml-add-job-validation-ui-tests
kibanamachine Apr 26, 2024
bee8109
Merge branch 'ml-add-job-validation-ui-tests' of github.com:wayneseym…
wayneseymour Apr 29, 2024
aabfc04
Merge branch 'main' of github.com:elastic/kibana into ml-add-job-vali…
wayneseymour Apr 29, 2024
894de3d
Merge branch 'main' of github.com:elastic/kibana into ml-add-job-vali…
wayneseymour Apr 29, 2024
43d2b26
drop togglingModelChangeAnnotationsShowsCalloutAndRemovesCallout meth…
wayneseymour Apr 29, 2024
9ac5448
drop cloneJob method per cr
wayneseymour Apr 29, 2024
e0ad466
Merge branch 'main' of github.com:elastic/kibana into ml-add-job-vali…
wayneseymour Apr 30, 2024
7ec5b38
Merge branch 'main' of github.com:elastic/kibana into ml-add-job-vali…
wayneseymour May 6, 2024
82afd94
Drop ts ignore.
wayneseymour May 6, 2024
969bf50
drop unused method
wayneseymour May 6, 2024
dfa29d5
drop assertShortDurationTimeRange
wayneseymour May 6, 2024
bf81eee
Merge branch 'main' of github.com:elastic/kibana into ml-add-job-vali…
wayneseymour May 7, 2024
c5237ca
wrap in retry
wayneseymour May 7, 2024
66488da
Update x-pack/test/functional/services/ml/job_wizard_common.ts
wayneseymour May 8, 2024
a7a75e3
Update x-pack/test/functional/services/ml/job_wizard_common.ts
wayneseymour May 8, 2024
ea3e6dc
final fixups?
wayneseymour May 8, 2024
38a829b
Merge branch 'main' into ml-add-job-validation-ui-tests
kibanamachine May 9, 2024
ac47e74
Merge branch 'main' into ml-add-job-validation-ui-tests
kibanamachine May 10, 2024
ecbd487
Merge branch 'main' into ml-add-job-validation-ui-tests
kibanamachine May 13, 2024
268e403
Merge branch 'main' into ml-add-job-validation-ui-tests
kibanamachine May 15, 2024
60cb125
Merge branch 'main' into ml-add-job-validation-ui-tests
kibanamachine May 16, 2024
b8c45d7
Merge branch 'main' into ml-add-job-validation-ui-tests
kibanamachine May 22, 2024
ab3b025
Merge branch 'main' into ml-add-job-validation-ui-tests
kibanamachine May 23, 2024
afa90d7
Merge branch 'main' into ml-add-job-validation-ui-tests
kibanamachine May 24, 2024
e53e9d9
Update x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_m…
wayneseymour May 24, 2024
a1fe7e4
Update x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_m…
wayneseymour May 24, 2024
0f62a46
Update x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_m…
wayneseymour May 24, 2024
d8edc00
Update x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_m…
wayneseymour May 24, 2024
9d7a2a2
Update x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_m…
wayneseymour May 24, 2024
a0e5557
Update x-pack/test/functional/apps/ml/anomaly_detection_jobs/single_m…
wayneseymour May 24, 2024
4be34ab
Update x-pack/test/functional/services/ml/job_wizard_common.ts
wayneseymour May 24, 2024
820e96c
Update x-pack/test/functional/services/ml/job_wizard_common.ts
wayneseymour May 24, 2024
0355263
Update x-pack/test/functional/services/ml/common_ui.ts
wayneseymour May 24, 2024
dd28646
fixups per cr
wayneseymour May 24, 2024
1ee9dee
Merge branch 'main' into ml-add-job-validation-ui-tests
kibanamachine May 24, 2024
d4bea26
add assertion per cr
wayneseymour May 24, 2024
528d151
Merge branch 'ml-add-job-validation-ui-tests' of github.com:wayneseym…
wayneseymour May 24, 2024
31f5136
Merge branch 'main' into ml-add-job-validation-ui-tests
kibanamachine May 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const Message: FC<Pick<CalloutMessage, 'text' | 'url'>> = ({ text, url }) => (
export const Callout: FC<CalloutMessage> = ({ heading, status, text, url }) => (
<>
<EuiCallOut
data-test-subj={'mlValidationCallout'}
data-test-subj={`mlValidationCallout ${status}`}
// @ts-ignore
color={statusToEuiColor(status)}
size="s"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ export const TimeRangePicker: FC<Props> = ({ setTimeRange, timeRange }) => {
fullWidth={true}
startDateControl={
<EuiDatePicker
popperProps={{
'data-test-subj': 'mlJobWizardDatePickerRangeStartDate',
}}
selected={startMoment}
onChange={handleChangeStart}
startDate={startMoment}
Expand All @@ -86,6 +89,9 @@ export const TimeRangePicker: FC<Props> = ({ setTimeRange, timeRange }) => {
}
endDateControl={
<EuiDatePicker
popperProps={{
'data-test-subj': 'mlJobWizardDatePickerRangeEndDate',
}}
selected={endMoment}
onChange={handleChangeEnd}
startDate={startMoment}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const AnnotationsSwitch: FC = () => {
</Description>
{showCallOut && (
<EuiCallOut
data-test-subj="mlJobWizardAlsoEnableAnnotationsRecommendationCallout"
title={
<FormattedMessage
id="xpack.ml.newJob.wizard.jobDetailsStep.advancedSection.annotationsSwitchCallout.title"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,35 @@ export const WizardHorizontalSteps: FC<Props> = ({
defaultMessage: 'Time range',
}),
...createStepProps(WIZARD_STEPS.TIME_RANGE),
'data-test-subj': 'mlJobWizardTimeRangeStep',
},
{
title: i18n.translate('xpack.ml.newJob.wizard.step.pickFieldsTitle', {
defaultMessage: 'Choose fields',
}),
...createStepProps(WIZARD_STEPS.PICK_FIELDS),
'data-test-subj': 'mlJobWizardPickFieldsStep',
},
{
title: i18n.translate('xpack.ml.newJob.wizard.step.jobDetailsTitle', {
defaultMessage: 'Job details',
}),
...createStepProps(WIZARD_STEPS.JOB_DETAILS),
'data-test-subj': 'mlJobWizardJobDetailsStep',
},
{
title: i18n.translate('xpack.ml.newJob.wizard.step.validationTitle', {
defaultMessage: 'Validation',
}),
...createStepProps(WIZARD_STEPS.VALIDATION),
'data-test-subj': 'mlJobWizardValidationStep',
},
{
title: i18n.translate('xpack.ml.newJob.wizard.step.summaryTitle', {
defaultMessage: 'Summary',
}),
...createStepProps(WIZARD_STEPS.SUMMARY),
'data-test-subj': 'mlJobWizardSummaryStep',
},
];

Expand All @@ -75,6 +80,7 @@ export const WizardHorizontalSteps: FC<Props> = ({
defaultMessage: 'Configure datafeed',
}),
...createStepProps(WIZARD_STEPS.ADVANCED_CONFIGURE_DATAFEED),
'data-test-subj': 'mlJobWizardAdvancedStep',
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,90 @@ export default function ({ getService }: FtrProviderContext) {
);
await ml.api.assertNoJobResultsExist(jobIdClone);
});

it('job cloning with too short of a job creation time range results in validation callouts', async () => {
await ml.testExecution.logTestStep('job cloning loads the job management page');
await ml.navigation.navigateToMl();
await ml.navigation.navigateToJobManagement();

await ml.testExecution.logTestStep(`cloning job: [${jobId}]`);
await ml.jobTable.clickCloneJobAction(jobId);

await ml.testExecution.logTestStep('job cloning displays the time range step');
await ml.jobWizardCommon.assertTimeRangeSectionExists();

await ml.testExecution.logTestStep('job cloning sets the time range');
await ml.jobWizardCommon.clickUseFullDataButton(
'Feb 7, 2016 @ 00:00:00.000',
'Feb 11, 2016 @ 23:59:54.000'
);

await ml.jobWizardCommon.goToTimeRangeStep();

const { startDate: origStartDate } = await ml.jobWizardCommon.getSelectedDateRange();

await ml.testExecution.logTestStep('calculate the new end date');
const shortDurationEndDate: string = `${origStartDate?.split(':', 1)[0]}:01:00.000`;

await ml.testExecution.logTestStep('set the new end date');
await ml.jobWizardCommon.setTimeRange({ endTime: shortDurationEndDate });

// assert time is set as expected
await ml.jobWizardCommon.assertDateRangeSelection(
origStartDate as string,
shortDurationEndDate
);

await ml.jobWizardCommon.advanceToPickFieldsSection();
await ml.jobWizardCommon.advanceToJobDetailsSection();
await ml.jobWizardCommon.assertJobIdInputExists();
await ml.jobWizardCommon.setJobId(`${jobIdClone}-again`);
await ml.jobWizardCommon.advanceToValidationSection();
await ml.jobWizardCommon.assertValidationCallouts([
'mlValidationCallout warning',
'mlValidationCallout error',
]);
await ml.jobWizardCommon.assertCalloutText(
'mlValidationCallout warning',
/Time range\s*The selected or available time range might be too short/
);

await ml.jobWizardCommon.goToTimeRangeStep();
await ml.jobWizardCommon.clickUseFullDataButton(
'Feb 7, 2016 @ 00:00:00.000',
'Feb 11, 2016 @ 23:59:54.000'
);
await ml.jobWizardCommon.goToValidationStep();
await ml.jobWizardCommon.assertValidationCallouts(['mlValidationCallout success']);
await ml.jobWizardCommon.assertCalloutText(
'mlValidationCallout success',
/Time range\s*Valid and long enough to model patterns in the data/
);
});

it('job creation and toggling model change annotation triggers enable annotation recommendation callout', async () => {
await ml.jobWizardCommon.goToJobDetailsStep();
await ml.jobWizardCommon.ensureAdvancedSectionOpen();

await ml.commonUI.toggleSwitchIfNeeded('mlJobWizardSwitchAnnotations', false);
await ml.jobWizardCommon.assertAnnotationRecommendationCalloutVisible();

await ml.commonUI.toggleSwitchIfNeeded('mlJobWizardSwitchAnnotations', true);
await ml.jobWizardCommon.assertAnnotationRecommendationCalloutVisible(false);
});

it('job creation memory limit too large results in validation callout', async () => {
await ml.jobWizardCommon.goToJobDetailsStep();

const tooLarge = '100000000MB';
await ml.jobWizardCommon.setModelMemoryLimit(tooLarge);

await ml.jobWizardCommon.advanceToValidationSection();
await ml.jobWizardCommon.assertValidationCallouts(['mlValidationCallout warning']);
await ml.jobWizardCommon.assertCalloutText(
'mlValidationCallout warning',
/Job will not be able to run in the current cluster because model memory limit is higher than/
);
});
});
}
4 changes: 4 additions & 0 deletions x-pack/test/functional/services/ml/common_ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,5 +447,9 @@ export function MachineLearningCommonUIProvider({
await testSubjects.missingOrFail(selector);
}
},

async toggleSwitchIfNeeded(testSubj: string, targetState: boolean) {
await testSubjects.setEuiSwitch(testSubj, targetState ? 'check' : 'uncheck');
},
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -553,12 +553,12 @@ export function MachineLearningDataFrameAnalyticsCreationProvider(

async assertValidationCalloutsExists() {
await retry.tryForTime(4000, async () => {
await testSubjects.existOrFail('mlValidationCallout');
await testSubjects.existOrFail('~mlValidationCallout');
});
},

async assertAllValidationCalloutsPresent(expectedNumCallouts: number) {
const validationCallouts = await testSubjects.findAll('mlValidationCallout');
const validationCallouts = await testSubjects.findAll('~mlValidationCallout');
expect(validationCallouts.length).to.eql(expectedNumCallouts);
},

Expand Down
74 changes: 74 additions & 0 deletions x-pack/test/functional/services/ml/job_wizard_common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export function MachineLearningJobWizardCommonProvider(
const retry = getService('retry');
const testSubjects = getService('testSubjects');
const headerPage = getPageObject('header');
const browser = getService('browser');

function advancedSectionSelector(subSelector?: string) {
const subj = 'mlJobWizardAdvancedSection';
Expand Down Expand Up @@ -628,5 +629,78 @@ export function MachineLearningJobWizardCommonProvider(
await testSubjects.existOrFail(expectedSelector);
});
},

async assertAnnotationRecommendationCalloutVisible(expectVisible: boolean = true) {
const callOutTestSubj = 'mlJobWizardAlsoEnableAnnotationsRecommendationCallout';
if (expectVisible)
await testSubjects.existOrFail(callOutTestSubj, {
timeout: 3_000,
});
else
await testSubjects.missingOrFail(callOutTestSubj, {
timeout: 3_000,
});
},

async goToTimeRangeStep() {
await retry.tryForTime(60_000, async () => {
await testSubjects.existOrFail('mlJobWizardTimeRangeStep');
await testSubjects.click('mlJobWizardTimeRangeStep');
await this.assertTimeRangeSectionExists();
});
},

async goToValidationStep() {
await retry.tryForTime(60_000, async () => {
await testSubjects.existOrFail('mlJobWizardValidationStep');
await testSubjects.click('mlJobWizardValidationStep');
pheyos marked this conversation as resolved.
Show resolved Hide resolved
await this.assertValidationSectionExists();
});
},

async setTimeRange({ startTime, endTime }: { startTime?: string; endTime?: string }) {
const opts = {
clearWithKeyboard: true,
typeCharByChar: true,
};

if (startTime)
await testSubjects.setValue('mlJobWizardDatePickerRangeStartDate', startTime, opts);
if (endTime) await testSubjects.setValue('mlJobWizardDatePickerRangeEndDate', endTime, opts);

// escape popover
await browser.pressKeys(browser.keys.ESCAPE);
},

async goToJobDetailsStep() {
await testSubjects.existOrFail('mlJobWizardJobDetailsStep', {
timeout: 3_000,
});
await testSubjects.click('mlJobWizardJobDetailsStep');
darnautov marked this conversation as resolved.
Show resolved Hide resolved
await this.assertJobDetailsSectionExists();
},

async assertValidationCallouts(expectedCallOutSelectors: string[]) {
darnautov marked this conversation as resolved.
Show resolved Hide resolved
for await (const sel of expectedCallOutSelectors)
await testSubjects.existOrFail(sel, {
timeout: 3_000,
});
},

async assertCalloutText(calloutStatusTestSubj: string, expectedText: RegExp) {
const allCalloutStatusTexts = await testSubjects.getVisibleTextAll(calloutStatusTestSubj);

const oneCalloutMatches = allCalloutStatusTexts.some(
(visibleText) => !!visibleText.match(expectedText)
);
expect(oneCalloutMatches).to.eql(
true,
`Expect one of the callouts [${calloutStatusTestSubj}] to match [${expectedText}], instead found ${JSON.stringify(
allCalloutStatusTexts,
null,
2
)}`
);
},
};
}