forked from taskcluster/taskcluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
taskstatus_broken_on_docker_test.go
56 lines (48 loc) · 1.39 KB
/
taskstatus_broken_on_docker_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
//go:build !docker
package main
import (
"path/filepath"
"testing"
"time"
)
// Makes sure that if a running task gets cancelled externally, the worker does not shut down
func TestResolveResolvedTask(t *testing.T) {
setup(t)
td, payload := CancelTask(t)
_ = submitAndAssert(t, td, payload, "exception", "canceled")
}
func TestReclaimCancelledTask(t *testing.T) {
setup(t)
mounts := []MountEntry{
// requires scope "generic-worker:cache:banana-cache"
&WritableDirectoryCache{
CacheName: "banana-cache",
Directory: filepath.Join("my-task-caches", "bananas"),
},
}
td, payload := CancelTask(t)
td.Scopes = []string{"generic-worker:cache:banana-cache"}
payload.Command = append(payload.Command, sleep(300)...)
payload.Mounts = toMountArray(t, &mounts)
reclaimEvery5Seconds = true
defer func() {
reclaimEvery5Seconds = false
}()
start := time.Now()
taskID := submitAndAssert(t, td, payload, "exception", "canceled")
end := time.Now()
expectedArtifacts := ExpectedArtifacts{
"public/logs/live_backing.log": {
Extracts: []string{
"Preserving cache: Moving",
},
ContentType: "text/plain; charset=utf-8",
ContentEncoding: "gzip",
Expires: td.Expires,
},
}
expectedArtifacts.Validate(t, taskID, 0)
if duration := end.Sub(start); duration.Seconds() > 280 {
t.Fatalf("Task should have expired long before the max run time (300s) but took %v", duration)
}
}