Skip to content
This repository was archived by the owner on Jun 30, 2021. It is now read-only.

Commit 6b3e6f5

Browse files
committed
Video stopping resilience from Zalenium side
1 parent 61ebda8 commit 6b3e6f5

File tree

5 files changed

+59
-19
lines changed

5 files changed

+59
-19
lines changed

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,34 @@ Note image ids also change after scm-source.json has being updated which trigger
77
###### To get container versions
88
docker exec grid versions
99

10+
## TBD_DOCKER_TAG
11+
+ **Changes:** https://github.com/elgalu/docker-selenium/compare/TBD_PREV_COMM...TBD_CUR_COMM (TBD_DATE)
12+
+ Improve stop-video functionality via VIDEO_TMP_FILE_EXTENSION & others
13+
+ Avoid wait video shutdown from halting in Zalenium / in general
14+
+ Improve video stopping workflow by grabbing mkv and converting to mp4 after that
15+
+ Video stopping resilience from Zalenium side from version >= 3.3.1
16+
+ **Image tag details:**
17+
+ Selenium 2: TBD_SELENIUM_2_VERSION (TBD_SELENIUM_2_REVISION)
18+
+ Selenium 3: 3.2.0 (8c03df6)
19+
+ Chrome stable: TBD_CHROME_STABLE
20+
+ Firefox for Selenium 2: TBD_FIREFOX_FOR_SEL2
21+
+ Firefox for Selenium 3: TBD_FIREFOX_FOR_SEL3
22+
+ Geckodriver: TBD_GECKO_DRIVER
23+
+ Chromedriver: TBD_CHROME_DRIVER (TBD_CHROMEDRIVER_COMMIT)
24+
+ Java: TBD_JAVA_VENDOR Java TBD_JAVA_BUILD
25+
+ Timezone: TBD_TIME_ZONE
26+
+ FROM ubuntu:UBUNTU_FLAVOR-UBUNTU_DATE
27+
+ Python: TBD_PYTHON_VERSION
28+
+ Tested on kernel dev host: 4.4.0-70-generic x86_64
29+
+ Tested on kernel CI host: TBD_HOST_UNAME
30+
+ Built at dev host with: Docker version 17.03.1-ce, build c6d412e
31+
+ Built at CI host with: Docker version TBD_DOCKER_VERS, build TBD_DOCKER_BUILD
32+
+ Built at dev host with: Docker Compose version 1.11.2, build dfed245
33+
+ Built at CI host with: Docker Compose version TBD_DOCKER_COMPOSE_VERS, build TBD_DOCKER_COMPOSE_BUILD
34+
+ Image size: TBD_IMAGE_SIZE
35+
+ Digest: TBD_DIGEST
36+
+ Image ID: TBD_IMAGE_ID
37+
1038
## 3.2.0-p3
1139
+ **Changes:** https://github.com/elgalu/docker-selenium/compare/TBD_PREV_COMM...TBD_CUR_COMM (2017-03-21)
1240
+ Enable MP4Box as it was incorrectly targeting the files

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ For pull requests or local commits:
1212

1313
For repository owners only:
1414

15-
git commit -m "Enable MP4Box as it was incorrectly targeting the files"
15+
git commit -m "Video stopping resilience from Zalenium side"
1616
git tag -d latest && git tag `cat VERSION` && git push origin tmp-`cat VERSION` && git push --tags
1717

1818
-- Wait for Travis to pass OK

Dockerfile

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -864,29 +864,30 @@ ENV FIREFOX_VERSION="${FF_VER}" \
864864
LOGFILE_MAXBYTES=10MB \
865865
LOGFILE_BACKUPS=5 \
866866
LOGS_DIR="/var/log/cont" \
867-
FFMPEG_FRAME_RATE=10 \
868-
FFMPEG_CODEC_ARGS="-crf 0 -preset ultrafast -qp 0" \
869-
FFMPEG_FINAL_CRF=0 \
870867
VIDEO="false" \
871868
GRID="true" \
872869
CHROME="true" \
873870
FIREFOX="true" \
874871
RC_CHROME="false" \
875872
RC_FIREFOX="false" \
873+
FFMPEG_FRAME_RATE=10 \
874+
FFMPEG_CODEC_ARGS="-crf 0 -preset ultrafast -qp 0" \
875+
FFMPEG_FINAL_CRF=0 \
876876
VIDEO_TMP_FILE_EXTENSION="mkv" \
877877
VIDEO_FILE_EXTENSION="mp4" \
878878
MP4_INTERLEAVES_MEDIA_DATA_CHUNKS_SECS="500" \
879879
VIDEO_FILE_NAME="" \
880-
VIDEO_BEFORE_STOP_SLEEP_SECS="0" \
881-
VIDEO_AFTER_STOP_SLEEP_SECS="0" \
882-
VIDEO_MP4_FIX_MAX_WAIT="3s" \
880+
VIDEO_BEFORE_STOP_SLEEP_SECS="1" \
881+
VIDEO_AFTER_STOP_SLEEP_SECS="0.5" \
882+
VIDEO_STOPWAITSECS="50" \
883+
VIDEO_CONVERSION_MAX_WAIT="20s" \
884+
VIDEO_MP4_FIX_MAX_WAIT="8s" \
883885
VIDEO_WAIT_VID_TOOL_PID_1st_sig_UP_TO_SECS="6s" \
884886
VIDEO_WAIT_VID_TOOL_PID_2nd_sig_UP_TO_SECS="2s" \
885887
VIDEO_WAIT_VID_TOOL_PID_3rd_sig_UP_TO_SECS="1s" \
886-
VIDEO_STOP_1st_sig_TYPE="SIGINT" \
887-
VIDEO_STOP_2nd_sig_TYPE="SIGTERM" \
888+
VIDEO_STOP_1st_sig_TYPE="SIGTERM" \
889+
VIDEO_STOP_2nd_sig_TYPE="SIGINT" \
888890
VIDEO_STOP_3rd_sig_TYPE="SIGKILL" \
889-
VIDEO_STOPWAITSECS=20 \
890891
WAIT_TIME_OUT_VIDEO_STOP="20s" \
891892
VIDEOS_DIR="/home/seluser/videos" \
892893
XMANAGER="fluxbox" \

video-rec/bin/fix_videos.sh

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,21 @@ sudo chown ${HOST_UID}:${HOST_GID} "${tmp_video_path}"* || true
4646

4747
if [ "${VIDEO_TMP_FILE_EXTENSION}" != "${VIDEO_FILE_EXTENSION}" ]; then
4848
log "Changing video encoding from ${VIDEO_TMP_FILE_EXTENSION} to ${VIDEO_FILE_EXTENSION}..."
49-
# ffmpeg -i ${tmp_video_path} -vcodec libx264 -crf ${FFMPEG_FINAL_CRF} ${final_video_path}
50-
ffmpeg -i ${tmp_video_path} ${final_video_path}
51-
log "Conversion from ${VIDEO_TMP_FILE_EXTENSION} to ${VIDEO_FILE_EXTENSION} completed, cleaning up ${tmp_video_path} ..."
52-
rm -f "${tmp_video_path}"
49+
50+
# TODO: Move this mkv to mp4 conversion to a post-processing Zalenium thread
51+
# ffmpeg -i ${tmp_video_path} ${final_video_path}
52+
if timeout --foreground "${VIDEO_CONVERSION_MAX_WAIT}" \
53+
ffmpeg -i ${tmp_video_path} -vcodec libx264 ${FFMPEG_CODEC_ARGS} ${final_video_path}; \
54+
then
55+
log "Conversion from ${VIDEO_TMP_FILE_EXTENSION} to ${VIDEO_FILE_EXTENSION} succeeded!"
56+
log "Cleaning up ${tmp_video_path} ..."
57+
rm -f "${tmp_video_path}"
58+
else
59+
log "Conversion from ${VIDEO_TMP_FILE_EXTENSION} to ${VIDEO_FILE_EXTENSION} FAILED! in within the ${VIDEO_CONVERSION_MAX_WAIT}"
60+
rm -f "${final_video_path}"
61+
mv "${tmp_video_path}" "${final_video_path}"
62+
fi
63+
5364
fi
5465

5566
if [ "${VIDEO_FILE_EXTENSION}" == "mp4" ]; then

video-rec/bin/start-video-rec.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ function shutdown {
5555
local __2nd_sig="${VIDEO_STOP_2nd_sig_TYPE}"
5656
local __3rd_sig="${VIDEO_STOP_3rd_sig_TYPE}"
5757

58-
kill -${__1st_sig} ${VID_TOOL_PID} || log "Failed on kill -${__1st_sig} VID_TOOL_PID=${VID_TOOL_PID}"
59-
# killall -${__1st_sig} ffmpeg || log "Failed on killall -${__1st_sig} ffmpeg"
6058
sleep ${VIDEO_BEFORE_STOP_SLEEP_SECS}
59+
kill -${__1st_sig} ${VID_TOOL_PID} || log "Tried to kill -${__1st_sig} VID_TOOL_PID=${VID_TOOL_PID}"
60+
# killall -${__1st_sig} ffmpeg || log "Tried to killall -${__1st_sig} ffmpeg"
6161

6262
local __secs=${VIDEO_WAIT_VID_TOOL_PID_1st_sig_UP_TO_SECS}
6363
log "Waiting up to ${__secs} for VID_TOOL_PID=${VID_TOOL_PID} to end with ${__1st_sig}..."
@@ -68,7 +68,7 @@ function shutdown {
6868
log "Failed VID_TOOL_PID=${VID_TOOL_PID} took longer than ${__secs} ! will try to kill it again..."
6969

7070
local __secs=${VIDEO_WAIT_VID_TOOL_PID_2nd_sig_UP_TO_SECS}
71-
kill -${__2nd_sig} ${VID_TOOL_PID} || log "Failed (2nd) on kill -${__2nd_sig} VID_TOOL_PID=${VID_TOOL_PID}"
71+
kill -${__2nd_sig} ${VID_TOOL_PID} || log "Tried tond) on kill -${__2nd_sig} VID_TOOL_PID=${VID_TOOL_PID}"
7272
log "Waiting (again) up to ${__secs} for VID_TOOL_PID=${VID_TOOL_PID} to end with ${__2nd_sig}..."
7373
if timeout --foreground "${__secs}" \
7474
wait_pid ${VID_TOOL_PID}; then
@@ -77,13 +77,13 @@ function shutdown {
7777
log "Failed (3rd) VID_TOOL_PID=${VID_TOOL_PID} took longer than ${__secs} ! will try to kill it again..."
7878

7979
local __secs=${VIDEO_WAIT_VID_TOOL_PID_3rd_sig_UP_TO_SECS}
80-
kill -${__3rd_sig} ${VID_TOOL_PID} || log "Failed (4th) on kill -${__3rd_sig} VID_TOOL_PID=${VID_TOOL_PID}"
80+
kill -${__3rd_sig} ${VID_TOOL_PID} || log "Tried toth) on kill -${__3rd_sig} VID_TOOL_PID=${VID_TOOL_PID}"
8181
if timeout --foreground "${__secs}" \
8282
wait_pid ${VID_TOOL_PID}; then
8383
log "wait_pid (4th) successfully managed to ${__3rd_sig}:VID_TOOL_PID=${VID_TOOL_PID} within less than ${__secs}"
8484
else
8585
log "Failed (4th) VID_TOOL_PID=${VID_TOOL_PID} took longer than ${__secs} ! will try to kill it again..."
86-
kill -9 ${VID_TOOL_PID} || log "Failed (4th) on kill -9 VID_TOOL_PID=${VID_TOOL_PID}"
86+
kill -9 ${VID_TOOL_PID} || log "Tried toth) on kill -9 VID_TOOL_PID=${VID_TOOL_PID}"
8787
fi
8888
fi
8989
fi

0 commit comments

Comments
 (0)