Skip to content

Commit

Permalink
Refine test for record. v5.9.11
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Sep 5, 2023
1 parent 27ad0dc commit 4eb105f
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 8 deletions.
49 changes: 48 additions & 1 deletion DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,54 @@ cd scripts/setup-droplet && packer build srs.json)
Please check the [snapshot](https://cloud.digitalocean.com/images/snapshots/droplets), and create a test droplet.

TODO: FIXME: Test it.
```bash
IMAGE=$(doctl compute snapshot list --context market --format ID --no-header) &&
sshkey=$(doctl compute ssh-key list --context market --no-header |grep srs |awk '{print $1}') &&
doctl compute droplet create srs-stack-test --context market --image $IMAGE \
--region sgp1 --size s-2vcpu-2gb --ssh-keys $sshkey --wait &&
SRS_DROPLET_EIP=$(doctl compute droplet get srs-stack-test --context market --format PublicIPv4 --no-header)
```

Prepare test environment:

```bash
ssh root@$SRS_DROPLET_EIP sudo mkdir -p /data/upload &&
ssh root@$SRS_DROPLET_EIP sudo chmod 777 /data/upload &&
cp ~/git/srs/trunk/doc/source.200kbps.768x320.flv test/ &&
scp test/source.200kbps.768x320.flv root@$SRS_DROPLET_EIP:/data/upload/
```

Test the droplet instance:

```bash
scp scripts/tools/secret.sh root@$SRS_DROPLET_EIP:~ &&
make -j -C test &&
ssh root@$SRS_DROPLET_EIP sudo bash secret.sh >test/.env &&
./test/srs-stack.test -test.v -endpoint http://$SRS_DROPLET_EIP:2022 \
-srs-log=true -wait-ready=true -init-password=true -check-api-secret=true -init-self-signed-cert=true \
-test.run TestApi_Empty &&
ssh root@$SRS_DROPLET_EIP sudo bash secret.sh >test/.env &&
./test/srs-stack.test -test.v -wait-ready -endpoint http://$SRS_DROPLET_EIP:2022 \
-endpoint-rtmp rtmp://$SRS_DROPLET_EIP -endpoint-http http://$SRS_DROPLET_EIP -endpoint-srt srt://$SRS_DROPLET_EIP:10080 \
-srs-log=true -wait-ready=true -init-password=false -check-api-secret=true \
-test.parallel 1 &&
./test/srs-stack.test -test.v -wait-ready -endpoint https://$SRS_DROPLET_EIP:2443 \
-endpoint-rtmp rtmp://$SRS_DROPLET_EIP -endpoint-http https://$SRS_DROPLET_EIP -endpoint-srt srt://$SRS_DROPLET_EIP:10080 \
-srs-log=true -wait-ready=true -init-password=false -check-api-secret=true \
-test.parallel 1
```

Remove the droplet instance:

```bash
doctl compute droplet delete srs-stack-test --context market --force
```

After submit to [marketplace](https://cloud.digitalocean.com/vendorportal/624145d53da4ad68de259945/10/edit), cleanup the snapshot:

```bash
doctl compute snapshot delete $IMAGE --context market --force
```

## Develop the TencentCloud Lighthouse Image

Expand Down
12 changes: 5 additions & 7 deletions test/scenario_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ func TestApi_PublishRtmpRecordMp4(t *testing.T) {
r0 = errors.Wrapf(err, "request record apply failed")
return
}
logger.Tf(ctx, "stop record worker done")

// Query the record file.
type RecordFile struct {
Expand All @@ -297,8 +298,9 @@ func TestApi_PublishRtmpRecordMp4(t *testing.T) {
UUID string `json:"uuid"`
}{recordFile.UUID}, nil)
}()
defer cancel()

for i := 0; i < 60; i++ {
for i := 0; i < 45; i++ {
files := []RecordFile{}
if err := apiRequest(ctx, "/terraform/v1/hooks/record/files", nil, &files); err != nil {
r0 = errors.Wrapf(err, "request record files failed")
Expand All @@ -312,7 +314,7 @@ func TestApi_PublishRtmpRecordMp4(t *testing.T) {
}
}

if recordFile == nil || recordFile.Progress {
if recordFile == nil || (recordFile.Progress && recordFile.Duration < 10) {
select {
case <-ctx.Done():
r0 = errors.Wrapf(ctx.Err(), "record file not found")
Expand All @@ -328,11 +330,7 @@ func TestApi_PublishRtmpRecordMp4(t *testing.T) {
r0 = errors.Errorf("record file not found")
return
}
if recordFile.Progress {
r0 = errors.Errorf("record file is progress, %v", recordFile)
return
}
if recordFile.Duration < 10 {
if recordFile.Progress && recordFile.Duration < 10 {
r0 = errors.Errorf("record file duration too short, %v", recordFile)
return
}
Expand Down

0 comments on commit 4eb105f

Please sign in to comment.