Skip to content

Commit

Permalink
Revert "Populate status message"
Browse files Browse the repository at this point in the history
  • Loading branch information
marzagao authored Dec 2, 2016
1 parent a034de7 commit a56d8da
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 205 deletions.
9 changes: 0 additions & 9 deletions provider/elastictranscoder/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,18 +285,9 @@ func (p *awsProvider) JobStatus(job *db.Job) (*provider.JobStatus, error) {
Width: aws.Int64Value(resp.Job.Input.DetectedProperties.Width),
}
}
statusMessage := ""
if len(resp.Job.Outputs) > 0 {
statusMessage = aws.StringValue(resp.Job.Outputs[0].StatusDetail)
if strings.Contains(statusMessage, ":") {
errorMessage := strings.Split(statusMessage, ":")[1]
statusMessage = strings.Trim(errorMessage, " ")
}
}
return &provider.JobStatus{
ProviderJobID: aws.StringValue(resp.Job.Id),
Status: p.statusMap(aws.StringValue(resp.Job.Status)),
StatusMessage: statusMessage,
Progress: completedJobs / float64(totalJobs) * 100,
ProviderStatus: map[string]interface{}{"outputs": outputs},
SourceInfo: sourceInfo,
Expand Down
2 changes: 0 additions & 2 deletions provider/elastictranscoder/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,6 @@ func TestAWSJobStatus(t *testing.T) {
expectedJobStatus := provider.JobStatus{
ProviderJobID: jobStatus.ProviderJobID,
Status: provider.StatusFinished,
StatusMessage: "it's finished!",
Progress: 100,
ProviderStatus: map[string]interface{}{
"outputs": map[string]interface{}{
Expand Down Expand Up @@ -753,7 +752,6 @@ func TestAWSJobStatusNoDetectedProperties(t *testing.T) {
expectedJobStatus := provider.JobStatus{
ProviderJobID: jobStatus.ProviderJobID,
Status: provider.StatusFinished,
StatusMessage: "it's finished!",
Progress: 100,
ProviderStatus: map[string]interface{}{
"outputs": map[string]interface{}{
Expand Down
5 changes: 0 additions & 5 deletions provider/elementalconductor/elementalconductor.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,11 @@ func (p *elementalConductorProvider) JobStatus(job *db.Job) (*provider.JobStatus
if resp.ContentDuration != nil {
duration = time.Duration(resp.ContentDuration.InputDuration) * time.Second
}
statusMessage := ""
if len(resp.ErrorMessages) > 0 {
statusMessage = resp.ErrorMessages[0].Message
}
return &provider.JobStatus{
ProviderName: Name,
ProviderJobID: job.ProviderJobID,
Progress: float64(resp.PercentComplete),
Status: p.statusMap(resp.Status),
StatusMessage: statusMessage,
ProviderStatus: providerStatus,
SourceInfo: provider.SourceInfo{
Duration: duration,
Expand Down
14 changes: 0 additions & 14 deletions provider/elementalconductor/elementalconductor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package elementalconductor

import (
"encoding/xml"
"os"
"reflect"
"testing"
"time"
Expand All @@ -11,7 +10,6 @@ import (
"github.com/NYTimes/video-transcoding-api/config"
"github.com/NYTimes/video-transcoding-api/db"
"github.com/NYTimes/video-transcoding-api/provider"
"github.com/kr/pretty"
)

func TestFactoryIsRegistered(t *testing.T) {
Expand Down Expand Up @@ -736,11 +734,6 @@ func TestJobStatus(t *testing.T) {
client := newFakeElementalConductorClient(&elementalConductorConfig)
client.jobs["job-1"] = elementalconductor.Job{
Href: "whatever",
ErrorMessages: []elementalconductor.JobError{
{
Message: "This is some error.",
},
},
Input: elementalconductor.Input{
InputInfo: &elementalconductor.InputInfo{
Video: elementalconductor.VideoInputInfo{
Expand Down Expand Up @@ -865,7 +858,6 @@ func TestJobStatus(t *testing.T) {
ProviderJobID: "job-1",
Progress: 89.,
Status: provider.StatusStarted,
StatusMessage: "This is some error.",
Output: provider.JobOutput{
Destination: "s3://destination/super-job-1",
Files: []provider.OutputFile{
Expand Down Expand Up @@ -898,15 +890,9 @@ func TestJobStatus(t *testing.T) {
ProviderStatus: map[string]interface{}{
"status": "running",
"submitted": submitted,
"error_messages": []elementalconductor.JobError{
{
Message: "This is some error.",
},
},
},
}
if !reflect.DeepEqual(*jobStatus, expectedJobStatus) {
pretty.Fdiff(os.Stderr, expectedJobStatus, *jobStatus)
t.Errorf("wrong job stats\nwant %#v\ngot %#v", expectedJobStatus, *jobStatus)
}
}
Expand Down
14 changes: 2 additions & 12 deletions provider/encodingcom/encodingcom.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,24 +227,18 @@ func (e *encodingComProvider) JobStatus(job *db.Job) (*provider.JobStatus, error
return nil, err
}
}
formatStatus := e.getFormatStatus(resp)
statusMessage := ""
if len(formatStatus) > 0 {
statusMessage = formatStatus[0]
}
return &provider.JobStatus{
ProviderJobID: job.ProviderJobID,
ProviderName: "encoding.com",
Status: status,
StatusMessage: statusMessage,
Progress: resp[0].Progress,
ProviderStatus: map[string]interface{}{
"sourcefile": resp[0].SourceFile,
"timeleft": resp[0].TimeLeft,
"created": resp[0].CreateDate,
"started": resp[0].StartDate,
"finished": resp[0].FinishDate,
"formatStatus": formatStatus,
"formatStatus": e.getFormatStatus(resp),
},
Output: provider.JobOutput{
Destination: e.getOutputDestination(job),
Expand Down Expand Up @@ -286,11 +280,7 @@ func (e *encodingComProvider) getFormatStatus(status []encodingcom.StatusRespons
formatStatusList := []string{}
formats := status[0].Formats
for _, formatStatus := range formats {
statusMessage := formatStatus.Status
if statusMessage == "Error" {
statusMessage = statusMessage + ": " + formatStatus.Description
}
formatStatusList = append(formatStatusList, statusMessage)
formatStatusList = append(formatStatusList, formatStatus.Status)
}
return formatStatusList
}
Expand Down
15 changes: 6 additions & 9 deletions provider/encodingcom/encodingcom_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@ type fakePreset struct {
}

type fakeMedia struct {
ID string
Request request
Created time.Time
Started time.Time
Finished time.Time
Status string
Description string
ID string
Request request
Created time.Time
Started time.Time
Finished time.Time
Status string
}

// encodingComFakeServer is a fake version of the Encoding.com API.
Expand Down Expand Up @@ -190,8 +189,6 @@ func (s *encodingComFakeServer) getStatus(w http.ResponseWriter, req request) {
"finished": media.Finished.Format(encodingComDateFormat),
"output": hlsOutput,
"format": map[string]interface{}{
"status": status,
"description": media.Description,
"destination": []string{
"https://mybucket.s3.amazonaws.com/dir/job-123/some_hls_preset/video-0.m3u8",
"https://mybucket.s3.amazonaws.com/dir/job-123/video.m3u8",
Expand Down
51 changes: 10 additions & 41 deletions provider/encodingcom/encodingcom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,15 +512,15 @@ func TestJobStatus(t *testing.T) {
ProviderJobID: "mymedia",
ProviderName: "encoding.com",
Status: provider.StatusFinished,
StatusMessage: "Finished",
StatusMessage: "",
Progress: 100,
ProviderStatus: map[string]interface{}{
"sourcefile": "http://some.source.file",
"timeleft": "1",
"created": media.Created,
"started": media.Started,
"finished": media.Finished,
"formatStatus": []string{"Finished"},
"formatStatus": []string{""},
},
SourceInfo: provider.SourceInfo{
Duration: 183e9,
Expand Down Expand Up @@ -592,15 +592,15 @@ func TestJobStatusNotFinished(t *testing.T) {
ProviderJobID: "mymedia",
ProviderName: "encoding.com",
Status: provider.StatusStarted,
StatusMessage: "Saving",
StatusMessage: "",
Progress: 100,
ProviderStatus: map[string]interface{}{
"sourcefile": "http://some.source.file",
"timeleft": "1",
"created": media.Created,
"started": media.Started,
"finished": media.Finished,
"formatStatus": []string{"Saving"},
"formatStatus": []string{""},
},
Output: provider.JobOutput{
Destination: "s3://mybucket/dir/job-123/",
Expand Down Expand Up @@ -682,58 +682,30 @@ func TestJobStatusInvalidSourceInfo(t *testing.T) {
Finished: now.Add(time.Hour),
}
server.medias["media3"] = &media3
media4 := fakeMedia{
ID: "media4",
Request: request{
Format: []encodingcom.Format{
{
VideoCodec: "VP9",
Output: []string{"webm"},
},
},
},
Status: "Error",
Description: "Something",
Created: now,
Started: now.Add(time.Minute),
Finished: now.Add(time.Hour),
}
server.medias["media4"] = &media4
var tests = []struct {
testCase string
mediaID string
errMsg string
resultingStatusShouldBeNil bool
testCase string
mediaID string
errMsg string
}{
{
"invalid media ID",
"something",
`Error returned by the Encoding.com API: {"Errors":["media not found"]}`,
true,
},
{
"invalid height",
"media1",
`invalid size returned by the Encoding.com API ("1920x1080x900"): strconv.ParseInt: parsing "1080x900": invalid syntax`,
true,
},
{
"invalid width",
"media2",
`invalid size returned by the Encoding.com API ("πx1080"): strconv.ParseInt: parsing "π": invalid syntax`,
true,
},
{
"invalid size",
"media3",
`invalid size returned by the Encoding.com API: "π"`,
true,
},
{
"error status",
"media4",
`Error: Something`,
false,
},
}
client, err := encodingcom.NewClient(server.URL, "myuser", "secret")
Expand All @@ -748,19 +720,16 @@ func TestJobStatusInvalidSourceInfo(t *testing.T) {
}
for _, test := range tests {
jobStatus, err := prov.JobStatus(&db.Job{ProviderJobID: test.mediaID})
if test.resultingStatusShouldBeNil && jobStatus != nil {
if jobStatus != nil {
t.Errorf("%s: got unexpected non-nil status: %#v", test.testCase, jobStatus)
}
if test.resultingStatusShouldBeNil && err == nil {
if err == nil {
t.Errorf("%s: got unexpected <nil> error", test.testCase)
continue
}
if test.resultingStatusShouldBeNil && err.Error() != test.errMsg {
if err.Error() != test.errMsg {
t.Errorf("%s: wrong error message\nwant %q\ngot %q", test.testCase, test.errMsg, err.Error())
}
if !test.resultingStatusShouldBeNil && test.errMsg != jobStatus.StatusMessage {
t.Errorf("%s: wrong error message\nwant %q\ngot %q", test.testCase, test.errMsg, jobStatus.StatusMessage)
}
}
}

Expand Down
5 changes: 0 additions & 5 deletions provider/zencoder/zencoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,10 @@ func (z *zencoderProvider) JobStatus(job *db.Job) (*provider.JobStatus, error) {
return nil, fmt.Errorf("error getting job progress: %s", err)
}
inputMediaFile := jobDetails.Job.InputMediaFile
statusMessage := ""
if inputMediaFile.ErrorMessage != nil {
statusMessage = *inputMediaFile.ErrorMessage
}
return &provider.JobStatus{
ProviderName: Name,
ProviderJobID: job.ProviderJobID,
Status: z.statusMap(progress.State),
StatusMessage: statusMessage,
Progress: progress.JobProgress,
Output: jobOutputs,
SourceInfo: provider.SourceInfo{
Expand Down
38 changes: 0 additions & 38 deletions provider/zencoder/zencoder_fake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,44 +23,6 @@ func (z *FakeZencoder) GetJobProgress(id int64) (*zencoder.JobProgress, error) {
}

func (z *FakeZencoder) GetJobDetails(id int64) (*zencoder.JobDetails, error) {
if id == 11111 {
errorMessage := "Some error happened."
return &zencoder.JobDetails{
Job: &zencoder.Job{
InputMediaFile: &zencoder.MediaFile{
Url: "http://nyt.net/input.mov",
Format: "mov",
VideoCodec: "ProRes422",
Width: 1920,
Height: 1080,
DurationInMs: 10000,
ErrorMessage: &errorMessage,
},
CreatedAt: "2016-11-05T05:02:57Z",
FinishedAt: "2016-11-05T05:02:57Z",
UpdatedAt: "2016-11-05T05:02:57Z",
SubmittedAt: "2016-11-05T05:02:57Z",
OutputMediaFiles: []*zencoder.MediaFile{
{
Url: "https://mybucket.s3.amazonaws.com/destination-dir/output1.mp4",
Format: "mp4",
VideoCodec: "h264",
Width: 1920,
Height: 1080,
DurationInMs: 10000,
},
{
Url: "https://mybucket.s3.amazonaws.com/destination-dir/output2.webm",
Format: "webm",
VideoCodec: "vp8",
Width: 1080,
Height: 720,
DurationInMs: 10000,
},
},
},
}, nil
}
return &zencoder.JobDetails{
Job: &zencoder.Job{
InputMediaFile: &zencoder.MediaFile{
Expand Down
Loading

0 comments on commit a56d8da

Please sign in to comment.