Skip to content

Commit 2507e91

Browse files
committed
fix(tests): build docker image as first test step
This keeps us from starting etcd and other test support services minutes before they are needed, and makes the component tests fail faster when there are build errors, which is not uncommon.
1 parent d3b0783 commit 2507e91

7 files changed

Lines changed: 72 additions & 63 deletions

File tree

builder/tests/builder_test.go

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,11 @@ import (
1212

1313
func runDeisBuilderTest(
1414
t *testing.T, testSessionUID string, etcdPort string, servicePort string) {
15+
var err error
1516
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
1617
done := make(chan bool, 1)
17-
err := dockercliutils.BuildImage(t, "../", "deis/builder:"+testSessionUID)
18-
if err != nil {
19-
t.Fatal(err)
20-
}
2118
dockercliutils.RunDeisDataTest(t, "--name", "deis-builder-data",
2219
"-v", "/var/lib/docker", "deis/base", "/bin/true")
23-
//docker run --name deis-builder -p 2223:22 -e PUBLISH=22
24-
// -e HOST=${COREOS_PRIVATE_IPV4} -e PORT=2223
25-
// --volumes-from deis-builder-data --privileged deis/builder
2620
ipaddr := utils.GetHostIPAddress()
2721
done <- true
2822
go func() {
@@ -47,24 +41,31 @@ func runDeisBuilderTest(
4741
}
4842

4943
func TestBuilder(t *testing.T) {
50-
setkeys := []string{"/deis/registry/protocol",
44+
setkeys := []string{
45+
"/deis/registry/protocol",
5146
"deis/registry/host",
5247
"/deis/registry/port",
5348
"/deis/cache/host",
54-
"/deis/cache/port"}
55-
setdir := []string{"/deis/controller",
49+
"/deis/cache/port",
50+
}
51+
setdir := []string{
52+
"/deis/controller",
5653
"/deis/cache",
5754
"/deis/database",
5855
"/deis/registry",
59-
"/deis/domains"}
60-
var testSessionUID = utils.NewUuid()
61-
fmt.Println("UUID for the session Builder Test :" + testSessionUID)
56+
"/deis/domains",
57+
}
58+
testSessionUID := utils.NewUuid()
59+
err := dockercliutils.BuildImage(t, "../", "deis/builder:"+testSessionUID)
60+
if err != nil {
61+
t.Fatal(err)
62+
}
6263
etcdPort := utils.GetRandomPort()
63-
servicePort := utils.GetRandomPort()
6464
dockercliutils.RunEtcdTest(t, testSessionUID, etcdPort)
6565
Builderhandler := etcdutils.InitetcdValues(setdir, setkeys, etcdPort)
6666
etcdutils.Publishvalues(t, Builderhandler)
6767
fmt.Println("starting Builder Component test")
68+
servicePort := utils.GetRandomPort()
6869
runDeisBuilderTest(t, testSessionUID, etcdPort, servicePort)
6970
// TODO: builder needs a few seconds to wake up here--fixme!
7071
time.Sleep(5000 * time.Millisecond)

cache/tests/cache_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@ import (
99
)
1010

1111
func runDeisCacheTest(t *testing.T, testSessionUID string, etcdPort string, servicePort string) {
12+
var err error
1213
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
1314
done := make(chan bool, 1)
14-
err := dockercliutils.BuildImage(t, "../", "deis/cache:"+testSessionUID)
15-
if err != nil {
16-
t.Fatal(err)
17-
}
1815
ipaddr := utils.GetHostIPAddress()
1916
done <- true
2017
go func() {
@@ -35,12 +32,15 @@ func runDeisCacheTest(t *testing.T, testSessionUID string, etcdPort string, serv
3532
}
3633

3734
func TestCache(t *testing.T) {
38-
var testSessionUID = utils.NewUuid()
39-
fmt.Println("UUID for the session Cache Test :" + testSessionUID)
35+
testSessionUID := utils.NewUuid()
36+
err := dockercliutils.BuildImage(t, "../", "deis/cache:"+testSessionUID)
37+
if err != nil {
38+
t.Fatal(err)
39+
}
4040
etcdPort := utils.GetRandomPort()
41-
servicePort := utils.GetRandomPort()
4241
dockercliutils.RunEtcdTest(t, testSessionUID, etcdPort)
4342
fmt.Println("starting cache component test:")
43+
servicePort := utils.GetRandomPort()
4444
runDeisCacheTest(t, testSessionUID, etcdPort, servicePort)
4545
dockercliutils.DeisServiceTest(
4646
t, "deis-cache-"+testSessionUID, servicePort, "tcp")

controller/tests/controller_test.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,9 @@ import (
1212
)
1313

1414
func runDeisControllerTest(t *testing.T, testSessionUID string, etcdPort string, servicePort string) {
15+
var err error
1516
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
1617
done := make(chan bool, 1)
17-
err := dockercliutils.BuildImage(t, "../", "deis/controller:"+testSessionUID)
18-
if err != nil {
19-
t.Fatal(err)
20-
}
2118
ipaddr := utils.GetHostIPAddress()
2219
done <- true
2320
go func() {
@@ -39,18 +36,25 @@ func runDeisControllerTest(t *testing.T, testSessionUID string, etcdPort string,
3936
}
4037

4138
func TestController(t *testing.T) {
42-
setkeys := []string{"/deis/registry/protocol",
39+
setkeys := []string{
40+
"/deis/registry/protocol",
4341
"deis/registry/host",
4442
"/deis/registry/port",
4543
"/deis/cache/host",
46-
"/deis/cache/port"}
47-
setdir := []string{"/deis/controller",
44+
"/deis/cache/port",
45+
}
46+
setdir := []string{
47+
"/deis/controller",
4848
"/deis/cache",
4949
"/deis/database",
5050
"/deis/registry",
51-
"/deis/domains"}
52-
var testSessionUID = utils.NewUuid()
53-
fmt.Println("UUID for the session Controller Test :" + testSessionUID)
51+
"/deis/domains",
52+
}
53+
testSessionUID := utils.NewUuid()
54+
err := dockercliutils.BuildImage(t, "../", "deis/controller:"+testSessionUID)
55+
if err != nil {
56+
t.Fatal(err)
57+
}
5458
etcdPort := utils.GetRandomPort()
5559
servicePort := utils.GetRandomPort()
5660
dbPort := utils.GetRandomPort()

database/tests/database_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@ import (
1010

1111
func runDeisDatabaseTest(
1212
t *testing.T, testSessionUID string, etcdPort string, servicePort string) {
13+
var err error
1314
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
1415
done := make(chan bool, 1)
15-
err := dockercliutils.BuildImage(t, "../", "deis/database:"+testSessionUID)
16-
if err != nil {
17-
t.Fatal(err)
18-
}
1916
dockercliutils.RunDeisDataTest(t, "--name", "deis-database-data",
2017
"-v", "/var/lib/postgresql", "deis/base", "true")
2118
ipaddr := utils.GetHostIPAddress()
@@ -42,12 +39,15 @@ func runDeisDatabaseTest(
4239
}
4340

4441
func TestDatabase(t *testing.T) {
45-
var testSessionUID = utils.NewUuid()
46-
fmt.Println("UUID for the session Cache Test :" + testSessionUID)
42+
testSessionUID := utils.NewUuid()
43+
err := dockercliutils.BuildImage(t, "../", "deis/database:"+testSessionUID)
44+
if err != nil {
45+
t.Fatal(err)
46+
}
4747
etcdPort := utils.GetRandomPort()
48-
servicePort := utils.GetRandomPort()
4948
dockercliutils.RunEtcdTest(t, testSessionUID, etcdPort)
5049
fmt.Println("starting Database component test:")
50+
servicePort := utils.GetRandomPort()
5151
runDeisDatabaseTest(t, testSessionUID, etcdPort, servicePort)
5252
dockercliutils.DeisServiceTest(
5353
t, "deis-database-"+testSessionUID, servicePort, "tcp")

logger/tests/logger_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@ import (
1010

1111
func runDeisLoggerTest(
1212
t *testing.T, testSessionUID string, etcdPort string, servicePort string) {
13+
var err error
1314
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
1415
done := make(chan bool, 1)
15-
err := dockercliutils.BuildImage(t, "../", "deis/logger:"+testSessionUID)
16-
if err != nil {
17-
t.Fatal(err)
18-
}
1916
dockercliutils.RunDeisDataTest(t, "--name", "deis-logger-data",
2017
"-v", "/var/log/deis", "deis/base", "true")
2118
ipaddr := utils.GetHostIPAddress()
@@ -39,12 +36,15 @@ func runDeisLoggerTest(
3936
}
4037

4138
func TestLogger(t *testing.T) {
42-
var testSessionUID = utils.NewUuid()
39+
testSessionUID := utils.NewUuid()
40+
err := dockercliutils.BuildImage(t, "../", "deis/logger:"+testSessionUID)
41+
if err != nil {
42+
t.Fatal(err)
43+
}
4344
etcdPort := utils.GetRandomPort()
44-
servicePort := utils.GetRandomPort()
45-
fmt.Println("UUID for the session logger Test :" + testSessionUID)
4645
dockercliutils.RunEtcdTest(t, testSessionUID, etcdPort)
4746
fmt.Println("starting logger component test:")
47+
servicePort := utils.GetRandomPort()
4848
runDeisLoggerTest(t, testSessionUID, etcdPort, servicePort)
4949
dockercliutils.DeisServiceTest(
5050
t, "deis-logger-"+testSessionUID, servicePort, "udp")

registry/tests/registry_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,9 @@ import (
1111

1212
func runDeisRegistryTest(
1313
t *testing.T, testSessionUID string, etcdPort string, servicePort string) {
14+
var err error
1415
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
1516
done := make(chan bool, 1)
16-
err := dockercliutils.BuildImage(t, "../", "deis/registry:"+testSessionUID)
17-
if err != nil {
18-
t.Fatal(err)
19-
}
2017
dockercliutils.RunDeisDataTest(t, "--name", "deis-registry-data",
2118
"-v", "/data", "deis/base", "/bin/true")
2219
ipaddr := utils.GetHostIPAddress()
@@ -41,12 +38,15 @@ func runDeisRegistryTest(
4138
}
4239

4340
func TestRegistry(t *testing.T) {
44-
var testSessionUID = utils.NewUuid()
45-
fmt.Println("UUID for the session registry Test :" + testSessionUID)
41+
testSessionUID := utils.NewUuid()
42+
err := dockercliutils.BuildImage(t, "../", "deis/registry:"+testSessionUID)
43+
if err != nil {
44+
t.Fatal(err)
45+
}
4646
etcdPort := utils.GetRandomPort()
47-
servicePort := utils.GetRandomPort()
4847
dockercliutils.RunEtcdTest(t, testSessionUID, etcdPort)
4948
fmt.Println("starting registry component test")
49+
servicePort := utils.GetRandomPort()
5050
runDeisRegistryTest(t, testSessionUID, etcdPort, servicePort)
5151
dockercliutils.DeisServiceTest(
5252
t, "deis-registry-"+testSessionUID, servicePort, "http")

router/tests/router_test.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,9 @@ import (
1212

1313
func runDeisRouterTest(
1414
t *testing.T, testSessionID string, etcdPort string, servicePort string) {
15+
var err error
1516
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
1617
done := make(chan bool, 1)
17-
err := dockercliutils.BuildImage(t, "../", "deis/router:"+testSessionID)
18-
if err != nil {
19-
t.Fatal(err)
20-
}
2118
ipaddr := utils.GetHostIPAddress()
2219
done <- true
2320
go func() {
@@ -40,24 +37,31 @@ func runDeisRouterTest(
4037
}
4138

4239
func TestRouter(t *testing.T) {
43-
setkeys := []string{"deis/controller/host",
40+
setkeys := []string{
41+
"deis/controller/host",
4442
"/deis/controller/port",
4543
"/deis/builder/host",
46-
"/deis/builder/port"}
47-
setdir := []string{"/deis/controller",
44+
"/deis/builder/port",
45+
}
46+
setdir := []string{
47+
"/deis/controller",
4848
"/deis/router",
4949
"/deis/database",
5050
"/deis/services",
5151
"/deis/builder",
52-
"/deis/domains"}
53-
var testSessionID = utils.NewUuid()
54-
fmt.Println("UUID for the session Router Test :" + testSessionID)
52+
"/deis/domains",
53+
}
54+
testSessionID := utils.NewUuid()
55+
err := dockercliutils.BuildImage(t, "../", "deis/router:"+testSessionID)
56+
if err != nil {
57+
t.Fatal(err)
58+
}
5559
etcdPort := utils.GetRandomPort()
56-
servicePort := utils.GetRandomPort()
5760
dockercliutils.RunEtcdTest(t, testSessionID, etcdPort)
5861
Routerhandler := etcdutils.InitetcdValues(setdir, setkeys, etcdPort)
5962
etcdutils.Publishvalues(t, Routerhandler)
6063
fmt.Println("starting Router Component test")
64+
servicePort := utils.GetRandomPort()
6165
runDeisRouterTest(t, testSessionID, etcdPort, servicePort)
6266
// TODO: nginx needs a few seconds to wake up here--fixme!
6367
time.Sleep(5000 * time.Millisecond)

0 commit comments

Comments
 (0)