Skip to content

Commit

Permalink
Add recording of tests using ffmpeg
Browse files Browse the repository at this point in the history
Signed-off-by: Radim Hopp <rhopp@redhat.com>
  • Loading branch information
rhopp committed Apr 1, 2020
1 parent db3d588 commit 9d2b189
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion dockerfiles/e2e/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ RUN apt-get update && apt-get install && \
apt-get install -y nodejs && \
apt-get install -y npm && \
npm install -g typescript && \
apt-get install x11vnc -y
apt-get install x11vnc ffmpeg -y

RUN mkdir /tmp/e2e && \
chmod -R 777 /tmp/e2e
Expand Down
18 changes: 18 additions & 0 deletions dockerfiles/e2e/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
#!/bin/bash

EXIT_CODE=0

kill_ffmpeg(){
echo "Killing ffmpeg with PID=$ffmpeg_pid"
kill -2 "$ffmpeg_pid"
wait "$ffmpeg_pid"
mkdir -p /tmp/e2e/report/
cp /tmp/ffmpeg_report/* /tmp/e2e/report/
exit $EXIT_CODE
}

set -x
# Validate selenium base URL
if [ -z "$TS_SELENIUM_BASE_URL" ]; then
echo "The \"TS_SELENIUM_BASE_URL\" is not set!";
Expand Down Expand Up @@ -59,6 +71,10 @@ else
cd /tmp/e2e || exit
fi

mkdir -p /tmp/ffmpeg_report
nohup ffmpeg -y -video_size 1920x1080 -framerate 24 -f x11grab -i :20.0 /tmp/ffmpeg_report/output.mp4 2> /tmp/ffmpeg_report/ffmpeg_err.txt > /tmp/ffmpeg_report/ffmpeg_std.txt &
ffmpeg_pid=$!
trap kill_ffmpeg 2 15

# Launch tests
if [ $TEST_SUITE == "load-test" ]; then
Expand Down Expand Up @@ -86,4 +102,6 @@ End_script
else
echo "Running TEST_SUITE: $TEST_SUITE with user: $TS_SELENIUM_USERNAME"
npm run $TEST_SUITE
EXIT_CODE=$?
fi
kill_ffmpeg
18 changes: 1 addition & 17 deletions tests/.infra/crw-ci/pr-check/k8s/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ pipeline {

stage("Run E2E Happy path tests") {
steps {
sh """
sh """
CHE_URL=http://${cheHost}
docker run --shm-size=1g --net=host --ipc=host \\
-p 5920:5920 \\
Expand All @@ -323,22 +323,6 @@ pipeline {
}

post {
failure {
echo "Create screencast from $WORKSPACE/tests/e2e/report/executionScreencast files."
sh """
command -v ffmpeg >/dev/null 2>&1 && if ls $WORKSPACE/tests/e2e/report/executionScreencast/*.png 1> /dev/null 2>&1; then
cd $WORKSPACE/tests/e2e/report/executionScreencast
# remove first screenshot which has lower resolution 800x600 and breaks screencast video
sudo rm -f 00100001* || true
sudo ffmpeg -framerate 1 -pattern_type glob -i '*.png' -c:v libx264 -r 30 -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -pix_fmt yuv420p $WORKSPACE/tests/e2e/report/screencast.mp4
cd $WORKSPACE/tests/e2e/report/
sudo rm -rf $WORKSPACE/tests/e2e/report/executionScreencast
fi
"""
}

cleanup {
sh """
mkdir -p $LOGS_AND_CONFIGS/kubectl
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/TestConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ export const TestConstants = {
TS_SELENIUM_REPORT_FOLDER: process.env.TS_SELENIUM_REPORT_FOLDER || './report',

/**
* Enable or disable storing of execution screencast, "true" by default.
* Enable or disable storing of execution screencast, "false" by default.
*/
TS_SELENIUM_EXECUTION_SCREENCAST: process.env.TS_SELENIUM_EXECUTION_SCREENCAST !== 'false',
TS_SELENIUM_EXECUTION_SCREENCAST: process.env.TS_SELENIUM_EXECUTION_SCREENCAST === 'true',

/**
* Delete screencast after execution if all tests passed, "true" by default.
Expand Down

0 comments on commit 9d2b189

Please sign in to comment.