Skip to content

Commit

Permalink
Use default context when restore hphls. v5.8.28
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Aug 30, 2023
1 parent 886978b commit e3dad7e
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 14 deletions.
31 changes: 21 additions & 10 deletions .github/workflows/test-online.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
# Note that s-1vcpu-512mb-10gb is too small for test, at least s-1vcpu-1gb size.
# Note that s-1vcpu-512mb-10gb is too small for test, use s-1vcpu-1gb or s-2vcpu-4gb size.
- name: Create test machine
run: |
sshkey=$(doctl compute ssh-key list --no-header |grep srs |awk '{print $1}')
Expand Down Expand Up @@ -242,10 +242,17 @@ jobs:
timeout: 600s
script: |
# Move files from provision.
mv -f provision/* .
mv -f provision/* .
# For manually debugging.
echo "" >> /etc/profile
echo "export SRS_TAG=${SRS_TAG}" >> /etc/profile
echo "export SRS_DOMAIN=${SRS_DOMAIN}" >> /etc/profile
tar xf platform.tar.gz
docker load -i platform.tar
if [[ $(docker images |grep platform |grep -q latest || echo no) == no ]]; then
tar xf platform.tar.gz
docker load -i platform.tar
fi
docker tag platform:latest ossrs/srs-stack:$SRS_TAG
docker tag platform:latest registry.cn-hangzhou.aliyuncs.com/ossrs/srs-stack:$SRS_TAG
docker image prune -f
Expand Down Expand Up @@ -286,34 +293,38 @@ jobs:
bash secret.sh >./test/.env &&
./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 &&
-test.run TestApi_Empty -no-bilibili-test=true &&
echo "Test HTTP API with self-signed cert." &&
bash secret.sh >./test/.env &&
./test/srs-stack.test -test.v -wait-ready -endpoint http://$SRS_DOMAIN.ossrs.io \
-srs-log=true -wait-ready=true -init-password=false -check-api-secret=true -no-media-test &&
-srs-log=true -wait-ready=true -init-password=false -check-api-secret=true -no-media-test \
-no-bilibili-test=true &&
echo "Test HTTPS API with self-signed cert." &&
bash secret.sh >./test/.env &&
./test/srs-stack.test -test.v -wait-ready -endpoint https://$SRS_DOMAIN.ossrs.io \
-srs-log=true -wait-ready=true -init-password=false -check-api-secret=true -no-media-test &&
-srs-log=true -wait-ready=true -init-password=false -check-api-secret=true -no-media-test \
-no-bilibili-test=true &&
echo "Request CERT from letsencrypt." &&
bash secret.sh >./test/.env &&
./test/srs-stack.test -test.v -endpoint http://$SRS_DOMAIN.ossrs.io \
-srs-log=true -wait-ready=true -init-password=false -check-api-secret=true -domain-lets-encrypt=$SRS_DOMAIN.ossrs.io \
-test.run TestApi_LetsEncryptUpdateCert -no-media-test &&
-test.run TestApi_LetsEncryptUpdateCert -no-media-test \
-no-bilibili-test=true &&
echo "Test HTTPS API with letsencrypt cert." &&
bash secret.sh >./test/.env &&
./test/srs-stack.test -test.v -wait-ready -endpoint https://$SRS_DOMAIN.ossrs.io \
-srs-log=true -wait-ready=true -init-password=false -check-api-secret=true -https-insecure-verify \
-no-media-test &&
-no-media-test -no-bilibili-test=true &&
echo "Run media test with retry" &&
bash secret.sh >./test/.env &&
./failed-retry.sh 5 ./test/srs-stack.test -test.v -wait-ready -endpoint http://$SRS_DOMAIN.ossrs.io \
-srs-log=true -wait-ready=true -init-password=false -check-api-secret=true -test.run TestApi_Publish*
-srs-log=true -wait-ready=true -init-password=false -check-api-secret=true -test.run TestApi_Publish* \
-no-bilibili-test=true
ret=$?; echo "Test result: $ret"
echo "Stop service"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![](https://img.shields.io/twitter/follow/srs_server?style=social)](https://twitter.com/srs_server)
[![](https://badgen.net/discord/members/bQUPDRqy79)](https://discord.gg/bQUPDRqy79)
[![](https://ossrs.net/wiki/images/wechat-badge4.svg)](https://ossrs.net/lts/zh-cn/contact#discussion)
[![](https://ossrs.net/wiki/images/do-btn-srs-125x20.svg)](https://cloud.digitalocean.com/droplets/new?appId=133468816&size=s-1vcpu-512mb-10gb&region=sgp1&image=ossrs-srs&type=applications)
[![](https://ossrs.net/wiki/images/do-btn-srs-125x20.svg)](https://cloud.digitalocean.com/droplets/new?appId=133468816&size=s-2vcpu-4gb&region=sgp1&image=ossrs-srs&type=applications)
[![](https://opencollective.com/srs-server/tiers/badge.svg)](https://opencollective.com/srs-server)

SRS Stack is a video solution that is lightweight, open-source, and based on Go, Reactjs, SRS, FFmpeg, WebRTC, etc.
Expand Down
2 changes: 1 addition & 1 deletion scripts/setup-droplet/srs.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"api_token": "{{user `do_token`}}",
"image": "ubuntu-20-04-x64",
"region": "sgp1",
"size": "s-1vcpu-512mb-10gb",
"size": "s-2vcpu-4gb",
"ssh_username": "root",
"snapshot_name": "{{user `image_name`}}"
}
Expand Down
8 changes: 8 additions & 0 deletions test/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,10 @@ func TestApi_TutorialsQueryBilibili(t *testing.T) {
return
}

if *noBilibiliTest {
return
}

var r0 error
defer func(ctx context.Context) {
if err := filterTestError(ctx.Err(), r0); err != nil {
Expand Down Expand Up @@ -935,6 +939,8 @@ func TestApi_PublishRtmpPlayHls_NoHlsCtx(t *testing.T) {
// TODO: FIXME: Remove it after fix the bug.
time.Sleep(10 * time.Second)

// The ctx has already been cancelled by test case, which will cause the request failed.
ctx := context.Background()
if err := apiRequest(ctx, "/terraform/v1/mgmt/hphls/update", &initData, nil); err != nil {
logger.Tf(ctx, "restore hphls config failed %+v", err)
}
Expand Down Expand Up @@ -1083,6 +1089,8 @@ func TestApi_PublishRtmpPlayHls_WithHlsCtx(t *testing.T) {
// TODO: FIXME: Remove it after fix the bug.
time.Sleep(10 * time.Second)

// The ctx has already been cancelled by test case, which will cause the request failed.
ctx := context.Background()
if err := apiRequest(ctx, "/terraform/v1/mgmt/hphls/update", &initData, nil); err != nil {
logger.Tf(ctx, "restore hphls config failed %+v", err)
}
Expand Down
8 changes: 6 additions & 2 deletions test/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ var httpsInsecureVerify *bool
// and may occasionally fail. Therefore, it is necessary to retry the process if a failure occurs.
var noMediaTest *bool

// noBilibiliTest is used to disable the bilibili test.
var noBilibiliTest *bool

var srsLog *bool
var srsTimeout *int
var endpoint *string
Expand All @@ -100,10 +103,10 @@ var srsInputFile *string
func options() string {
return fmt.Sprintf("log=%v, timeout=%vms, secret=%vB, checkApiSecret=%v, endpoint=%v, forceHttps=%v, "+
"waitReady=%v, initPassword=%v, initSelfSignedCert=%v, systemPassword=%vB, domainLetsEncrypt=%v, "+
"httpsInsecureVerify=%v, srsInputFile=%v, noMediaTest=%v",
"httpsInsecureVerify=%v, srsInputFile=%v, noMediaTest=%v, noBilibiliTest=%v",
*srsLog, *srsTimeout, len(*apiSecret), *checkApiSecret, *endpoint, *forceHttps, *waitReady, *initPassword,
*initSelfSignedCert, len(*systemPassword), *domainLetsEncrypt, *httpsInsecureVerify, *srsInputFile,
*noMediaTest,
*noMediaTest, *noBilibiliTest,
)
}

Expand Down Expand Up @@ -145,6 +148,7 @@ func prepareTest(ctx context.Context) (err error) {
srsFFprobe = flag.String("srs-ffprobe", "ffprobe", "The FFprobe tool")
srsInputFile = flag.String("srs-input-file", "source.200kbps.768x320.flv", "The input file")
noMediaTest = flag.Bool("no-media-test", false, "Whether disable the media test")
noBilibiliTest = flag.Bool("no-bilibili-test", false, "Whether disable the bilibili test")

// Should parse it first.
flag.Parse()
Expand Down

0 comments on commit e3dad7e

Please sign in to comment.