Skip to content
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

Merged
merged 16 commits into from
Mar 3, 2020

Conversation

MadameSheema
Copy link
Member

Summary

Prepares SIEM cypress tests to be executed in Jenkins.

@MadameSheema MadameSheema self-assigned this Mar 2, 2020
@MadameSheema MadameSheema added release_note:skip Skip the PR/issue when compiling release notes Team:SIEM v7.7.0 v8.0.0 labels Mar 2, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/siem (Team:SIEM)

@MadameSheema
Copy link
Member Author

@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`;
Copy link
Contributor

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);

Copy link
Member Author

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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for adding this!

@MadameSheema
Copy link
Member Author

@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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@andrew-goldstein andrew-goldstein left a 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 🚀

@MadameSheema MadameSheema merged commit 02f89f0 into elastic:master Mar 3, 2020
@MadameSheema MadameSheema deleted the cypress-jenkins-preparation branch March 3, 2020 16:52
MadameSheema added a commit to MadameSheema/kibana that referenced this pull request Mar 3, 2020
* 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]>
@kibanamachine
Copy link
Contributor

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.

@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Mar 4, 2020
MadameSheema added a commit that referenced this pull request Mar 4, 2020
* 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]>
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Mar 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes Team:SIEM v7.7.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants