-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PROTO-1664] Replicate transcode result in parallel (#7593)
- Loading branch information
1 parent
23edd81
commit 0cd31cf
Showing
8 changed files
with
129 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
FROM golang:alpine | ||
|
||
RUN apk add ffmpeg | ||
|
||
WORKDIR /app | ||
|
||
COPY . . | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package server | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
"io" | ||
"mime/multipart" | ||
"net/http" | ||
"os" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestUploadFile(t *testing.T) { | ||
ss := testNetwork[0] | ||
s2 := testNetwork[1] | ||
|
||
var b bytes.Buffer | ||
w := multipart.NewWriter(&b) | ||
|
||
{ | ||
fw, err := w.CreateFormField("template") | ||
assert.NoError(t, err) | ||
fw.Write([]byte("audio")) | ||
} | ||
|
||
fw, err := w.CreateFormFile(filesFormFieldName, "beep.wav") | ||
assert.NoError(t, err) | ||
|
||
hit, err := os.Open("testdata/beep.wav") | ||
assert.NoError(t, err) | ||
|
||
io.Copy(fw, hit) | ||
hit.Close() | ||
w.Close() | ||
|
||
resp, err := http.Post(ss.Config.Self.Host+"/uploads", w.FormDataContentType(), &b) | ||
assert.NoError(t, err) | ||
assert.Equal(t, resp.StatusCode, 200) | ||
|
||
dec := json.NewDecoder(resp.Body) | ||
var uploads []Upload | ||
err = dec.Decode(&uploads) | ||
assert.NoError(t, err) | ||
uploadId := uploads[0].ID | ||
|
||
// force sweep (since blob changes SkipBroadcast) | ||
for _, s := range testNetwork { | ||
s.crud.ForceSweep() | ||
} | ||
|
||
// poll for complete | ||
var u2 *Upload | ||
for i := 0; i < 3; i++ { | ||
resp, err := s2.reqClient.R().SetSuccessResult(&u2).Get(s2.Config.Self.Host + "/uploads/" + uploadId) | ||
assert.NoError(t, err) | ||
assert.Equal(t, resp.StatusCode, 200) | ||
if u2.Status == JobStatusDone { | ||
break | ||
} | ||
time.Sleep(time.Second) | ||
} | ||
|
||
assert.Equal(t, u2.TranscodeProgress, 1.0) | ||
assert.Len(t, u2.TranscodedMirrors, ss.Config.ReplicationFactor) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters