diff --git a/.buildkite/scripts/lifecycle/post_command.sh b/.buildkite/scripts/lifecycle/post_command.sh index d0a5837ed5a67..620041151e583 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-security-solution/**/management/**/*.mp4' buildkite-agent artifact upload 'target/kibana-osquery/**/*.png' buildkite-agent artifact upload 'target/kibana-osquery/**/*.mp4' buildkite-agent artifact upload 'target/kibana-fleet/**/*.png' diff --git a/x-pack/plugins/security_solution/public/management/cypress/cypress_base.config.ts b/x-pack/plugins/security_solution/public/management/cypress/cypress_base.config.ts index 2e6023c7690a0..f3b545697d498 100644 --- a/x-pack/plugins/security_solution/public/management/cypress/cypress_base.config.ts +++ b/x-pack/plugins/security_solution/public/management/cypress/cypress_base.config.ts @@ -6,6 +6,7 @@ */ import { merge } from 'lodash'; +import { getVideosForFailedSpecs } from './support/filter_videos'; import { setupToolingLogLevel } from './support/setup_tooling_log_level'; import { createToolingLogger } from '../../../common/endpoint/data_loaders/utils'; import { dataLoaders, dataLoadersForRealEndpoints } from './support/data_loaders'; @@ -35,7 +36,9 @@ export const getCypressBaseConfig = ( screenshotsFolder: '../../../target/kibana-security-solution/public/management/cypress/screenshots', trashAssetsBeforeRuns: false, - video: false, + video: true, + videoCompression: 15, + videosFolder: '../../../target/kibana-security-solution/public/management/cypress/videos', viewportHeight: 900, viewportWidth: 1440, experimentalStudio: true, @@ -84,7 +87,8 @@ export const getCypressBaseConfig = ( // eslint-disable-next-line @typescript-eslint/no-var-requires require('@cypress/grep/src/plugin')(config); - on('after:spec', () => { + on('after:spec', (_, results) => { + getVideosForFailedSpecs(results); createToolingLogger().info( 'Tooling Usage Tracking summary:\n', usageTracker.toSummaryTable() diff --git a/x-pack/plugins/security_solution/public/management/cypress/support/filter_videos.ts b/x-pack/plugins/security_solution/public/management/cypress/support/filter_videos.ts new file mode 100644 index 0000000000000..e7cbbbb59f6c0 --- /dev/null +++ b/x-pack/plugins/security_solution/public/management/cypress/support/filter_videos.ts @@ -0,0 +1,23 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +// eslint-disable-next-line import/no-nodejs-modules +import fs from 'fs'; + +// makes sure we save videos just for failed specs +export const getVideosForFailedSpecs = (results: CypressCommandLine.RunResult) => { + if (results && results.video) { + // Do we have failures for any retry attempts? + const failures = results.tests.some((test) => + test.attempts.some((attempt) => attempt.state === 'failed') + ); + if (!failures) { + // delete the video if the spec passed and no tests retried + fs.unlinkSync(results.video); + } + } +};