Skip to content

Commit

Permalink
Fix utest fail. v5.9.10
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Sep 5, 2023
1 parent d37e07b commit 25edf14
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 36 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test-online.yml
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ jobs:
./test/srs-stack.test -test.v -endpoint http://$SRS_DOMAIN.ossrs.io \
-srs-log=true -wait-ready=true -init-password=true -check-api-secret=true -init-self-signed-cert=true \
-test.run TestApi_Empty -no-bilibili-test=true &&
echo "Make upload writable." &&
sudo chmod 777 /data/upload &&
echo "Test HTTP API with self-signed cert." &&
bash secret.sh >./test/.env &&
Expand Down
72 changes: 45 additions & 27 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
SRS_MAJOR: ${{ env.SRS_MAJOR }}
runs-on: ubuntu-20.04

test:
run-test:
name: Run UTest
runs-on: ubuntu-20.04
needs:
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
run: |
make -j && make test -j
build-image:
build-platform-image:
name: Build platform image
runs-on: ubuntu-20.04
needs:
Expand All @@ -83,11 +83,11 @@ jobs:
path: platform.tar
retention-days: 1

install-docker-zh:
test-zh-image:
name: Test ZH image
needs:
- envs
- build-image
- build-platform-image
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand Down Expand Up @@ -125,6 +125,9 @@ jobs:
-srs-log=true -wait-ready=true -init-password=true -init-self-signed-cert=true \
-check-api-secret=true -test.run TestApi_Empty &&
echo "Make upload writable." &&
sudo chmod 777 /data/upload &&
echo "Test HTTP service." &&
bash scripts/tools/secret.sh --output test/.env &&
./test/srs-stack.test -test.v -endpoint http://localhost:2022 \
Expand All @@ -139,7 +142,7 @@ jobs:
echo "Run media test with retry" &&
bash scripts/tools/secret.sh --output test/.env &&
./scripts/tools/failed-retry.sh 5 ./test/srs-stack.test -test.v -endpoint http://localhost:2022 \
./scripts/tools/failed-retry.sh 1 ./test/srs-stack.test -test.v -endpoint http://localhost:2022 \
-srs-log=true -wait-ready=true -init-password=false -init-self-signed-cert=false \
-check-api-secret=true -test.run TestApi_Publish*
ret=$?; echo "Test result: $ret"
Expand All @@ -152,11 +155,11 @@ jobs:
exit $ret
runs-on: ubuntu-20.04

install-docker-en:
test-en-image:
name: Test EN image
needs:
- envs
- build-image
- build-platform-image
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand Down Expand Up @@ -194,6 +197,9 @@ jobs:
-srs-log=true -wait-ready=true -init-password=true -init-self-signed-cert=true \
-check-api-secret=true -test.run TestApi_Empty &&
echo "Make upload writable." &&
sudo chmod 777 /data/upload &&
echo "Test HTTP service." &&
bash scripts/tools/secret.sh --output test/.env &&
./test/srs-stack.test -test.v -endpoint http://localhost:2022 \
Expand All @@ -208,7 +214,7 @@ jobs:
echo "Run media test with retry" &&
bash scripts/tools/secret.sh --output test/.env &&
./scripts/tools/failed-retry.sh 5 ./test/srs-stack.test -test.v -endpoint http://localhost:2022 \
./scripts/tools/failed-retry.sh 1 ./test/srs-stack.test -test.v -endpoint http://localhost:2022 \
-srs-log=true -wait-ready=true -init-password=false -init-self-signed-cert=false \
-check-api-secret=true -test.run TestApi_Publish*
ret=$?; echo "Test result: $ret"
Expand All @@ -221,12 +227,12 @@ jobs:
exit $ret
runs-on: ubuntu-20.04

install-script-zh:
test-zh-installer:
name: Test ZH installer
runs-on: ubuntu-20.04
needs:
- envs
- build-image
- build-platform-image
steps:
- name: Covert output to env
run: |
Expand Down Expand Up @@ -281,6 +287,9 @@ jobs:
-srs-log=true -wait-ready=true -init-password=true -init-self-signed-cert=true \
-check-api-secret=true -test.run TestApi_Empty &&
echo "Make upload writable." &&
sudo chmod 777 /data/upload &&
echo "Test HTTP service." &&
bash scripts/tools/secret.sh --output test/.env &&
./test/srs-stack.test -test.v -endpoint http://localhost:2022 \
Expand All @@ -295,7 +304,7 @@ jobs:
echo "Run media test with retry" &&
bash scripts/tools/secret.sh --output test/.env &&
./scripts/tools/failed-retry.sh 5 ./test/srs-stack.test -test.v -endpoint http://localhost:2022 \
./scripts/tools/failed-retry.sh 1 ./test/srs-stack.test -test.v -endpoint http://localhost:2022 \
-srs-log=true -wait-ready=true -init-password=false -init-self-signed-cert=false \
-check-api-secret=true -test.run TestApi_Publish*
ret=$?; echo "Test result: $ret"
Expand All @@ -307,12 +316,12 @@ jobs:
exit $ret
install-script-en:
test-en-installer:
name: Test EN installer
runs-on: ubuntu-20.04
needs:
- envs
- build-image
- build-platform-image
steps:
- name: Covert output to env
run: |
Expand Down Expand Up @@ -367,6 +376,9 @@ jobs:
-srs-log=true -wait-ready=true -init-password=true -init-self-signed-cert=true \
-check-api-secret=true -test.run TestApi_Empty &&
echo "Make upload writable." &&
sudo chmod 777 /data/upload &&
echo "Test HTTP service." &&
bash scripts/tools/secret.sh --output test/.env &&
./test/srs-stack.test -test.v -endpoint http://localhost:2022 \
Expand All @@ -381,7 +393,7 @@ jobs:
echo "Run media test with retry" &&
bash scripts/tools/secret.sh --output test/.env &&
./scripts/tools/failed-retry.sh 5 ./test/srs-stack.test -test.v -endpoint http://localhost:2022 \
./scripts/tools/failed-retry.sh 1 ./test/srs-stack.test -test.v -endpoint http://localhost:2022 \
-srs-log=true -wait-ready=true -init-password=false -init-self-signed-cert=false \
-check-api-secret=true -test.run TestApi_Publish*
ret=$?; echo "Test result: $ret"
Expand All @@ -393,12 +405,12 @@ jobs:
exit $ret
install-bt:
test-bt-plugin:
name: Test BT plugin
runs-on: ubuntu-20.04
needs:
- envs
- build-image
- build-platform-image
steps:
- name: Remove unnecessary files
run: |
Expand Down Expand Up @@ -521,6 +533,9 @@ jobs:
-srs-log=true -wait-ready=true -init-password=true -init-self-signed-cert=true \
-check-api-secret=true -test.run TestApi_Empty &&
echo "Make upload writable." &&
sudo chmod 777 /data/upload &&
echo "Test HTTP service." &&
bash scripts/tools/secret.sh --output test/.env &&
./test/srs-stack.test -test.v -endpoint http://srs.stack.local:80 \
Expand All @@ -535,7 +550,7 @@ jobs:
echo "Run media test with retry" &&
bash scripts/tools/secret.sh --output test/.env &&
./scripts/tools/failed-retry.sh 5 ./test/srs-stack.test -test.v -endpoint http://srs.stack.local:80 \
./scripts/tools/failed-retry.sh 1 ./test/srs-stack.test -test.v -endpoint http://srs.stack.local:80 \
-srs-log=true -wait-ready=true -init-password=false -init-self-signed-cert=false \
-check-api-secret=true -test.run TestApi_Publish*
ret=$?; echo "Test result: $ret"
Expand All @@ -548,12 +563,12 @@ jobs:
exit $ret
install-aapanel:
test-aapanel-plugin:
name: Test aaPanel plugin
runs-on: ubuntu-20.04
needs:
- envs
- build-image
- build-platform-image
steps:
- name: Remove unnecessary files
run: |
Expand Down Expand Up @@ -673,6 +688,9 @@ jobs:
-srs-log=true -wait-ready=true -init-password=true -init-self-signed-cert=true \
-check-api-secret=true -test.run TestApi_Empty &&
echo "Make upload writable." &&
sudo chmod 777 /data/upload &&
echo "Test HTTP service." &&
bash scripts/tools/secret.sh --output test/.env &&
./test/srs-stack.test -test.v -endpoint http://srs.stack.local:80 \
Expand All @@ -687,7 +705,7 @@ jobs:
echo "Run media test with retry" &&
bash scripts/tools/secret.sh --output test/.env &&
./scripts/tools/failed-retry.sh 5 ./test/srs-stack.test -test.v -endpoint http://srs.stack.local:80 \
./scripts/tools/failed-retry.sh 1 ./test/srs-stack.test -test.v -endpoint http://srs.stack.local:80 \
-srs-log=true -wait-ready=true -init-password=false -init-self-signed-cert=false \
-check-api-secret=true -test.run TestApi_Publish*
ret=$?; echo "Test result: $ret"
Expand All @@ -704,13 +722,13 @@ jobs:
name: test-final
runs-on: ubuntu-20.04
needs:
- test
- install-docker-zh
- install-docker-en
- install-script-zh
- install-script-en
- install-bt
- install-aapanel
- run-test
- test-zh-image
- test-en-image
- test-zh-installer
- test-en-installer
- test-bt-plugin
- test-aapanel-plugin
steps:
- uses: geekyeggo/delete-artifact@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion platform/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ func initPlatform(ctx context.Context) error {
}

// Run only once for a special version.
bootRelease := "v202328"
bootRelease := "v2023-r29"
if firstRun, err := rdb.HGet(ctx, SRS_FIRST_BOOT, bootRelease).Result(); err != nil && err != redis.Nil {
return errors.Wrapf(err, "hget %v %v", SRS_FIRST_BOOT, bootRelease)
} else if firstRun == "" {
Expand Down
14 changes: 9 additions & 5 deletions test/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ func prepareTest(ctx context.Context) (err error) {
return nFilename, nil
}

// Try to open files in test directory.
nFilename = path.Join("test", filename)
if stat, err := os.Stat(nFilename); err == nil && !stat.IsDir() {
return nFilename, nil
}

// Try to find file by which if it's a command like ffmpeg.
cmd := exec.Command("which", filename)
cmd.Env = []string{"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"}
Expand All @@ -181,15 +187,13 @@ func prepareTest(ctx context.Context) (err error) {

// Check and relocate path of tools.
if *srsFFmpeg, err = tryOpenFile(*srsFFmpeg); err != nil {
return err
return errors.Wrapf(err, "not found ffmpeg %v", *srsFFmpeg)
}
if *srsFFprobe, err = tryOpenFile(*srsFFprobe); err != nil {
return err
return errors.Wrapf(err, "not found ffprobe %v", *srsFFprobe)
}
if *srsInputFile, err = tryOpenFile(*srsInputFile); err != nil {
if *srsInputFile, err = tryOpenFile(path.Join("test", *srsInputFile)); err != nil {
return errors.Wrapf(err, "not found input file %v", *srsInputFile)
}
return errors.Wrapf(err, "not found input file %v", *srsInputFile)
}

return nil
Expand Down
3 changes: 2 additions & 1 deletion test/media_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"math/rand"
"os"
"path"
"path/filepath"
"strings"
"sync"
"testing"
Expand Down Expand Up @@ -667,7 +668,7 @@ func TestApi_PublishVLivePlayFlv(t *testing.T) {
}

// Get first matched source file.
sourceFile := getExistsFile(ctx, *srsInputFile, destDirs...)
sourceFile := getExistsFile(ctx, filepath.Base(*srsInputFile), destDirs...)
if sourceFile == "" {
r0 = errors.Errorf("no source file found")
return
Expand Down
5 changes: 3 additions & 2 deletions test/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ func getExistsFile(ctx context.Context, filename string, destDirs ...string) str
func copyToDest(ctx context.Context, sourceFile string, destDirs ...string) error {
for _, destDir := range destDirs {
if stat, err := os.Stat(destDir); err == nil && stat.IsDir() {
if err = exec.CommandContext(ctx, "cp", "-f", sourceFile, destDir).Run(); err != nil {
return err
cmd := exec.CommandContext(ctx, "cp", "-f", sourceFile, destDir)
if b, err := cmd.CombinedOutput(); err != nil {
return errors.Wrapf(err, "cp %s to %s failed, output %s", sourceFile, destDir, string(b))
}
}
}
Expand Down

0 comments on commit 25edf14

Please sign in to comment.