Skip to content

Commit

Permalink
[ML] Functional tests - stabilize alerting flyout test (elastic#102030)
Browse files Browse the repository at this point in the history
This PR stabilizes and re-activates the ML alerting flyout test suite.
  • Loading branch information
pheyos authored and John Dorlus committed Jun 15, 2021
1 parent cc3a989 commit a54419c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions x-pack/test/functional/services/ml/alerting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/functional/services/ml/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 5 additions & 3 deletions x-pack/test/functional_with_es_ssl/apps/ml/alert_flyout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -93,6 +92,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
});

after(async () => {
await ml.api.deleteAnomalyDetectionJobES(testJobId);
await ml.api.cleanMlIndices();
await ml.alerting.cleanAnomalyDetectionRules();
});
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit a54419c

Please sign in to comment.