Skip to content

Commit

Permalink
Fix utest fail. v5.12.15
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Dec 13, 2023
1 parent 804a49b commit fb1a497
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions platform/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,13 +387,13 @@ func initPlatform(ctx context.Context) error {
}

// Create directories for data, allow user to link it.
// Keep in mind that we must not create the containers/data/srs-s3-bucket, as the user should generate
// Keep in mind that the containers/data/srs-s3-bucket maybe mount by user, because user should generate
// and mount it if they wish to save recordings to cloud storage.
for _, dir := range []string{
"containers/data/dvr", "containers/data/record", "containers/data/vod",
"containers/data/upload", "containers/data/vlive", "containers/data/signals",
"containers/data/lego", "containers/data/.well-known", "containers/data/config",
"containers/data/transcript",
"containers/data/transcript", "containers/data/srs-s3-bucket",
} {
if _, err := os.Stat(dir); err != nil && os.IsNotExist(err) {
if err = os.MkdirAll(dir, os.ModeDir|os.FileMode(0755)); err != nil {
Expand Down
18 changes: 12 additions & 6 deletions test/scenario_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ func TestScenario_WithStream_PostProcessCpFile_RecordMp4(t *testing.T) {
// Change the dir to new dir.
if err := NewApi().WithAuth(ctx, "/terraform/v1/hooks/record/post-processing", &RecordPostProcess{
PostProcess: "post-cp-file",
PostCpDir: "/tmp",
PostCpDir: "./containers/data/srs-s3-bucket",
}, nil); err != nil {
r0 = errors.Wrapf(err, "request record apply failed")
return
Expand Down Expand Up @@ -681,8 +681,14 @@ func TestScenario_WithStream_PostProcessCpFile_RecordMp4(t *testing.T) {
UUID string `json:"uuid"`
}{recordFile.UUID}, nil)
}()
// Try to find the file in relative dir, then find file in absolute path.
buildRecordCpFilePath := func(f *RecordFile) string {
return path.Join("/tmp", fmt.Sprintf("%v.mp4", recordFile.UUID))
filename := fmt.Sprintf("%v.mp4", recordFile.UUID)
p := path.Join("../platform/containers/data/srs-s3-bucket", filename)
if _, err := os.Stat(p); err == nil {
return p
}
return path.Join("/data/srs-s3-bucket", filename)
}
defer func() {
// Remove the cp file at tmp.
Expand Down Expand Up @@ -812,7 +818,7 @@ func TestScenario_WithStream_Publishing_EndRecordMp4(t *testing.T) {
// Wait for record to save file.
select {
case <-ctx.Done():
case <-time.After(15 * time.Second):
case <-time.After(20 * time.Second):
}

// Query the recording task.
Expand Down Expand Up @@ -897,7 +903,7 @@ func TestScenario_WithStream_Publishing_EndRecordMp4(t *testing.T) {
// There should be another record file, after current task is ended.
select {
case <-ctx.Done():
case <-time.After(15 * time.Second):
case <-time.After(20 * time.Second):
}

// Stop record worker.
Expand Down Expand Up @@ -1020,7 +1026,7 @@ func TestScenario_WithStream_Unpublished_EndRecordMp4(t *testing.T) {
// Wait for record to save file.
select {
case <-ctx.Done():
case <-time.After(15 * time.Second):
case <-time.After(20 * time.Second):
}

// Query the recording task.
Expand Down Expand Up @@ -1112,7 +1118,7 @@ func TestScenario_WithStream_Unpublished_EndRecordMp4(t *testing.T) {
// There should never be another record file, after current task is ended.
select {
case <-ctx.Done():
case <-time.After(15 * time.Second):
case <-time.After(20 * time.Second):
}

// Stop record worker.
Expand Down

0 comments on commit fb1a497

Please sign in to comment.