From c068b77c4c056778077901822cd9fb19ce31eca1 Mon Sep 17 00:00:00 2001 From: Robert Oskamp Date: Mon, 14 Jun 2021 14:55:26 +0200 Subject: [PATCH] [ML] Functional tests - stabilize alerting flyout test (#102030) This PR stabilizes and re-activates the ML alerting flyout test suite. --- x-pack/test/functional/services/ml/alerting.ts | 4 ++-- x-pack/test/functional/services/ml/api.ts | 2 +- .../test/functional_with_es_ssl/apps/ml/alert_flyout.ts | 8 +++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/x-pack/test/functional/services/ml/alerting.ts b/x-pack/test/functional/services/ml/alerting.ts index 327a0e574f0fde..241ffde6f7628e 100644 --- a/x-pack/test/functional/services/ml/alerting.ts +++ b/x-pack/test/functional/services/ml/alerting.ts @@ -94,10 +94,10 @@ export function MachineLearningAlertingProvider( await this.assertPreviewCalloutVisible(); }, - async checkPreview(expectedMessage: string) { + async checkPreview(expectedMessagePattern: RegExp) { await this.clickPreviewButton(); const previewMessage = await testSubjects.getVisibleText('mlAnomalyAlertPreviewMessage'); - expect(previewMessage).to.eql(expectedMessage); + expect(previewMessage).to.match(expectedMessagePattern); }, async assertPreviewCalloutVisible() { diff --git a/x-pack/test/functional/services/ml/api.ts b/x-pack/test/functional/services/ml/api.ts index 9a96b1ec372dc5..317f2dfe605143 100644 --- a/x-pack/test/functional/services/ml/api.ts +++ b/x-pack/test/functional/services/ml/api.ts @@ -541,7 +541,7 @@ export function MachineLearningAPIProvider({ getService }: FtrProviderContext) { }, async waitForDatafeedToNotExist(datafeedId: string) { - await retry.waitForWithTimeout(`'${datafeedId}' to exist`, 5 * 1000, async () => { + await retry.waitForWithTimeout(`'${datafeedId}' to not exist`, 5 * 1000, async () => { if ((await this.datafeedExist(datafeedId)) === false) { return true; } else { diff --git a/x-pack/test/functional_with_es_ssl/apps/ml/alert_flyout.ts b/x-pack/test/functional_with_es_ssl/apps/ml/alert_flyout.ts index 96e6bd4b302bd0..63326448ec1e51 100644 --- a/x-pack/test/functional_with_es_ssl/apps/ml/alert_flyout.ts +++ b/x-pack/test/functional_with_es_ssl/apps/ml/alert_flyout.ts @@ -67,8 +67,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { let testJobId = ''; - // Failing: See https://github.com/elastic/kibana/issues/102012 - describe.skip('anomaly detection alert', function () { + describe('anomaly detection alert', function () { this.tags('ciGroup13'); before(async () => { @@ -93,6 +92,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { }); after(async () => { + await ml.api.deleteAnomalyDetectionJobES(testJobId); await ml.api.cleanMlIndices(); await ml.alerting.cleanAnomalyDetectionRules(); }); @@ -120,7 +120,9 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await ml.alerting.assertPreviewButtonState(false); await ml.alerting.setTestInterval('2y'); await ml.alerting.assertPreviewButtonState(true); - await ml.alerting.checkPreview('Found 13 anomalies in the last 2y.'); + + // don't check the exact number provided by the backend, just make sure it's > 0 + await ml.alerting.checkPreview(/Found [1-9]\d* anomalies in the last 2y/); await ml.testExecution.logTestStep('should create an alert'); await pageObjects.triggersActionsUI.setAlertName('ml-test-alert');