Artem Nikitin
Artem Nikitin

Reputation: 845

Android app uploaded in Device Farm via AWS SDK for Go never changed status from INITIALIZED

I'm trying to use AWS SDK for Go to automate app runs in AWS Device Farm. But any app that uploaded with Go version of SDK never changed status from "INITIALIZED". If I upload them via AWS Console web UI, then all will be fine.

Example of code for upload: func uploadApp(client *devicefarm.DeviceFarm, appType, projectArn string) string { params := &devicefarm.CreateUploadInput{ Name: aws.String(*appName), ProjectArn: aws.String(projectArn), Type: aws.String(appType), } resp, err := client.CreateUpload(params) if err != nil { log.Fatal("Failed to upload an app because of: ", err.Error()) } log.Println("Upload ARN:", *resp.Upload.Arn) return *resp.Upload.Arn } In response I got something like:
{ Upload: { Arn: "arn:aws:devicefarm:us-west-2:091463382595:upload:c632e325-266b-4bda-a74d-0acec1e2a5ae/9fbbf140-e377-4de9-b7df-dd18a21b2bca", Created: 2016-01-15 14:27:31 +0000 UTC, Name: "app-debug-unaligned.apk", Status: "INITIALIZED", Type: "ANDROID_APP", Url: "bla-bla-bla" } }
With time status never changes from "INITIALIZED". As I mentioned, apps which run scheduled from UI works fine.

How to figure it out reason of this ?

=======================================

Solution:

1) After CreateUpload it requires to upload a file using pre-signed S3 link in the response
2) Upload should be executed via HTTP PUT request by received URL with file content in the body
3) In &devicefarm.CreateUploadInput should be specified ContentTypeparameter. For PUT request same value for Content-Type header should be used
4) If PUT request will be send from Go code, then Content-Length header should be set manually

Upvotes: 2

Views: 767

Answers (1)

Michael Willingham
Michael Willingham

Reputation: 912

When you call the CreateUpload API, Device Farm will return an "Upload" response containing a "Url" field.

{ Upload: { Arn: "arn:aws:devicefarm:us-west-2:....", Created: 2016-01-15 14:27:31 +0000 UTC, Name: "app-name.apk", Status: "INITIALIZED", Type: "ANDROID_APP", Url: "bla-bla-bla" } }

The returned url, "bla-bla-bla", is a pre-signed S3 url for you to upload your application. Documentation on using a pre-signed url to upload an object: http://docs.aws.amazon.com/AmazonS3/latest/dev/PresignedUrlUploadObject.html

Once your application has been uploaded, the app will be processed. The status of your upload will change to "PROCESSING" and "SUCCEEDED" (or "FAILED" if something is wrong). Once it's in "SUCCEEDED" status, you can use it to schedule a run.

Upvotes: 2

Related Questions