From 69cfe3ac49113f22d26e1ce2742cfa09aebd5f61 Mon Sep 17 00:00:00 2001 From: Tomasz Ciecierski Date: Wed, 18 Oct 2023 17:15:22 +0200 Subject: [PATCH] [EDR Workflows] Add junit config to osquery cypress tests (#169060) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Patryk KopyciƄski --- .buildkite/pipelines/pull_request/osquery_cypress.yml | 6 ------ .buildkite/scripts/lifecycle/post_command.sh | 1 + .buildkite/scripts/steps/functional/osquery_cypress.sh | 10 +++++++--- .../steps/functional/security_serverless_osquery.sh | 5 ++++- x-pack/plugins/osquery/cypress/cypress.config.ts | 5 +++++ x-pack/plugins/osquery/cypress/reporter_config.json | 10 ++++++++++ .../osquery/cypress/serverless_cypress.config.ts | 5 +++++ 7 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 x-pack/plugins/osquery/cypress/reporter_config.json diff --git a/.buildkite/pipelines/pull_request/osquery_cypress.yml b/.buildkite/pipelines/pull_request/osquery_cypress.yml index 021fbe5f5e679..49ef00aeb8090 100644 --- a/.buildkite/pipelines/pull_request/osquery_cypress.yml +++ b/.buildkite/pipelines/pull_request/osquery_cypress.yml @@ -10,8 +10,6 @@ steps: automatic: - exit_status: '*' limit: 1 - artifact_paths: - - "target/kibana-osquery/**/*" - command: .buildkite/scripts/steps/functional/security_serverless_osquery.sh label: 'Serverless Osquery Cypress Tests' @@ -24,8 +22,6 @@ steps: automatic: - exit_status: '*' limit: 1 - artifact_paths: - - 'target/kibana-osquery/**/*' - command: .buildkite/scripts/steps/functional/osquery_cypress_burn.sh label: 'Osquery Cypress Tests, burning changed specs' @@ -36,5 +32,3 @@ steps: soft_fail: true retry: automatic: false - artifact_paths: - - 'target/kibana-osquery/**/*' \ No newline at end of file diff --git a/.buildkite/scripts/lifecycle/post_command.sh b/.buildkite/scripts/lifecycle/post_command.sh index 01877bedbef8c..eeb7fa0ef410f 100755 --- a/.buildkite/scripts/lifecycle/post_command.sh +++ b/.buildkite/scripts/lifecycle/post_command.sh @@ -14,6 +14,7 @@ if [[ "$IS_TEST_EXECUTION_STEP" == "true" ]]; then buildkite-agent artifact upload 'target/kibana-coverage/functional/**/*' buildkite-agent artifact upload 'target/kibana-*' buildkite-agent artifact upload 'target/kibana-security-solution/**/*.png' + buildkite-agent artifact upload 'target/kibana-osquery/**/*.png' buildkite-agent artifact upload 'target/kibana-fleet/**/*.png' buildkite-agent artifact upload 'target/test-metrics/*' buildkite-agent artifact upload 'target/test-suites-ci-plan.json' diff --git a/.buildkite/scripts/steps/functional/osquery_cypress.sh b/.buildkite/scripts/steps/functional/osquery_cypress.sh index da27c27559a45..e9a74f308fac9 100755 --- a/.buildkite/scripts/steps/functional/osquery_cypress.sh +++ b/.buildkite/scripts/steps/functional/osquery_cypress.sh @@ -2,10 +2,13 @@ set -euo pipefail -source .buildkite/scripts/common/util.sh +source .buildkite/scripts/steps/functional/common.sh source .buildkite/scripts/steps/functional/common_cypress.sh -.buildkite/scripts/bootstrap.sh +# TODO: remove the line below to use build artifacts for tests. +# in addition to remove the line, we will have to expose the kibana install dir into the downloaded build location +# by exporting a var like: +# export KIBANA_INSTALL_DIR=${KIBANA_BUILD_LOCATION} node scripts/build_kibana_platform_plugins.js export JOB=kibana-osquery-cypress @@ -14,4 +17,5 @@ echo "--- Osquery Cypress tests" cd x-pack/plugins/osquery -yarn --cwd x-pack/plugins/osquery cypress:run \ No newline at end of file +set +e +yarn cypress:run; status=$?; yarn junit:merge || :; exit $status diff --git a/.buildkite/scripts/steps/functional/security_serverless_osquery.sh b/.buildkite/scripts/steps/functional/security_serverless_osquery.sh index d631424552fa8..e87251b0710c7 100755 --- a/.buildkite/scripts/steps/functional/security_serverless_osquery.sh +++ b/.buildkite/scripts/steps/functional/security_serverless_osquery.sh @@ -15,4 +15,7 @@ export JOB=kibana-osquery-cypress-serverless echo "--- Security Osquery Serverless Cypress" -yarn --cwd x-pack/plugins/osquery cypress:serverless:run +cd x-pack/plugins/osquery + +set +e +yarn cypress:serverless:run; status=$?; yarn junit:merge || :; exit $status diff --git a/x-pack/plugins/osquery/cypress/cypress.config.ts b/x-pack/plugins/osquery/cypress/cypress.config.ts index 26b1d9b67850d..e3321d7ff6865 100644 --- a/x-pack/plugins/osquery/cypress/cypress.config.ts +++ b/x-pack/plugins/osquery/cypress/cypress.config.ts @@ -20,6 +20,11 @@ const ROLES_YAML_FILE_PATH = path.join( const roleDefinitions = loadYaml(readFileSync(ROLES_YAML_FILE_PATH, 'utf8')) as YamlRoleDefinitions; export default defineCypressConfig({ + reporter: '../../../node_modules/cypress-multi-reporters', + reporterOptions: { + configFile: './cypress/reporter_config.json', + }, + defaultCommandTimeout: 60000, execTimeout: 120000, pageLoadTimeout: 12000, diff --git a/x-pack/plugins/osquery/cypress/reporter_config.json b/x-pack/plugins/osquery/cypress/reporter_config.json new file mode 100644 index 0000000000000..c472bd0bb643e --- /dev/null +++ b/x-pack/plugins/osquery/cypress/reporter_config.json @@ -0,0 +1,10 @@ +{ + "reporterEnabled": "mochawesome, mocha-junit-reporter", + "reporterOptions": { + "html": false, + "json": true, + "mochaFile": "../../../target/kibana-osquery/cypress/results/TEST-osquery-cypress-[hash].xml", + "overwrite": false, + "reportDir": "../../../target/kibana-osquery/cypress/results" + } +} diff --git a/x-pack/plugins/osquery/cypress/serverless_cypress.config.ts b/x-pack/plugins/osquery/cypress/serverless_cypress.config.ts index fff0d4431df52..506204de66aa2 100644 --- a/x-pack/plugins/osquery/cypress/serverless_cypress.config.ts +++ b/x-pack/plugins/osquery/cypress/serverless_cypress.config.ts @@ -10,6 +10,11 @@ import { setupUserDataLoader } from '../../../test_serverless/functional/test_su // eslint-disable-next-line import/no-default-export export default defineCypressConfig({ + reporter: '../../../node_modules/cypress-multi-reporters', + reporterOptions: { + configFile: './cypress/reporter_config.json', + }, + defaultCommandTimeout: 60000, execTimeout: 60000, pageLoadTimeout: 60000,