Skip to content

Commit 78e7b8a

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 5b7f51a commit 78e7b8a

2 files changed

Lines changed: 13 additions & 34 deletions

File tree

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/...

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
}

0 commit comments

Comments
 (0)