forked from taskcluster/taskcluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple_docker_test.go
51 lines (45 loc) · 1.32 KB
/
simple_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
// +build simple docker
package main
import (
"fmt"
"os"
"path/filepath"
"testing"
)
// Note we don't want to set config.NumberOfTasksToRun on multiuser engine
// since new OS users would get created, so we limit this test to simple and
// docker engines.
func TestNewTaskDirectoryForEachTask(t *testing.T) {
defer setup(t)()
config.NumberOfTasksToRun = 3
payload := GenericWorkerPayload{
Command: returnExitCode(0),
MaxRunTime: 10,
}
td := testTask(t)
for i := uint(0); i < config.NumberOfTasksToRun; i++ {
_ = scheduleTask(t, td, payload)
}
execute(t, TASKS_COMPLETE)
// scan task directories, to make sure there are three unique backing log files,
// implying that each task ran in its own directory
var backingLogsFound uint = 0
err := filepath.Walk(config.TasksDir, func(path string, info os.FileInfo, err error) error {
if info.IsDir() {
t.Logf("Found dir %v", path)
return nil
}
t.Logf("Found file %v", path)
if info.Name() != "live_backing.log" {
return fmt.Errorf("Discovered file with name %q but was expecting %q", info.Name(), "live_backing.log")
}
backingLogsFound++
return nil
})
if err != nil {
t.Fatalf("%v", err)
}
if backingLogsFound != config.NumberOfTasksToRun {
t.Fatalf("Expected to find %v backing logs, but found %v", config.NumberOfTasksToRun, backingLogsFound)
}
}