Skip to content

Commit

Permalink
update: video folder could not change via env var
Browse files Browse the repository at this point in the history
Signed-off-by: Viet Nguyen Duc <nguyenducviet4496@gmail.com>
  • Loading branch information
VietND96 committed Jun 18, 2024
1 parent fdb3e83 commit 5af1bfe
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 29 deletions.
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ workflows:
name: "K8s test - Autoscaling Deployments"
platforms: linux/arm64
machine-type: ubuntu2204arm64large
k8s-version: 'v1.27.14'
k8s-version: 'v1.27.15'
test-strategy: deployment
cluster: 'minikube'
helm-version: 'v3.12.3'
Expand All @@ -37,7 +37,7 @@ workflows:
name: "K8s test - Autoscaling Jobs - HTTPS"
platforms: linux/arm64
machine-type: ubuntu2204arm64large
k8s-version: 'v1.28.10'
k8s-version: 'v1.28.11'
test-strategy: job_https
cluster: 'minikube'
helm-version: 'v3.13.3'
Expand All @@ -47,7 +47,7 @@ workflows:
name: "K8s test - Autoscaling Jobs - Ingress hostname"
platforms: linux/arm64
machine-type: ubuntu2204arm64large
k8s-version: 'v1.29.5'
k8s-version: 'v1.29.6'
test-strategy: job_hostname
cluster: 'minikube'
helm-version: 'v3.14.4'
Expand All @@ -57,10 +57,10 @@ workflows:
name: "K8s test - Autoscaling Deployments - HTTPS"
platforms: linux/arm64
machine-type: ubuntu2204arm64large
k8s-version: 'v1.30.1'
k8s-version: 'v1.30.2'
test-strategy: deployment_https
cluster: 'minikube'
helm-version: 'v3.15.0'
helm-version: 'v3.15.2'
test-existing-keda: false
test-upgrade: true
- docker-test:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/helm-chart-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,28 @@ jobs:
helm-version: 'v3.11.3'
test-existing-keda: true
test-upgrade: true
- k8s-version: 'v1.27.14'
- k8s-version: 'v1.27.15'
test-strategy: deployment
cluster: 'minikube'
helm-version: 'v3.12.3'
test-existing-keda: true
test-upgrade: true
- k8s-version: 'v1.28.10'
- k8s-version: 'v1.28.11'
test-strategy: job_https
cluster: 'minikube'
helm-version: 'v3.13.3'
test-existing-keda: true
test-upgrade: true
- k8s-version: 'v1.29.5'
- k8s-version: 'v1.29.6'
test-strategy: job_hostname
cluster: 'minikube'
helm-version: 'v3.14.4'
test-existing-keda: false
test-upgrade: true
- k8s-version: 'v1.30.1'
- k8s-version: 'v1.30.2'
test-strategy: deployment_https
cluster: 'minikube'
helm-version: 'v3.15.0'
helm-version: 'v3.15.2'
test-existing-keda: false
test-upgrade: true
env:
Expand Down
15 changes: 8 additions & 7 deletions Video/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ARG SEL_GROUP=${SEL_USER}
ARG SEL_PASSWD=secret
ARG UID=1200
ARG GID=1201
ARG VIDEO_FOLDER=/videos

USER root
#================================================
Expand Down Expand Up @@ -85,13 +86,12 @@ ENV SE_UPLOAD_DESTINATION_PREFIX ""
ENV SE_VIDEO_INTERNAL_UPLOAD false
ENV UPLOAD_OPTS "-P"

ENV SE_VIDEO_FOLDER /videos
RUN mkdir -p /var/run/supervisor /var/log/supervisor $SE_VIDEO_FOLDER \
&& chown -R ${SEL_USER}:${SEL_GROUP} /var/run/supervisor /var/log/supervisor $SE_VIDEO_FOLDER $HOME \
&& chmod -R 775 /var/run/supervisor /var/log/supervisor $SE_VIDEO_FOLDER $HOME \
&& chgrp -R 0 /var/run/supervisor /var/log/supervisor $SE_VIDEO_FOLDER $HOME \
&& chmod -R g=u /var/run/supervisor /var/log/supervisor $SE_VIDEO_FOLDER $HOME \
&& setfacl -Rdm u:${SEL_USER}:rwx,g:${SEL_GROUP}:rwx /var/run/supervisor /var/log/supervisor $SE_VIDEO_FOLDER $HOME
RUN mkdir -p /var/run/supervisor /var/log/supervisor ${VIDEO_FOLDER} \
&& chown -R ${SEL_USER}:${SEL_GROUP} /var/run/supervisor /var/log/supervisor ${VIDEO_FOLDER} $HOME \
&& chmod -R 775 /var/run/supervisor /var/log/supervisor ${VIDEO_FOLDER} $HOME \
&& chgrp -R 0 /var/run/supervisor /var/log/supervisor ${VIDEO_FOLDER} $HOME \
&& chmod -R g=u /var/run/supervisor /var/log/supervisor ${VIDEO_FOLDER} $HOME \
&& setfacl -Rdm u:${SEL_USER}:rwx,g:${SEL_GROUP}:rwx /var/run/supervisor /var/log/supervisor ${VIDEO_FOLDER} $HOME

USER ${SEL_UID}

Expand All @@ -105,6 +105,7 @@ ENV SE_SCREEN_HEIGHT 1020
ENV SE_FRAME_RATE 15
ENV SE_CODEC libx264
ENV SE_PRESET "-preset ultrafast"
ENV VIDEO_FOLDER ${VIDEO_FOLDER}
ENV SE_VIDEO_FILE_NAME video.mp4
ENV SE_VIDEO_FILE_NAME_TRIM_REGEX "[:alnum:]-_"

Expand Down
6 changes: 3 additions & 3 deletions Video/upload.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

SE_VIDEO_FOLDER=${SE_VIDEO_FOLDER:-"/videos"}
VIDEO_FOLDER=${VIDEO_FOLDER}
UPLOAD_CONFIG_DIRECTORY=${UPLOAD_CONFIG_DIRECTORY:-"/opt/bin"}
UPLOAD_CONFIG_FILE_NAME=${UPLOAD_CONFIG_FILE_NAME:-"upload.conf"}
UPLOAD_COMMAND=${UPLOAD_COMMAND:-"copy"}
Expand All @@ -17,8 +17,8 @@ then
FORCE_EXIT_FILE="/tmp/force_exit"
else
# If using external container for uploading, write signal to the video folder
UPLOAD_PIPE_FILE="${SE_VIDEO_FOLDER}/${UPLOAD_PIPE_FILE_NAME}"
FORCE_EXIT_FILE="${SE_VIDEO_FOLDER}/force_exit"
UPLOAD_PIPE_FILE="${VIDEO_FOLDER}/${UPLOAD_PIPE_FILE_NAME}"
FORCE_EXIT_FILE="${VIDEO_FOLDER}/force_exit"
fi

if [ "${UPLOAD_RETAIN_LOCAL_FILE}" = "false" ];
Expand Down
14 changes: 11 additions & 3 deletions Video/video.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ VIDEO_FILE_NAME=${FILE_NAME:-$SE_VIDEO_FILE_NAME}
FRAME_RATE=${FRAME_RATE:-$SE_FRAME_RATE}
CODEC=${CODEC:-$SE_CODEC}
PRESET=${PRESET:-$SE_PRESET}
VIDEO_FOLDER=${SE_VIDEO_FOLDER}
VIDEO_FOLDER=${VIDEO_FOLDER}
VIDEO_UPLOAD_ENABLED=${VIDEO_UPLOAD_ENABLED:-$SE_VIDEO_UPLOAD_ENABLED}
VIDEO_CONFIG_DIRECTORY=${VIDEO_CONFIG_DIRECTORY:-"/opt/bin"}
UPLOAD_DESTINATION_PREFIX=${UPLOAD_DESTINATION_PREFIX:-$SE_UPLOAD_DESTINATION_PREFIX}
Expand All @@ -18,15 +18,23 @@ SE_NODE_PORT=${SE_NODE_PORT:-"5555"}
max_attempts=${SE_VIDEO_WAIT_ATTEMPTS:-50}
process_name="video.recorder"

if [ -d "${VIDEO_FOLDER}" ];
then
echo "$(date +%FT%T%Z) [${process_name}] - Video folder exists: ${VIDEO_FOLDER}"
else
echo "$(date +%FT%T%Z) [${process_name}] - Video folder does not exist: ${VIDEO_FOLDER}. Due to permission, folder name could not be changed via environment variable. Exiting..."
exit 1
fi

if [ "${SE_VIDEO_INTERNAL_UPLOAD}" = "true" ];
then
# If using RCLONE in the same container, write signal to /tmp internally
UPLOAD_PIPE_FILE="/tmp/${UPLOAD_PIPE_FILE_NAME}"
FORCE_EXIT_FILE="/tmp/force_exit"
else
# If using external container for uploading, write signal to the video folder
UPLOAD_PIPE_FILE="${SE_VIDEO_FOLDER}/${UPLOAD_PIPE_FILE_NAME}"
FORCE_EXIT_FILE="${SE_VIDEO_FOLDER}/force_exit"
UPLOAD_PIPE_FILE="${VIDEO_FOLDER}/${UPLOAD_PIPE_FILE_NAME}"
FORCE_EXIT_FILE="${VIDEO_FOLDER}/force_exit"
fi

function create_pipe() {
Expand Down
19 changes: 14 additions & 5 deletions Video/video_graphQLQuery.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ SESSION_ID=$1
GRAPHQL_ENDPOINT=${2:-$SE_NODE_GRID_GRAPHQL_URL}
VIDEO_CAP_NAME=${VIDEO_CAP_NAME:-"se:recordVideo"}
TEST_NAME_CAP=${TEST_NAME_CAP:-"se:name"}
VIDEO_NAME_CAP=${VIDEO_NAME_CAP:-"se:videoName"}
VIDEO_FILE_NAME_TRIM=${SE_VIDEO_FILE_NAME_TRIM_REGEX:-"[:alnum:]-_"}
VIDEO_FILE_NAME_SUFFIX=${SE_VIDEO_FILE_NAME_SUFFIX:-"true"}

Expand All @@ -21,6 +22,7 @@ if [ -n "${GRAPHQL_ENDPOINT}" ]; then

RECORD_VIDEO=$(jq -r '.data.session.capabilities | fromjson | ."'${VIDEO_CAP_NAME}'"' /tmp/graphQL_${SESSION_ID}.json)
TEST_NAME=$(jq -r '.data.session.capabilities | fromjson | ."'${TEST_NAME_CAP}'"' /tmp/graphQL_${SESSION_ID}.json)
VIDEO_NAME=$(jq -r '.data.session.capabilities | fromjson | ."'${VIDEO_NAME_CAP}'"' /tmp/graphQL_${SESSION_ID}.json)
fi

if [ "${RECORD_VIDEO,,}" = "false" ]; then
Expand All @@ -29,14 +31,21 @@ else
RECORD_VIDEO=true
fi

if [ "${TEST_NAME}" != "null" ] && [ -n "${TEST_NAME}" ]; then
if [ "${VIDEO_FILE_NAME_SUFFIX,,}" = "true" ]; then
TEST_NAME="${TEST_NAME}_${SESSION_ID}"
fi
TEST_NAME="$(echo "${TEST_NAME}" | tr ' ' '_' | tr -dc "${VIDEO_FILE_NAME_TRIM}" | cut -c 1-251)"
if [ "${VIDEO_NAME}" != "null" ] && [ -n "${VIDEO_NAME}" ]; then
TEST_NAME="${VIDEO_NAME}"
elif [ "${TEST_NAME}" != "null" ] && [ -n "${TEST_NAME}" ]; then
TEST_NAME="${TEST_NAME}"
else
TEST_NAME=""
fi

if [ -z "${TEST_NAME}" ]; then
TEST_NAME="${SESSION_ID}"
elif [ "${VIDEO_FILE_NAME_SUFFIX,,}" = "true" ]; then
TEST_NAME="${TEST_NAME}_${SESSION_ID}"
fi

TEST_NAME="$(echo "${TEST_NAME}" | tr ' ' '_' | tr -dc "${VIDEO_FILE_NAME_TRIM}" | cut -c 1-251)"

return_array=("${RECORD_VIDEO}" "${TEST_NAME}")
echo "${return_array[@]}"
2 changes: 1 addition & 1 deletion tests/charts/make/chart_setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ kubectl version --client
echo "==============================="

echo "Installing Helm for AMD64 / ARM64"
HELM_VERSION=${HELM_VERSION:-"v3.14.4"}
HELM_VERSION=${HELM_VERSION:-"v3.15.2"}
curl -fsSL -o helm.tar.gz https://get.helm.sh/helm-${HELM_VERSION}-linux-$(dpkg --print-architecture).tar.gz
mkdir -p helm
tar -xf helm.tar.gz --strip-components 1 -C helm
Expand Down

0 comments on commit 5af1bfe

Please sign in to comment.