Skip to content

Commit

Permalink
[Security Solution][Endpoint][Cypress] Update endpoint cypress config…
Browse files Browse the repository at this point in the history
… to include videos (elastic#170499)

## Summary

Adds videos to failed cypress tests for debugging.

(cherry picked from commit 1c25217)

# Conflicts:
#	.buildkite/scripts/lifecycle/post_command.sh
#	x-pack/plugins/security_solution/public/management/cypress/cypress_base.config.ts
  • Loading branch information
ashokaditya committed Nov 8, 2023
1 parent 809bffa commit c884617
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions .buildkite/scripts/lifecycle/post_command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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-fleet/**/*.png'
buildkite-agent artifact upload 'target/test-metrics/*'
buildkite-agent artifact upload 'target/test-suites-ci-plan.json'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import { merge } from 'lodash';
import { getVideosForFailedSpecs } from './support/filter_videos';
import { dataLoaders, dataLoadersForRealEndpoints } from './support/data_loaders';
import { responseActionTasks } from './support/response_actions';

Expand All @@ -31,7 +32,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,
Expand Down Expand Up @@ -71,6 +74,10 @@ export const getCypressBaseConfig = (
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('@cypress/grep/src/plugin')(config);

on('after:spec', (_, results) => {
getVideosForFailedSpecs(results);
});

return config;
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
};

0 comments on commit c884617

Please sign in to comment.