Take control over your live stream video by running it yourself. Streaming + chat out of the box.
HTML activitypubbroadcastingchatdecentralizedfederationfediversegolanghacktoberfesthlslivelivestreamowncastrtmpself-hostedstreaming-videovideo
Fix HLS automatic test (#2572)
Meisamde9f8995245d
diff --git a/.github/workflows/automated-end-to-end-api.yaml b/.github/workflows/automated-end-to-end-api.yamlindex 53a8ac0b21..b723da7a0d 100644--- a/.github/workflows/automated-end-to-end-api.yaml+++ b/.github/workflows/automated-end-to-end-api.yaml@@ -3,12 +3,9 @@ name: Automated API testson:push:paths-ignore:- - 'webroot/**'- 'web/**'-pull_request:paths-ignore:- - 'webroot/**'- 'web/**'jobs:diff --git a/.github/workflows/browser-testing.yml b/.github/workflows/browser-testing.ymlindex 0f65a57b78..ad54865bb5 100644--- a/.github/workflows/browser-testing.yml+++ b/.github/workflows/browser-testing.yml@@ -3,10 +3,12 @@ name: Browser Testson:push:paths:- - web/**- pull_request_target:+ - 'web/**'+ - 'test/automated/browser/**'+ pull_request:paths:- - web/**+ - 'web/**'+ - 'test/automated/browser/**'jobs:cypress-run:runs-on: ubuntu-latestdiff --git a/.github/workflows/go-lint.yml b/.github/workflows/go-lint.ymlindex 80f9ce41d4..124f773efe 100644--- a/.github/workflows/go-lint.yml+++ b/.github/workflows/go-lint.yml@@ -2,12 +2,9 @@ name: Linton:push:paths-ignore:- - 'webroot/**'- 'web/**'-pull_request:paths-ignore:- - 'webroot/**'- 'web/**'permissions:diff --git a/test/automated/api/run.sh b/test/automated/api/run.shindex 716c9bdb5f..bf775e1307 100755--- a/test/automated/api/run.sh+++ b/test/automated/api/run.sh@@ -1,37 +1,17 @@#!/bin/bash-source ../tools.sh+set -e-TEMP_DB=$(mktemp)+source ../tools.sh# Install the node test frameworknpm install --quiet --no-progress-ffmpegInstall--pushd ../../.. >/dev/null || exit--# Build and run owncast from source-go build -o owncast main.go-./owncast -database "$TEMP_DB" &-SERVER_PID=$!--popd >/dev/null || exit-sleep 5--# Start streaming the test file over RTMP to-# the local owncast instance.-../../ocTestStream.sh &-FFMPEG_PID=$!+install_ffmpeg-function finish {- kill $SERVER_PID $FFMPEG_PID- rm -fr "$TEMP_DB" "$FFMPEG_PATH"-}-trap finish EXIT+start_owncast-echo "Waiting..."-sleep 15+start_stream# Run the tests against the instance.npm testdiff --git a/test/automated/browser/run.sh b/test/automated/browser/run.shindex 249a3c6281..662ae961c7 100755--- a/test/automated/browser/run.sh+++ b/test/automated/browser/run.sh@@ -5,7 +5,6 @@ set -o pipefailsource ../tools.sh-TEMP_DB=$(mktemp)BUILD_ID=$((RANDOM % 7200 + 600))BROWSER="electron" # Default. Will try to use Google Chrome.@@ -16,61 +15,43 @@ elseecho "Google Chrome not found. Using Electron."fi-# Change to the root directory of the repository-pushd "$(git rev-parse --show-toplevel)"# Bundle the updated web code into the server codebase.if [ -z "$SKIP_BUILD" ]; thenecho "Bundling web code into server..."++ # Change to the root directory of the repository+ pushd "$(git rev-parse --show-toplevel)"+./build/web/bundleWeb.sh >/dev/null++ popdelseecho "Skipping web build..."fi+# Install the web test frameworkif [ -z "$SKIP_BUILD" ]; thenecho "Installing test dependencies..."- pushd test/automated/browsernpm install --quiet --no-progress- popdelseecho "Skipping dependencies installation"fiset -o nounset-ffmpegInstall--# Build and run owncast from source-echo "Building owncast..."-go build -o owncast main.go--echo "Running owncast..."-./owncast -database "$TEMP_DB" &-SERVER_PID=$!+install_ffmpeg-pushd test/automated/browser+start_owncast# Run cypress browser tests for desktopnpx cypress run --browser "$BROWSER" --group "desktop-offline" --env tags=desktop --ci-build-id $BUILD_ID --tag "desktop,offline" --record --key e9c8b547-7a8f-452d-8c53-fd7531491e3b --spec "cypress/e2e/offline/*.cy.js"# Run cypress browser tests for mobilenpx cypress run --browser "$BROWSER" --group "mobile-offline" --ci-build-id $BUILD_ID --tag "mobile,offline" --record --key e9c8b547-7a8f-452d-8c53-fd7531491e3b --spec "cypress/e2e/offline/*.cy.js" --config viewportWidth=375,viewportHeight=667-# Start streaming the test file over RTMP to-# the local owncast instance.-echo "Waiting for stream to start..."-../../ocTestStream.sh &-STREAMING_CLIENT=$!--function finish {- echo "Cleaning up..."- kill $SERVER_PID $STREAMING_CLIENT- rm -fr "$TEMP_DB" "$FFMPEG_PATH"-}-trap finish EXIT SIGHUP SIGINT SIGTERM SIGQUIT SIGABRT SIGTERM--sleep 20+start_stream# Run cypress browser tests for desktopnpx cypress run --browser "$BROWSER" --group "desktop-online" --env tags=desktop --ci-build-id $BUILD_ID --tag "desktop,online" --record --key e9c8b547-7a8f-452d-8c53-fd7531491e3b --spec "cypress/e2e/online/*.cy.js"diff --git a/test/automated/hls/run.sh b/test/automated/hls/run.shindex 639ed2be0f..9cccebd9af 100755--- a/test/automated/hls/run.sh+++ b/test/automated/hls/run.sh@@ -4,71 +4,31 @@ set -esource ../tools.sh-function update_storage_config() {- echo "Configuring external storage to use ${S3_BUCKET}..."-- # Hard coded to admin:abc123 for auth- curl 'http://localhost:8080/api/admin/config/s3' \- -H 'Authorization: Basic YWRtaW46YWJjMTIz' \- --data-raw "{\"value\":{\"accessKey\":\"${S3_ACCESS_KEY}\",\"acl\":\"\",\"bucket\":\"${S3_BUCKET}\",\"enabled\":true,\"endpoint\":\"${S3_ENDPOINT}\",\"region\":\"${S3_REGION}\",\"secret\":\"${S3_SECRET}\",\"servingEndpoint\":\"\"}}"-}--TEMP_DB=$(mktemp)-# Install the node test frameworknpm install --silent >/dev/null-ffmpegInstall--pushd ../../.. >/dev/null--# Build and run owncast from source-go build -o owncast main.go-./owncast -database "$TEMP_DB" &-SERVER_PID=$!--popd >/dev/null-sleep 5+install_ffmpeg-# Start the stream.-../../ocTestStream.sh &-STREAMING_CLIENT=$!+start_owncast-function finish {- echo "Cleaning up..."- kill $SERVER_PID $STREAMING_CLIENT- rm -fr "$TEMP_DB" "$FFMPEG_PATH"-}-trap finish EXIT--echo "Waiting..."-sleep 13+start_stream# Run tests against a fresh install with no settings.npm test-# REMOVE this ONCE #2571 IS FIXED-exit 0+# Kill the stream.+kill_with_kids "$STREAM_PID"# Determine if we should continue testing with S3 configuration.if [[ -z "${S3_BUCKET}" ]]; then- echo "No S3 configuration set"+ echo "No S3 configuration is set. Skipping S3 tests!"exit 0fi-# Kill the stream.-kill $STREAMING_CLIENT-sleep 5-# Update the server config to use S3 for storage.update_storage_config-# start the stream.-../../ocTestStream.sh &-STREAMING_CLIENT=$!--echo "Waiting..."-sleep 13+start_stream# Re-run the HLS test against the external storage configuration.npm testdiff --git a/test/automated/tools.sh b/test/automated/tools.shindex da4ee26d22..bcfe253889 100755--- a/test/automated/tools.sh+++ b/test/automated/tools.sh@@ -1,22 +1,26 @@#!/bin/bash-ffmpegInstall(){+set -e++function install_ffmpeg() {# install a specific version of ffmpegFFMPEG_VER="4.4.1"FFMPEG_PATH="$(pwd)/ffmpeg-$FFMPEG_VER"+ PATH=$FFMPEG_PATH:$PATHif ! [[ -d "$FFMPEG_PATH" ]]; thenmkdir "$FFMPEG_PATH"fi- pushd "$FFMPEG_PATH" >/dev/null || exit+ pushd "$FFMPEG_PATH" >/dev/nullif [[ -x "$FFMPEG_PATH/ffmpeg" ]]; thenffmpeg_version=$("$FFMPEG_PATH/ffmpeg" -version | awk -F 'ffmpeg version' '{print $2}' | awk 'NR==1{print $1}')if [[ "$ffmpeg_version" == "$FFMPEG_VER-static" ]]; then+ popd >/dev/nullreturn 0elsemv "$FFMPEG_PATH/ffmpeg" "$FFMPEG_PATH/ffmpeg.bk" || rm -f "$FFMPEG_PATH/ffmpeg"@@ -29,5 +33,64 @@ ffmpegInstall(){chmod +x ffmpegPATH=$FFMPEG_PATH:$PATH- popd >/dev/null || exit-}\ No newline at end of file+ popd >/dev/null+}++function start_owncast() {+ # Build and run owncast from source+ echo "Building owncast..."+ pushd "$(git rev-parse --show-toplevel)" >/dev/null+ go build -o owncast main.go++ echo "Running owncast..."+ ./owncast -database "$TEMP_DB" &+ SERVER_PID=$!+ popd >/dev/null++ sleep 5++}++function start_stream() {+ # Start streaming the test file over RTMP to the local owncast instance.+ ../../ocTestStream.sh &+ STREAM_PID=$!++ echo "Waiting for stream to start..."+ sleep 12+}++function update_storage_config() {+ echo "Configuring external storage to use ${S3_BUCKET}..."++ # Hard-coded to admin:abc123 for auth+ curl --fail 'http://localhost:8080/api/admin/config/s3' \+ -H 'Authorization: Basic YWRtaW46YWJjMTIz' \+ --data-raw "{\"value\":{\"accessKey\":\"${S3_ACCESS_KEY}\",\"acl\":\"\",\"bucket\":\"${S3_BUCKET}\",\"enabled\":true,\"endpoint\":\"${S3_ENDPOINT}\",\"region\":\"${S3_REGION}\",\"secret\":\"${S3_SECRET}\",\"servingEndpoint\":\"\"}}"+}++function kill_with_kids() {+ # kill a process and all its children (by pid)! return no error.++ if [[ -n $1 ]]; then+ mapfile -t CHILDREN_PID_LIST < <(ps --ppid "$1" -o pid= || true)+ for child_pid in "${CHILDREN_PID_LIST[@]}"; do+ kill "$child_pid" &>/dev/null || true+ wait "$child_pid" &>/dev/null || true+ done+ kill "$1" &>/dev/null || true+ wait "$1" &>/dev/null || true+ fi+}++function finish() {+ echo "Cleaning up..."+ kill_with_kids "$STREAM_PID"+ kill "$SERVER_PID" &>/dev/null || true+ wait "$SERVER_PID" &>/dev/null || true+ rm -fr "$TEMP_DB"+}++trap finish EXIT++TEMP_DB=$(mktemp)diff --git a/test/ocTestStream.sh b/test/ocTestStream.shindex 9994b61bf5..94471f6370 100755--- a/test/ocTestStream.sh+++ b/test/ocTestStream.sh@@ -85,7 +85,13 @@ elserm -f list.txtfor file in $CONTENTdo- echo "file '$file'" >> list.txt+ if [[ -f "$file" ]]; then+ echo "file '$file'" >> list.txt+ else+ echo "ERROR: File not found: $file"+ exit 1+ fi+donefunction finish {