Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
fix(tests): build docker image as first test step
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mboersma committed Jul 18, 2014
1 parent d3b0783 commit 2507e91
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 63 deletions.
29 changes: 15 additions & 14 deletions builder/tests/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,11 @@ import (

func runDeisBuilderTest(
t *testing.T, testSessionUID string, etcdPort string, servicePort string) {
var err error
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
done := make(chan bool, 1)
err := dockercliutils.BuildImage(t, "../", "deis/builder:"+testSessionUID)
if err != nil {
t.Fatal(err)
}
dockercliutils.RunDeisDataTest(t, "--name", "deis-builder-data",
"-v", "/var/lib/docker", "deis/base", "/bin/true")
//docker run --name deis-builder -p 2223:22 -e PUBLISH=22
// -e HOST=${COREOS_PRIVATE_IPV4} -e PORT=2223
// --volumes-from deis-builder-data --privileged deis/builder
ipaddr := utils.GetHostIPAddress()
done <- true
go func() {
Expand All @@ -47,24 +41,31 @@ func runDeisBuilderTest(
}

func TestBuilder(t *testing.T) {
setkeys := []string{"/deis/registry/protocol",
setkeys := []string{
"/deis/registry/protocol",
"deis/registry/host",
"/deis/registry/port",
"/deis/cache/host",
"/deis/cache/port"}
setdir := []string{"/deis/controller",
"/deis/cache/port",
}
setdir := []string{
"/deis/controller",
"/deis/cache",
"/deis/database",
"/deis/registry",
"/deis/domains"}
var testSessionUID = utils.NewUuid()
fmt.Println("UUID for the session Builder Test :" + testSessionUID)
"/deis/domains",
}
testSessionUID := utils.NewUuid()
err := dockercliutils.BuildImage(t, "../", "deis/builder:"+testSessionUID)
if err != nil {
t.Fatal(err)
}
etcdPort := utils.GetRandomPort()
servicePort := utils.GetRandomPort()
dockercliutils.RunEtcdTest(t, testSessionUID, etcdPort)
Builderhandler := etcdutils.InitetcdValues(setdir, setkeys, etcdPort)
etcdutils.Publishvalues(t, Builderhandler)
fmt.Println("starting Builder Component test")
servicePort := utils.GetRandomPort()
runDeisBuilderTest(t, testSessionUID, etcdPort, servicePort)
// TODO: builder needs a few seconds to wake up here--fixme!
time.Sleep(5000 * time.Millisecond)
Expand Down
14 changes: 7 additions & 7 deletions cache/tests/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@ import (
)

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

func TestCache(t *testing.T) {
var testSessionUID = utils.NewUuid()
fmt.Println("UUID for the session Cache Test :" + testSessionUID)
testSessionUID := utils.NewUuid()
err := dockercliutils.BuildImage(t, "../", "deis/cache:"+testSessionUID)
if err != nil {
t.Fatal(err)
}
etcdPort := utils.GetRandomPort()
servicePort := utils.GetRandomPort()
dockercliutils.RunEtcdTest(t, testSessionUID, etcdPort)
fmt.Println("starting cache component test:")
servicePort := utils.GetRandomPort()
runDeisCacheTest(t, testSessionUID, etcdPort, servicePort)
dockercliutils.DeisServiceTest(
t, "deis-cache-"+testSessionUID, servicePort, "tcp")
Expand Down
24 changes: 14 additions & 10 deletions controller/tests/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@ import (
)

func runDeisControllerTest(t *testing.T, testSessionUID string, etcdPort string, servicePort string) {
var err error
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
done := make(chan bool, 1)
err := dockercliutils.BuildImage(t, "../", "deis/controller:"+testSessionUID)
if err != nil {
t.Fatal(err)
}
ipaddr := utils.GetHostIPAddress()
done <- true
go func() {
Expand All @@ -39,18 +36,25 @@ func runDeisControllerTest(t *testing.T, testSessionUID string, etcdPort string,
}

func TestController(t *testing.T) {
setkeys := []string{"/deis/registry/protocol",
setkeys := []string{
"/deis/registry/protocol",
"deis/registry/host",
"/deis/registry/port",
"/deis/cache/host",
"/deis/cache/port"}
setdir := []string{"/deis/controller",
"/deis/cache/port",
}
setdir := []string{
"/deis/controller",
"/deis/cache",
"/deis/database",
"/deis/registry",
"/deis/domains"}
var testSessionUID = utils.NewUuid()
fmt.Println("UUID for the session Controller Test :" + testSessionUID)
"/deis/domains",
}
testSessionUID := utils.NewUuid()
err := dockercliutils.BuildImage(t, "../", "deis/controller:"+testSessionUID)
if err != nil {
t.Fatal(err)
}
etcdPort := utils.GetRandomPort()
servicePort := utils.GetRandomPort()
dbPort := utils.GetRandomPort()
Expand Down
14 changes: 7 additions & 7 deletions database/tests/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@ import (

func runDeisDatabaseTest(
t *testing.T, testSessionUID string, etcdPort string, servicePort string) {
var err error
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
done := make(chan bool, 1)
err := dockercliutils.BuildImage(t, "../", "deis/database:"+testSessionUID)
if err != nil {
t.Fatal(err)
}
dockercliutils.RunDeisDataTest(t, "--name", "deis-database-data",
"-v", "/var/lib/postgresql", "deis/base", "true")
ipaddr := utils.GetHostIPAddress()
Expand All @@ -42,12 +39,15 @@ func runDeisDatabaseTest(
}

func TestDatabase(t *testing.T) {
var testSessionUID = utils.NewUuid()
fmt.Println("UUID for the session Cache Test :" + testSessionUID)
testSessionUID := utils.NewUuid()
err := dockercliutils.BuildImage(t, "../", "deis/database:"+testSessionUID)
if err != nil {
t.Fatal(err)
}
etcdPort := utils.GetRandomPort()
servicePort := utils.GetRandomPort()
dockercliutils.RunEtcdTest(t, testSessionUID, etcdPort)
fmt.Println("starting Database component test:")
servicePort := utils.GetRandomPort()
runDeisDatabaseTest(t, testSessionUID, etcdPort, servicePort)
dockercliutils.DeisServiceTest(
t, "deis-database-"+testSessionUID, servicePort, "tcp")
Expand Down
14 changes: 7 additions & 7 deletions logger/tests/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@ import (

func runDeisLoggerTest(
t *testing.T, testSessionUID string, etcdPort string, servicePort string) {
var err error
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
done := make(chan bool, 1)
err := dockercliutils.BuildImage(t, "../", "deis/logger:"+testSessionUID)
if err != nil {
t.Fatal(err)
}
dockercliutils.RunDeisDataTest(t, "--name", "deis-logger-data",
"-v", "/var/log/deis", "deis/base", "true")
ipaddr := utils.GetHostIPAddress()
Expand All @@ -39,12 +36,15 @@ func runDeisLoggerTest(
}

func TestLogger(t *testing.T) {
var testSessionUID = utils.NewUuid()
testSessionUID := utils.NewUuid()
err := dockercliutils.BuildImage(t, "../", "deis/logger:"+testSessionUID)
if err != nil {
t.Fatal(err)
}
etcdPort := utils.GetRandomPort()
servicePort := utils.GetRandomPort()
fmt.Println("UUID for the session logger Test :" + testSessionUID)
dockercliutils.RunEtcdTest(t, testSessionUID, etcdPort)
fmt.Println("starting logger component test:")
servicePort := utils.GetRandomPort()
runDeisLoggerTest(t, testSessionUID, etcdPort, servicePort)
dockercliutils.DeisServiceTest(
t, "deis-logger-"+testSessionUID, servicePort, "udp")
Expand Down
14 changes: 7 additions & 7 deletions registry/tests/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@ import (

func runDeisRegistryTest(
t *testing.T, testSessionUID string, etcdPort string, servicePort string) {
var err error
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
done := make(chan bool, 1)
err := dockercliutils.BuildImage(t, "../", "deis/registry:"+testSessionUID)
if err != nil {
t.Fatal(err)
}
dockercliutils.RunDeisDataTest(t, "--name", "deis-registry-data",
"-v", "/data", "deis/base", "/bin/true")
ipaddr := utils.GetHostIPAddress()
Expand All @@ -41,12 +38,15 @@ func runDeisRegistryTest(
}

func TestRegistry(t *testing.T) {
var testSessionUID = utils.NewUuid()
fmt.Println("UUID for the session registry Test :" + testSessionUID)
testSessionUID := utils.NewUuid()
err := dockercliutils.BuildImage(t, "../", "deis/registry:"+testSessionUID)
if err != nil {
t.Fatal(err)
}
etcdPort := utils.GetRandomPort()
servicePort := utils.GetRandomPort()
dockercliutils.RunEtcdTest(t, testSessionUID, etcdPort)
fmt.Println("starting registry component test")
servicePort := utils.GetRandomPort()
runDeisRegistryTest(t, testSessionUID, etcdPort, servicePort)
dockercliutils.DeisServiceTest(
t, "deis-registry-"+testSessionUID, servicePort, "http")
Expand Down
26 changes: 15 additions & 11 deletions router/tests/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@ import (

func runDeisRouterTest(
t *testing.T, testSessionID string, etcdPort string, servicePort string) {
var err error
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
done := make(chan bool, 1)
err := dockercliutils.BuildImage(t, "../", "deis/router:"+testSessionID)
if err != nil {
t.Fatal(err)
}
ipaddr := utils.GetHostIPAddress()
done <- true
go func() {
Expand All @@ -40,24 +37,31 @@ func runDeisRouterTest(
}

func TestRouter(t *testing.T) {
setkeys := []string{"deis/controller/host",
setkeys := []string{
"deis/controller/host",
"/deis/controller/port",
"/deis/builder/host",
"/deis/builder/port"}
setdir := []string{"/deis/controller",
"/deis/builder/port",
}
setdir := []string{
"/deis/controller",
"/deis/router",
"/deis/database",
"/deis/services",
"/deis/builder",
"/deis/domains"}
var testSessionID = utils.NewUuid()
fmt.Println("UUID for the session Router Test :" + testSessionID)
"/deis/domains",
}
testSessionID := utils.NewUuid()
err := dockercliutils.BuildImage(t, "../", "deis/router:"+testSessionID)
if err != nil {
t.Fatal(err)
}
etcdPort := utils.GetRandomPort()
servicePort := utils.GetRandomPort()
dockercliutils.RunEtcdTest(t, testSessionID, etcdPort)
Routerhandler := etcdutils.InitetcdValues(setdir, setkeys, etcdPort)
etcdutils.Publishvalues(t, Routerhandler)
fmt.Println("starting Router Component test")
servicePort := utils.GetRandomPort()
runDeisRouterTest(t, testSessionID, etcdPort, servicePort)
// TODO: nginx needs a few seconds to wake up here--fixme!
time.Sleep(5000 * time.Millisecond)
Expand Down

0 comments on commit 2507e91

Please sign in to comment.