Skip to content

Commit a1ba071

Browse files
smothikimboersma
authored andcommitted
test(component): add working component tests
Added fallback function to get IP of running host Added abstract function for running service level ping test Removed debug print statements
1 parent 6edda25 commit a1ba071

18 files changed

Lines changed: 149 additions & 326 deletions

File tree

builder/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ test-unit:
3333
@echo no unit tests
3434

3535
test-functional:
36-
GOPATH=$(CURDIR)/../tests/_vendor:$(GOPATH) go test -timeout 30m -v ./test/...
36+
GOPATH=$(CURDIR)/../tests/_vendor:$(GOPATH) go test -timeout 7m -v ./test/...

builder/test/builderComponent_test.go

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,27 @@ import (
44
"fmt"
55
"github.com/deis/deis/tests/dockercliutils"
66
"github.com/deis/deis/tests/etcdutils"
7-
"github.com/deis/deis/tests/mockserviceutils"
87
"github.com/deis/deis/tests/utils"
9-
"net/http"
10-
"strings"
118
"testing"
129
"time"
1310
)
1411

15-
func runDeisBuilderTest(t *testing.T, testSessionUid string) {
12+
func runDeisBuilderTest(t *testing.T, testSessionUid string,port string) {
1613
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
1714
done := make(chan bool, 1)
1815
dockercliutils.BuildDockerfile(t, "../", "deis/builder:"+testSessionUid)
1916
dockercliutils.RunDeisDataTest(t, "--name", "deis-builder-data", "-v", "/var/lib/docker", "deis/base", "/bin/true")
2017
//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
21-
IPAddress := func() string {
22-
var Ip string
23-
if utils.GetHostOs() == "darwin" {
24-
Ip = "172.17.8.100"
25-
}
26-
return Ip
27-
}()
18+
IPAddress := utils.GetHostIpAddress()
2819
done <- true
2920
go func() {
3021
<-done
31-
fmt.Println("inside run container")
32-
dockercliutils.RunContainer(t, cli, "--name", "deis-builder-"+testSessionUid, "-p", "2223:22", "-e", "PUBLISH=22", "-e", "STORAGE_DRIVER=aufs", "-e", "HOST="+IPAddress, "-e", "PORT=2223","--volumes-from","deis-builder-data","--privileged", "deis/builder:"+testSessionUid)
22+
dockercliutils.RunContainer(t, cli, "--name", "deis-builder-"+testSessionUid, "-p", "2223:22", "-e", "PUBLISH=22", "-e", "STORAGE_DRIVER=aufs", "-e", "HOST="+IPAddress, "-e","ETCD_PORT="+port, "-e", "PORT=2223","--volumes-from","deis-builder-data","--privileged", "deis/builder:"+testSessionUid)
3323
}()
3424
time.Sleep(5000 * time.Millisecond)
3525
dockercliutils.PrintToStdout(t, stdout, stdoutPipe, "deis-builder running")
3626
}
3727

38-
func deisBuilderServiceTest(t *testing.T, testSessionUid string) {
39-
IPAddress := dockercliutils.GetInspectData(t, "{{ .NetworkSettings.IPAddress }}", "deis-controller-"+testSessionUid)
40-
if strings.Contains(IPAddress, "Error") {
41-
t.Fatalf("worng IP %s", IPAddress)
42-
}
43-
url := "http://" + IPAddress + ":8000"
44-
response, err := http.Get(url)
45-
if err != nil {
46-
t.Fatalf("Not reachable %s", err)
47-
}
48-
fmt.Println(response)
49-
}
50-
5128
func TestBuild(t *testing.T) {
5229
setkeys := []string{"/deis/registry/protocol",
5330
"deis/registry/host",
@@ -61,14 +38,14 @@ func TestBuild(t *testing.T) {
6138
"/deis/domains"}
6239
fmt.Println("1st")
6340
var testSessionUid = utils.GetnewUuid()
41+
fmt.Println("UUID for the session Builder Test :"+testSessionUid)
42+
port := utils.GetRandomPort()
6443
//testSessionUid := "352aea64"
65-
dockercliutils.RunDummyEtcdTest(t, testSessionUid)
66-
fmt.Println("2nd")
67-
t.Logf("starting controller test: %v", testSessionUid)
68-
Builderhandler := etcdutils.InitetcdValues(setdir, setkeys)
44+
dockercliutils.RunEtcdTest(t, testSessionUid,port)
45+
Builderhandler := etcdutils.InitetcdValues(setdir, setkeys,port)
6946
etcdutils.Publishvalues(t, Builderhandler)
70-
fmt.Println("starting registry test")
71-
runDeisBuilderTest(t, testSessionUid)
72-
//deisBuilderServiceTest(t, testSessionUid)
73-
//dockercliutils.ClearTestSession(t, testSessionUid)
47+
fmt.Println("starting Builder Component test")
48+
runDeisBuilderTest(t, testSessionUid,port)
49+
dockercliutils.DeisServiceTest(t,"deis-builder-"+testSessionUid,"22","tcp")
50+
dockercliutils.ClearTestSession(t, testSessionUid)
7451
}

cache/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ test-unit:
3333
@echo no unit tests
3434

3535
test-functional:
36-
GOPATH=$(CURDIR)/../tests/_vendor:$(GOPATH) go test -v ./test/...
36+
GOPATH=$(CURDIR)/../tests/_vendor:$(GOPATH) go test -timeout 7m -v ./test/...

cache/test/cacheComponent_test.go

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,54 +4,35 @@ import (
44
"fmt"
55
"github.com/deis/deis/tests/dockercliutils"
66
"github.com/deis/deis/tests/utils"
7-
"net/http"
8-
"strings"
97
"testing"
108
)
119

12-
func deisCacheServiceTest(t *testing.T, testSessionUid string) {
13-
IPAddress := dockercliutils.GetInspectData(t, "{{ .NetworkSettings.IPAddress }}", "deis-logger-"+testSessionUid)
14-
if strings.Contains(IPAddress, "Error") {
15-
t.Fatalf("worng IP %s", IPAddress)
16-
}
17-
url := "http://" + IPAddress + ":6379"
18-
response, err := http.Get(url)
19-
if err != nil {
20-
t.Fatalf("Not reachable %s", err)
21-
}
22-
fmt.Println(response)
23-
}
2410

25-
func runDeisCacheTest(t *testing.T, testSessionUid string) {
11+
12+
func runDeisCacheTest(t *testing.T, testSessionUid string,port string) {
2613
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
2714
done := make(chan bool, 1)
2815
dockercliutils.BuildDockerfile(t, "../", "deis/cache:"+testSessionUid)
29-
IPAddress := func() string {
30-
var Ip string
31-
if utils.GetHostOs() == "darwin" {
32-
Ip = "172.17.8.100"
33-
}
34-
return Ip
35-
}()
16+
IPAddress := utils.GetHostIpAddress()
3617
done <- true
3718
go func() {
3819
<-done
39-
fmt.Println("inside run etcd")
4020
//docker run --name deis-cache -p 6379:6379 -e PUBLISH=6379 -e HOST=${COREOS_PRIVATE_IPV4} deis/cache
41-
dockercliutils.RunContainer(t, cli, "--name", "deis-cache-"+testSessionUid, "-p", "6379:6379", "-e", "PUBLISH=6379", "-e", "HOST="+IPAddress, "deis/cache:"+testSessionUid)
21+
dockercliutils.RunContainer(t, cli, "--name", "deis-cache-"+testSessionUid, "-p", "6379:6379", "-e", "PUBLISH=6379", "-e", "HOST="+IPAddress,"-e","ETCD_PORT="+port,"deis/cache:"+testSessionUid)
4222
}()
4323
dockercliutils.PrintToStdout(t, stdout, stdoutPipe, "started")
4424
}
4525

4626
func TestBuild(t *testing.T) {
47-
fmt.Println("1st")
4827
var testSessionUid = utils.GetnewUuid()
49-
dockercliutils.RunDummyEtcdTest(t, testSessionUid)
50-
t.Logf("starting cache test: %v", testSessionUid)
51-
fmt.Println("2nd")
52-
runDeisCacheTest(t, testSessionUid)
53-
//deisCacheServiceTest(t, testSessionUid)
54-
//dockercliutils.ClearTestSession(t, testSessionUid)
55-
fmt.Println("3rd")
28+
fmt.Println("UUID for the session Cache Test :"+testSessionUid)
29+
port := utils.GetRandomPort()
30+
//testSessionUid := "352aea64"
31+
dockercliutils.RunEtcdTest(t, testSessionUid,port)
32+
fmt.Println("starting cache compotest:")
33+
runDeisCacheTest(t, testSessionUid,port)
34+
dockercliutils.DeisServiceTest(t,"deis-cache-"+testSessionUid,"6379","tcp")
35+
dockercliutils.ClearTestSession(t, testSessionUid)
36+
5637

5738
}

controller/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ test-unit:
5252
venv/bin/python manage.py test --noinput api
5353

5454
test-functional:
55-
GOPATH=$(CURDIR)/../tests/_vendor:$(GOPATH) go test -timeout 30m -v ./test/...
55+
GOPATH=$(CURDIR)/../tests/_vendor:$(GOPATH) go test -timeout 7m -v ./test/...

controller/test/controllerComponent_test.go

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,47 +6,26 @@ import (
66
"github.com/deis/deis/tests/etcdutils"
77
"github.com/deis/deis/tests/mockserviceutils"
88
"github.com/deis/deis/tests/utils"
9-
"net/http"
10-
"strings"
119
"testing"
1210
"time"
1311
)
1412

15-
func runDeisControllerTest(t *testing.T, testSessionUid string) {
13+
func runDeisControllerTest(t *testing.T, testSessionUid string,port string) {
1614
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
1715
done := make(chan bool, 1)
1816
dockercliutils.BuildDockerfile(t, "../", "deis/controller:"+testSessionUid)
1917
//docker run --name deis-controller -p 8000:8000 -e PUBLISH=8000 -e HOST=${COREOS_PRIVATE_IPV4} --volumes-from=deis-logger deis/controller
20-
IPAddress := func() string {
21-
var Ip string
22-
if utils.GetHostOs() == "darwin" {
23-
Ip = "172.17.8.100"
24-
}
25-
return Ip
26-
}()
18+
IPAddress := utils.GetHostIpAddress()
2719
done <- true
2820
go func() {
2921
<-done
30-
fmt.Println("inside run container")
31-
dockercliutils.RunContainer(t, cli, "--name", "deis-controller-"+testSessionUid, "-p", "8000:8000", "-e", "PUBLISH=8000", "-e", "HOST="+IPAddress, "deis/controller:"+testSessionUid)
22+
dockercliutils.RunContainer(t, cli, "--name", "deis-controller-"+testSessionUid, "-p", "8000:8000", "-e", "PUBLISH=8000", "-e", "HOST="+IPAddress,"-e","ETCD_PORT="+port, "deis/controller:"+testSessionUid)
3223
}()
3324
time.Sleep(5000 * time.Millisecond)
3425
dockercliutils.PrintToStdout(t, stdout, stdoutPipe, "Booting")
3526

3627
}
3728

38-
func deisControllerServiceTest(t *testing.T, testSessionUid string) {
39-
IPAddress := dockercliutils.GetInspectData(t, "{{ .NetworkSettings.IPAddress }}", "deis-controller-"+testSessionUid)
40-
if strings.Contains(IPAddress, "Error") {
41-
t.Fatalf("worng IP %s", IPAddress)
42-
}
43-
url := "http://" + IPAddress + ":8000"
44-
response, err := http.Get(url)
45-
if err != nil {
46-
t.Fatalf("Not reachable %s", err)
47-
}
48-
fmt.Println(response)
49-
}
5029

5130
func TestBuild(t *testing.T) {
5231
setkeys := []string{"/deis/registry/protocol",
@@ -59,17 +38,17 @@ func TestBuild(t *testing.T) {
5938
"/deis/database",
6039
"/deis/registry",
6140
"/deis/domains"}
62-
fmt.Println("1st")
6341
var testSessionUid = utils.GetnewUuid()
42+
fmt.Println("UUID for the session Controller Test :"+testSessionUid)
43+
port := utils.GetRandomPort()
6444
//testSessionUid := "352aea64"
65-
dockercliutils.RunDummyEtcdTest(t, testSessionUid)
66-
fmt.Println("2nd")
67-
t.Logf("starting controller test: %v", testSessionUid)
68-
Controllerhandler := etcdutils.InitetcdValues(setdir, setkeys)
45+
dockercliutils.RunEtcdTest(t, testSessionUid,port)
46+
fmt.Println("starting controller test:")
47+
Controllerhandler := etcdutils.InitetcdValues(setdir, setkeys,port)
6948
etcdutils.Publishvalues(t, Controllerhandler)
70-
fmt.Println("starting registry test")
71-
mockserviceutils.RunMockDatabase(t, testSessionUid)
72-
runDeisControllerTest(t, testSessionUid)
73-
deisControllerServiceTest(t, testSessionUid)
49+
mockserviceutils.RunMockDatabase(t, testSessionUid,port)
50+
fmt.Println("starting Controller component test")
51+
runDeisControllerTest(t, testSessionUid,port)
52+
dockercliutils.DeisServiceTest(t,"deis-controller-"+testSessionUid,"8000","http")
7453
dockercliutils.ClearTestSession(t, testSessionUid)
7554
}

database/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ test-unit:
3333
@echo no unit tests
3434

3535
test-functional:
36-
GOPATH=$(CURDIR)/../tests/_vendor:$(GOPATH) go test -v ./test/...
36+
GOPATH=$(CURDIR)/../tests/_vendor:$(GOPATH) go test -timeout 7m -v ./test/...

database/test/databaseComponent_test.go

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,56 +4,33 @@ import (
44
"fmt"
55
"github.com/deis/deis/tests/dockercliutils"
66
"github.com/deis/deis/tests/utils"
7-
"net/http"
8-
"strings"
97
"testing"
108
)
119

12-
func deisDatabaseServiceTest(t *testing.T, testSessionUid string) {
13-
IPAddress := dockercliutils.GetInspectData(t, "{{ .NetworkSettings.IPAddress }}", "deis-logger-"+testSessionUid)
14-
if strings.Contains(IPAddress, "Error") {
15-
t.Fatalf("worng IP %s", IPAddress)
16-
}
17-
url := "http://" + IPAddress + ":5000"
18-
response, err := http.Get(url)
19-
if err != nil {
20-
t.Fatalf("Not reachable %s", err)
21-
}
22-
fmt.Println(response)
23-
}
10+
2411

2512
func runDeisDatabaseTest(t *testing.T, testSessionUid string,port string) {
2613
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
2714
done := make(chan bool, 1)
2815
dockercliutils.BuildDockerfile(t, "../", "deis/database:"+testSessionUid)
2916
dockercliutils.RunDeisDataTest(t, "--name", "deis-database-data", "-v", "/var/lib/postgresql", "deis/base", "true")
30-
IPAddress := func() string {
31-
var Ip string
32-
if utils.GetHostOs() == "darwin" {
33-
Ip = "172.17.8.100"
34-
}
35-
return Ip
36-
}()
17+
IPAddress := utils.GetHostIpAddress()
3718
done <- true
3819
go func() {
3920
<-done
40-
fmt.Println("inside run etcd")
4121
//docker run --name deis-database -p 5432:5432 -e PUBLISH=5432 -e HOST=${COREOS_PRIVATE_IPV4} --volumes-from deis-database-data deis/database
4222
dockercliutils.RunContainer(t, cli, "--name", "deis-database-"+testSessionUid, "-p", "5432:5432", "-e", "PUBLISH=5432", "-e", "HOST="+IPAddress,"-e","ETCD_PORT="+port, "--volumes-from", "deis-database-data", "deis/database:"+testSessionUid)
4323
}()
4424
dockercliutils.PrintToStdout(t, stdout, stdoutPipe, "deis-database running")
4525
}
4626

4727
func TestBuild(t *testing.T) {
48-
fmt.Println("1st")
4928
var testSessionUid = utils.GetnewUuid()
29+
fmt.Println("UUID for the session Cache Test :"+testSessionUid)
5030
port := utils.GetRandomPort()
51-
dockercliutils.RunDummyEtcdTest(t, testSessionUid,port)
52-
t.Logf("starting registry test: %v", testSessionUid)
53-
fmt.Println("2nd")
31+
dockercliutils.RunEtcdTest(t, testSessionUid,port)
32+
fmt.Println("starting Database compotest:")
5433
runDeisDatabaseTest(t, testSessionUid,port)
55-
//deisRegistryServiceTest(t, testSessionUid)
56-
//dockercliutils.ClearTestSession(t, testSessionUid)
57-
fmt.Println("3rd")
58-
34+
dockercliutils.DeisServiceTest(t,"deis-database-"+testSessionUid,"5432","tcp")
35+
dockercliutils.ClearTestSession(t, testSessionUid)
5936
}

logger/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ test-unit:
3333
@echo no unit tests
3434

3535
test-functional:
36-
GOPATH=$(CURDIR)/../tests/_vendor:$(GOPATH) go test -v ./test/...
36+
GOPATH=$(CURDIR)/../tests/_vendor:$(GOPATH) go test -timeout 7m -v ./test/...

logger/test/loggerComponent_test.go

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,55 +4,32 @@ import (
44
"fmt"
55
"github.com/deis/deis/tests/dockercliutils"
66
"github.com/deis/deis/tests/utils"
7-
"net/http"
8-
"strings"
97
"testing"
10-
"time"
118
)
129

13-
func deisLoggerServiceTest(t *testing.T, testSessionUid string) {
14-
IPAddress := dockercliutils.GetInspectData(t, "{{ .NetworkSettings.IPAddress }}", "deis-logger-"+testSessionUid)
15-
if strings.Contains(IPAddress, "Error") {
16-
t.Fatalf("worng IP %s", IPAddress)
17-
}
18-
url := "http://" + IPAddress + ":5000"
19-
response, err := http.Get(url)
20-
if err != nil {
21-
t.Fatalf("Not reachable %s", err)
22-
}
23-
fmt.Println(response)
24-
}
25-
26-
func runDeisLoggerTest(t *testing.T, testSessionUid string) {
10+
func runDeisLoggerTest(t *testing.T, testSessionUid string,port string) {
2711
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
2812
done := make(chan bool, 1)
2913
dockercliutils.BuildDockerfile(t, "../", "deis/logger:"+testSessionUid)
3014
dockercliutils.RunDeisDataTest(t, "--name", "deis-logger-data", "-v", "/var/log/deis", "deis/base", "true")
31-
IPAddress := func() string {
32-
var Ip string
33-
if utils.GetHostOs() == "darwin" {
34-
Ip = "172.17.8.100"
35-
}
36-
return Ip
37-
}()
15+
IPAddress := utils.GetHostIpAddress()
3816
done <- true
3917
go func() {
4018
<-done
41-
fmt.Println("inside run etcd")
42-
dockercliutils.RunContainer(t, cli, "--name", "deis-logger-"+testSessionUid, "-p", "514:514/udp", "-e", "PUBLISH=514", "-e", "HOST="+IPAddress, "--volumes-from", "deis-logger-data", "deis/logger:"+testSessionUid)
19+
dockercliutils.RunContainer(t, cli, "--name", "deis-logger-"+testSessionUid, "-p", "514:514/udp", "-e", "PUBLISH=514", "-e", "HOST="+IPAddress, "-e","ETCD_PORT="+port, "--volumes-from", "deis-logger-data", "deis/logger:"+testSessionUid)
4320
}()
4421
dockercliutils.PrintToStdout(t, stdout, stdoutPipe, "deis-logger running")
4522
}
4623

4724
func TestBuild(t *testing.T) {
48-
fmt.Println("1st")
4925
var testSessionUid = utils.GetnewUuid()
50-
dockercliutils.RunDummyEtcdTest(t, testSessionUid)
51-
fmt.Println("starting registry test: %v", testSessionUid)
52-
fmt.Println("2nd")
53-
runDeisLoggerTest(t, testSessionUid)
54-
//deisRegistryServiceTest(t, testSessionUid)*/
26+
port := utils.GetRandomPort()
27+
fmt.Println("UUID for the session logger Test :"+testSessionUid)
28+
//testSessionUid := "352aea64"
29+
dockercliutils.RunEtcdTest(t, testSessionUid,port)
30+
fmt.Println("starting logger componenet test:")
31+
runDeisLoggerTest(t, testSessionUid,port)
32+
dockercliutils.DeisServiceTest(t,"deis-logger-"+testSessionUid,"514","udp")
5533
dockercliutils.ClearTestSession(t, testSessionUid)
56-
fmt.Println("3rd")
5734

5835
}

0 commit comments

Comments
 (0)