-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy pathcontroller_test.go
More file actions
63 lines (60 loc) · 1.71 KB
/
controller_test.go
File metadata and controls
63 lines (60 loc) · 1.71 KB
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
package tests
import (
"fmt"
"testing"
"time"
"github.com/deis/deis/tests/dockercli"
"github.com/deis/deis/tests/etcdutils"
"github.com/deis/deis/tests/mock"
"github.com/deis/deis/tests/utils"
)
func TestController(t *testing.T) {
var err error
setkeys := []string{
"/deis/registry/protocol",
"deis/registry/host",
"/deis/registry/port",
"/deis/cache/host",
"/deis/cache/port",
}
setdir := []string{
"/deis/controller",
"/deis/cache",
"/deis/database",
"/deis/registry",
"/deis/domains",
}
tag, etcdPort := utils.BuildTag(), utils.RandomPort()
etcdName := "deis-etcd-" + tag
cli, stdout, stdoutPipe := dockercli.NewClient()
dockercli.RunTestEtcd(t, etcdName, etcdPort)
defer cli.CmdRm("-f", etcdName)
handler := etcdutils.InitEtcd(setdir, setkeys, etcdPort)
etcdutils.PublishEtcd(t, handler)
mock.RunMockDatabase(t, tag, etcdPort, utils.RandomPort())
defer cli.CmdRm("-f", "deis-test-database-"+tag)
host, port := utils.HostAddress(), utils.RandomPort()
fmt.Printf("--- Run deis/controller:%s at %s:%s\n", tag, host, port)
name := "deis-controller-" + tag
defer cli.CmdRm("-f", name)
go func() {
cli.CmdRm("-f", name)
err = dockercli.RunContainer(cli,
"--name", name,
"--rm",
"-p", port+":8000",
"-e", "EXTERNAL_PORT="+port,
"-e", "HOST="+host,
"-e", "ETCD_PORT="+etcdPort,
"deis/controller:"+tag)
}()
dockercli.PrintToStdout(t, stdout, stdoutPipe, "Booting")
if err != nil {
t.Fatal(err)
}
// FIXME: Wait until etcd keys are published
time.Sleep(5000 * time.Millisecond)
dockercli.DeisServiceTest(t, name, port, "http")
etcdutils.VerifyEtcdValue(t, "/deis/controller/host", host, etcdPort)
etcdutils.VerifyEtcdValue(t, "/deis/controller/port", port, etcdPort)
}