mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[ML] Display warning if clone job fails due to missing data view (#117993)
* [ML] Display warning if clone job fails due to missing data view * [ML] Edits following review Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
703198227b
commit
f440b3b30f
3 changed files with 43 additions and 1 deletions
|
@ -220,9 +220,21 @@ export async function cloneJob(jobId) {
|
|||
]);
|
||||
|
||||
const dataViewNames = await getDataViewNames();
|
||||
const jobIndicesAvailable = dataViewNames.includes(datafeed.indices.join(','));
|
||||
const dataViewTitle = datafeed.indices.join(',');
|
||||
const jobIndicesAvailable = dataViewNames.includes(dataViewTitle);
|
||||
|
||||
if (jobIndicesAvailable === false) {
|
||||
const warningText = i18n.translate(
|
||||
'xpack.ml.jobsList.managementActions.noSourceDataViewForClone',
|
||||
{
|
||||
defaultMessage:
|
||||
'Unable to clone the anomaly detection job {jobId}. No data view exists for index {dataViewTitle}.',
|
||||
values: { jobId, dataViewTitle },
|
||||
}
|
||||
);
|
||||
getToastNotificationService().displayDangerToast(warningText, {
|
||||
'data-test-subj': 'mlCloneJobNoDataViewExistsWarningToast',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context';
|
|||
export default function ({ getService }: FtrProviderContext) {
|
||||
const esArchiver = getService('esArchiver');
|
||||
const ml = getService('ml');
|
||||
const browser = getService('browser');
|
||||
|
||||
const jobId = `fq_single_1_${Date.now()}`;
|
||||
const jobIdClone = `${jobId}_clone`;
|
||||
|
@ -201,7 +202,26 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
await ml.api.assertDetectorResultsExist(jobId, 0);
|
||||
});
|
||||
|
||||
it('job cloning fails in the single metric wizard if a matching data view does not exist', async () => {
|
||||
await ml.testExecution.logTestStep('delete data view used by job');
|
||||
await ml.testResources.deleteIndexPatternByTitle('ft_farequote');
|
||||
|
||||
// Refresh page to ensure page has correct cache of data views
|
||||
await browser.refresh();
|
||||
|
||||
await ml.testExecution.logTestStep(
|
||||
'job cloning clicks the clone action and displays an error toast'
|
||||
);
|
||||
await ml.jobTable.clickCloneJobActionWhenNoDataViewExists(jobId);
|
||||
});
|
||||
|
||||
it('job cloning opens the existing job in the single metric wizard', async () => {
|
||||
await ml.testExecution.logTestStep('recreate data view used by job');
|
||||
await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp');
|
||||
|
||||
// Refresh page to ensure page has correct cache of data views
|
||||
await browser.refresh();
|
||||
|
||||
await ml.testExecution.logTestStep(
|
||||
'job cloning clicks the clone action and loads the single metric wizard'
|
||||
);
|
||||
|
|
|
@ -373,6 +373,16 @@ export function MachineLearningJobTableProvider(
|
|||
await testSubjects.existOrFail('~mlPageJobWizard');
|
||||
}
|
||||
|
||||
public async clickCloneJobActionWhenNoDataViewExists(jobId: string) {
|
||||
await this.ensureJobActionsMenuOpen(jobId);
|
||||
await testSubjects.click('mlActionButtonCloneJob');
|
||||
await this.assertNoDataViewForCloneJobWarningToastExist();
|
||||
}
|
||||
|
||||
public async assertNoDataViewForCloneJobWarningToastExist() {
|
||||
await testSubjects.existOrFail('mlCloneJobNoDataViewExistsWarningToast', { timeout: 5000 });
|
||||
}
|
||||
|
||||
public async clickEditJobAction(jobId: string) {
|
||||
await this.ensureJobActionsMenuOpen(jobId);
|
||||
await testSubjects.click('mlActionButtonEditJob');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue