[APM] fix error count e2e flaky test (#129755)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Cauê Marcondes 2022-04-11 11:19:43 -04:00 committed by GitHub
parent 64910b3122
commit 1bdae99180
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 5 deletions

View file

@ -51,12 +51,14 @@ describe('Rules', () => {
cy.contains('Alerts and rules').click();
cy.contains('Create error count rule').click();
// Check for the existence of this element to make sure the form
// Check for the existence of these elements to make sure the form
// has loaded.
cy.contains('for the last');
cy.contains('Actions');
cy.contains('Save').should('not.be.disabled');
// Save, with no actions
cy.contains('button:not(:disabled)', 'Save').click();
cy.contains('Save').click();
cy.get(confirmModalButtonSelector).click();
cy.contains(`Created rule "${ruleName}`);

View file

@ -6,7 +6,7 @@
*/
/* eslint-disable no-console */
const { times } = require('lodash');
const path = require('path');
const yargs = require('yargs');
const childProcess = require('child_process');
@ -45,6 +45,10 @@ const { argv } = yargs(process.argv.slice(2))
type: 'boolean',
description: 'stop tests after the first failure',
})
.option('times', {
type: 'number',
description: 'Repeat the test n number of times',
})
.help();
const { server, runner, open, grep, bail, kibanaInstallDir } = argv;
@ -63,5 +67,28 @@ const grepArg = grep ? `--grep "${grep}"` : '';
const bailArg = bail ? `--bail` : '';
const cmd = `node ../../../../scripts/${ftrScript} --config ${config} ${grepArg} ${bailArg} --kibana-install-dir '${kibanaInstallDir}'`;
console.log(`Running "${cmd}"`);
childProcess.execSync(cmd, { cwd: e2eDir, stdio: 'inherit' });
function runTests() {
console.log(`Running "${cmd}"`);
childProcess.execSync(cmd, { cwd: e2eDir, stdio: 'inherit' });
}
if (argv.times) {
const runCounter = { succeeded: 0, failed: 0, remaining: argv.times };
let exitStatus = 0;
times(argv.times, () => {
try {
runTests();
runCounter.succeeded++;
} catch (e) {
exitStatus = 1;
runCounter.failed++;
}
runCounter.remaining--;
if (argv.times > 1) {
console.log(runCounter);
}
});
process.exit(exitStatus);
} else {
runTests();
}