-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[SIEM] Cypress preparation for Jenkins #59013
[SIEM] Cypress preparation for Jenkins #59013
Conversation
Pinging @elastic/siem (Team:SIEM) |
@elasticmachine merge upstream |
const spawn = require('child_process').spawn; | ||
/* eslint-disable no-process-exit */ | ||
const MUST_RUN_FROM_DIR = 'kibana'; | ||
const OUTPUT_FILE = `target/loop-cypress-tests.txt`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the target
directory does not exist, the script fails with the following error:
➜ kibana git:(cypress-jenkins-preparation) node x-pack/legacy/plugins/siem/scripts/loop_cypress_tests.js 1
Cypress tests will be run 1 times
Test output will be appended to 'target/loop-cypress-tests.txt'
*** Starting test run 1 of 1 on host tizelastic.local at Mon Mar 02 2020 11:31:59 GMT-0700 (Mountain Standard Time) ***
(node:55574) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'target/loop-cypress-tests.txt'
at Object.openSync (fs.js:443:3)
at Object.writeFileSync (fs.js:1194:35)
at Object.appendFileSync (fs.js:1240:6)
at runNTimes (/Users/abgoldst/Projects/forks/MadameSheema/kibana/x-pack/legacy/plugins/siem/scripts/loop_cypress_tests.js:62:8)
Consider changing:
const OUTPUT_FILE = `target/loop-cypress-tests.txt`;
to:
const OUTPUT_DIR = 'target';
const OUTPUT_FILE = `${OUTPUT_DIR}/loop-cypress-tests.txt`;
const createOutputDir = () => {
fs.mkdir(OUTPUT_DIR, { recursive: true }, err => {
if (err) throw err;
});
};
...and invoking the new createOutputDir
function just before invoking runNTimes(timesToRun)
, i.e. the following:
createOutputDir();
runNTimes(timesToRun);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done :)
@@ -8,7 +8,8 @@ | |||
"extract-mitre-attacks": "node scripts/extract_tactics_techniques_mitre.js & node ../../../../scripts/eslint ./public/pages/detection_engine/mitre/mitre_tactics_techniques.ts --fix", | |||
"build-graphql-types": "node scripts/generate_types_from_graphql.js", | |||
"cypress:open": "../../../node_modules/.bin/cypress open", | |||
"cypress:run": "../../../node_modules/.bin/cypress run --spec ./cypress/integration/**/*.spec.ts --reporter ../../../node_modules/cypress-multi-reporters --reporter-options configFile=./reporter_config.json; status=$?; ../../../node_modules/.bin/mochawesome-merge --reportDir ../../../../target/kibana-siem/cypress/results > ../../../../target/kibana-siem/cypress/results/output.json; ../../../../node_modules/.bin/marge ../../../../target/kibana-siem/cypress/results/output.json --reportDir ../../../../target/kibana-siem/cypress/results; mkdir -p ../../../../target/junit && cp ../../../../target/kibana-siem/cypress/results/*.xml ../../../../target/junit/ && exit $status;" | |||
"cypress:run": "../../../node_modules/.bin/cypress run --spec ./cypress/integration/**/*.spec.ts --reporter ../../../node_modules/cypress-multi-reporters --reporter-options configFile=./reporter_config.json; status=$?; ../../../node_modules/.bin/mochawesome-merge --reportDir ../../../../target/kibana-siem/cypress/results > ../../../../target/kibana-siem/cypress/results/output.json; ../../../../node_modules/.bin/marge ../../../../target/kibana-siem/cypress/results/output.json --reportDir ../../../../target/kibana-siem/cypress/results; mkdir -p ../../../../target/junit && cp ../../../../target/kibana-siem/cypress/results/*.xml ../../../../target/junit/ && exit $status;", | |||
"cypress:run-as-ci": "node ../../../../scripts/functional_tests --config ../../../test/siem_cypress/config.ts" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for adding this!
@elasticmachine merge upstream |
cy.get(DATE_PICKER_ABSOLUTE_INPUT).type(`{selectall}{backspace}${date}{enter}`); | ||
cy.get(DATE_PICKER_ABSOLUTE_INPUT).click({ force: true }); | ||
cy.get(DATE_PICKER_ABSOLUTE_INPUT).then($el => { | ||
// @ts-ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appreciate this integration with esarchiver
@MadameSheema! 🙏
The new yarn cypress:run-as-ci
command and loop_cypress_tests
are both ✅ ✅ locally
LGTM 🚀
* updates events viewer test * updates login tasks * updates ml conditional links * updates url state * updates timeline screen * updates timeline tasks * updates test files * adds jenkins needed files * ignoring isAttached lines due to a known error in Cypress (cypress-io/cypress#4408) * updates loop script * updates readme with new cypress command explanation * removes skip Co-authored-by: Elastic Machine <[email protected]>
Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync. |
* updates events viewer test * updates login tasks * updates ml conditional links * updates url state * updates timeline screen * updates timeline tasks * updates test files * adds jenkins needed files * ignoring isAttached lines due to a known error in Cypress (cypress-io/cypress#4408) * updates loop script * updates readme with new cypress command explanation * removes skip Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
Summary
Prepares SIEM cypress tests to be executed in Jenkins.