Skip to content

Commit

Permalink
Merge pull request #401 from zebrunner/#400
Browse files Browse the repository at this point in the history
#400: integrated video recording logging into the appium TASK_LOG
  • Loading branch information
vdelendik authored Jun 4, 2024
2 parents 41758dc + 795d763 commit c92b999
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ ENV LOG_LEVEL=info
ENV LOG_DIR=/tmp/log
ENV TASK_LOG=/tmp/log/appium.log
ENV LOG_FILE=session.log
ENV VIDEO_LOG=/tmp/log/appium-video.log
ENV VIDEO_LOG_FILE=video.log

# iOS envs
ENV WDA_HOST=connector
Expand Down
18 changes: 7 additions & 11 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ share() {
# unique folder to collect all artifacts for uploading
mkdir ${LOG_DIR}/${artifactId}

stop_ffmpeg $artifactId
echo "[info] [Share] Video recording file:"
ls -lah /tmp/${artifactId}.mp4

mv /tmp/${artifactId}.mp4 ${LOG_DIR}/${artifactId}/video.mp4

cp ${TASK_LOG} ${LOG_DIR}/${artifactId}/${LOG_FILE}
# do not move otherwise in global loop we should add extra verification on file presense
> ${TASK_LOG}
Expand All @@ -105,15 +111,9 @@ share() {
> ${WDA_LOG_FILE}
fi

stop_ffmpeg $artifactId
echo "[info] [Share] Video recording file:"
ls -lah /tmp/${artifactId}.mp4

mv /tmp/${artifactId}.mp4 ${LOG_DIR}/${artifactId}/video.mp4

# share all the rest custom reports from LOG_DIR into artifactId subfolder
for file in ${LOG_DIR}/*; do
if [ -f "$file" ] && [ -s "$file" ] && [ "$file" != "${TASK_LOG}" ] && [ "$file" != "${VIDEO_LOG}" ] && [ "$file" != "${WDA_LOG_FILE}" ]; then
if [ -f "$file" ] && [ -s "$file" ] && [ "$file" != "${TASK_LOG}" ] && [ "$file" != "${WDA_LOG_FILE}" ]; then
echo "[info] [Share] Sharing file: $file"
# to avoid extra publishing as launch artifact for driver sessions
mv $file ${LOG_DIR}/${artifactId}/
Expand All @@ -123,10 +123,6 @@ share() {
# register artifactId info to be able to parse by uploader
echo "artifactId=$artifactId" > ${LOG_DIR}/.artifact-$artifactId

# share video log file
cp ${VIDEO_LOG} ${LOG_DIR}/${artifactId}/${VIDEO_LOG_FILE}
> ${VIDEO_LOG}

# remove lock file (for other threads) when artifacts are shared for uploader
rm -f ${LOG_DIR}/.sharing-artifact-$artifactId
# remove lock file (for uploader) when artifacts are shared for uploader
Expand Down
2 changes: 1 addition & 1 deletion files/start-capture-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ echo -n "on" | nc ${BROADCAST_HOST} ${BROADCAST_PORT} -w 0 -v

echo "[info] [CaptureArtifacts] generating video file ${sessionId}.mp4..."
# you can add `-v trace` to enable verbose mode logs
ffmpeg -f mjpeg -r 10 -i tcp://${BROADCAST_HOST}:${BROADCAST_PORT} -vf scale="-2:720" -vcodec libx264 -movflags +frag_keyframe+separate_moof+omit_tfhd_offset+empty_moov ${FFMPEG_OPTS} -y /tmp/${sessionId}.mp4 > ${VIDEO_LOG} 2>&1 &
ffmpeg -f mjpeg -r 10 -i tcp://${BROADCAST_HOST}:${BROADCAST_PORT} -vf scale="-2:720" -vcodec libx264 -movflags +frag_keyframe+separate_moof+omit_tfhd_offset+empty_moov ${FFMPEG_OPTS} -y /tmp/${sessionId}.mp4 &

exit 0

0 comments on commit c92b999

Please sign in to comment.