forked from taskcluster/taskcluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlivelog_test.go
71 lines (57 loc) · 1.7 KB
/
livelog_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
package main
import (
"strings"
"testing"
"github.com/mcuadros/go-defaults"
)
func TestCustomLogPaths(t *testing.T) {
setup(t)
customLiveLogName := "public/banana.log"
customBackingLogName := "public/banana_backing.log"
payload := GenericWorkerPayload{
Command: helloGoodbye(),
MaxRunTime: 30,
Logs: Logs{
Backing: customBackingLogName,
Live: customLiveLogName,
},
}
defaults.SetDefaults(&payload)
td := testTask(t)
taskID := submitAndAssert(t, td, payload, "completed", "completed")
bytes := getArtifactContent(t, taskID, customBackingLogName)
logtext := string(bytes)
if !strings.Contains(logtext, "goodbye world!") {
t.Fatalf("Was expecting backing log file to contain 'goodbye world!' but it doesn't")
}
bytes = getArtifactContent(t, taskID, customLiveLogName)
logtext = string(bytes)
if !strings.Contains(logtext, "hello world!") {
t.Fatalf("Was expecting live log file to contain 'hello world!' but it doesn't")
}
}
func TestDisableLiveLogFeature(t *testing.T) {
setup(t)
payload := GenericWorkerPayload{
Command: helloGoodbye(),
MaxRunTime: 30,
}
defaults.SetDefaults(&payload)
// this has to be set _after_ setting defaults, since we are explicitly setting to the zero value!
payload.Features.LiveLog = false
td := testTask(t)
taskID := submitAndAssert(t, td, payload, "completed", "completed")
// some required substrings - not all, just a selection
expectedArtifacts := ExpectedArtifacts{
"public/logs/live_backing.log": {
Extracts: []string{
"hello world!",
"goodbye world!",
},
ContentType: "text/plain; charset=utf-8",
ContentEncoding: "gzip",
Expires: td.Expires,
},
}
expectedArtifacts.Validate(t, taskID, 0)
}