-
Notifications
You must be signed in to change notification settings - Fork 251
/
taskcluster_proxy_test.go
81 lines (70 loc) · 2.14 KB
/
taskcluster_proxy_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package main
import (
"encoding/base64"
"os"
"testing"
"github.com/mcuadros/go-defaults"
)
func TestTaskclusterProxy(t *testing.T) {
setup(t)
taskID := CreateArtifactFromFile(t, "SampleArtifacts/_/X.txt", "SampleArtifacts/_/X.txt")
// We base64 encode the url, because I can't get to the bottom of the
// windows command escaping issues, so I haven't worked out how to
// correctly escape the URL in the batch script that is generated from the
// command. Base64 encoded strings don't require any batch script escaping,
// so this is a cheap solution to the problem.
base64EncodedURL := base64.StdEncoding.EncodeToString(
// note that curlget.go substitutes the literal TASKCLUSTER_PROXY_URL
// with the actual value of the environment variable in its environment
[]byte("TASKCLUSTER_PROXY_URL/queue/v1/task/" + taskID + "/artifacts/SampleArtifacts%2F_%2FX.txt"),
)
payload := GenericWorkerPayload{
Command: append(
append(
GoEnv(),
// long enough to reclaim and get new credentials
sleep(12)...,
),
goRun(
"curlget.go",
base64EncodedURL,
)...,
),
MaxRunTime: 180,
Env: map[string]string{},
Features: FeatureFlags{
TaskclusterProxy: true,
},
}
defaults.SetDefaults(&payload)
// need to set _after_ setting defaults, since this is the zero value
// so setting it before would cause SetDefaults to change it to true
payload.Features.LiveLog = false
for _, envVar := range []string{
"PATH",
"GOPATH",
"GOROOT",
} {
if v, exists := os.LookupEnv(envVar); exists {
payload.Env[envVar] = v
}
}
td := testTask(t)
td.Scopes = []string{"queue:get-artifact:SampleArtifacts/_/X.txt"}
td.Dependencies = []string{taskID}
reclaimEvery5Seconds = true
taskID = submitAndAssert(t, td, payload, "completed", "completed")
reclaimEvery5Seconds = false
expectedArtifacts := ExpectedArtifacts{
"public/logs/live_backing.log": {
Extracts: []string{
"test artifact",
"Successfully refreshed taskcluster-proxy credentials",
},
ContentType: "text/plain; charset=utf-8",
ContentEncoding: "gzip",
Expires: td.Expires,
},
}
expectedArtifacts.Validate(t, taskID, 0)
}