Skip to content

Commit 3f313c5

Browse files
smothikimboersma
authored andcommitted
refactor(tests): add etcd and mock utility packages
1 parent 12e3fa6 commit 3f313c5

1 file changed

Lines changed: 28 additions & 18 deletions

File tree

test/controllerComponent_test.go

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,38 @@ package verbose
33
import (
44
"fmt"
55
"github.com/deis/deis/tests/dockercliutils"
6+
"github.com/deis/deis/tests/etcdutils"
7+
"github.com/deis/deis/tests/mockserviceutils"
68
"github.com/deis/deis/tests/utils"
79
"net/http"
810
"strings"
911
"testing"
1012
"time"
1113
)
1214

13-
func runDeisRegistryTest(t *testing.T, testSessionUid string) {
15+
func runDeisControllerTest(t *testing.T, testSessionUid string) {
1416
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
1517
done := make(chan bool, 1)
16-
dockercliutils.BuildDockerfile(t, "../", "deis/registry:"+testSessionUid)
17-
dockercliutils.RunDeisDataTest(t, "--name", "deis-registry-data", "-v", "/data", "deis/base", "/bin/true")
18-
IPAddress := dockercliutils.GetInspectData(t, "{{ .NetworkSettings.IPAddress }}", "deis-etcd-"+testSessionUid)
19-
if strings.Contains(IPAddress, "Error") {
20-
t.Fatalf("worng IP %s", IPAddress)
21-
}
18+
dockercliutils.BuildDockerfile(t, "../", "deis/controller:"+testSessionUid)
19+
//docker run --name deis-controller -p 8000:8000 -e PUBLISH=8000 -e HOST=${COREOS_PRIVATE_IPV4} --volumes-from=deis-logger deis/controller
20+
IPAddress := "172.17.8.100"
2221
done <- true
2322
go func() {
2423
<-done
2524
fmt.Println("inside run container")
26-
dockercliutils.RunContainer(t, cli, "--name", "deis-registry-"+testSessionUid, "-p", "5000:5000", "-e", "PUBLISH=5000", "-e", "HOST="+IPAddress, "--volumes-from", "deis-registry-data", "deis/registry:"+testSessionUid)
25+
dockercliutils.RunContainer(t, cli, "--name", "deis-controller-"+testSessionUid, "-p", "8000:8000", "-e", "PUBLISH=8000", "-e", "HOST="+IPAddress, "deis/controller:"+testSessionUid)
2726
}()
28-
time.Sleep(10000 * time.Millisecond)
27+
time.Sleep(5000 * time.Millisecond)
2928
dockercliutils.PrintToStdout(t, stdout, stdoutPipe, "Booting")
3029

3130
}
3231

33-
func deisRegistryServiceTest(t *testing.T, testSessionUid string) {
34-
IPAddress := dockercliutils.GetInspectData(t, "{{ .NetworkSettings.IPAddress }}", "deis-registry-"+testSessionUid)
32+
func deisControllerServiceTest(t *testing.T, testSessionUid string) {
33+
IPAddress := dockercliutils.GetInspectData(t, "{{ .NetworkSettings.IPAddress }}", "deis-controller-"+testSessionUid)
3534
if strings.Contains(IPAddress, "Error") {
3635
t.Fatalf("worng IP %s", IPAddress)
3736
}
38-
url := "http://" + IPAddress + ":5000"
37+
url := "http://" + IPAddress + ":8000"
3938
response, err := http.Get(url)
4039
if err != nil {
4140
t.Fatalf("Not reachable %s", err)
@@ -44,16 +43,27 @@ func deisRegistryServiceTest(t *testing.T, testSessionUid string) {
4443
}
4544

4645
func TestBuild(t *testing.T) {
47-
46+
setkeys := []string{"/deis/registry/protocol",
47+
"deis/registry/host",
48+
"/deis/registry/port",
49+
"/deis/cache/host",
50+
"/deis/cache/port"}
51+
setdir := []string{"/deis/controller",
52+
"/deis/cache",
53+
"/deis/database",
54+
"/deis/registry",
55+
"/deis/domains"}
4856
fmt.Println("1st")
4957
var testSessionUid = utils.GetnewUuid()
50-
testSessionUid = "352aea64"
58+
//testSessionUid := "352aea64"
5159
dockercliutils.RunEtcdTest(t, testSessionUid)
5260
fmt.Println("2nd")
53-
t.Logf("starting registry test: %v", testSessionUid)
61+
t.Logf("starting controller test: %v", testSessionUid)
62+
Controllerhandler := etcdutils.InitetcdValues(setdir, setkeys)
63+
etcdutils.PublishControllervalues(t, Controllerhandler)
5464
fmt.Println("starting registry test")
55-
runDeisRegistryTest(t, testSessionUid)
56-
deisRegistryServiceTest(t, testSessionUid)
65+
mockserviceutils.RunMockDatabase(t, testSessionUid)
66+
runDeisControllerTest(t, testSessionUid)
67+
deisControllerServiceTest(t, testSessionUid)
5768
dockercliutils.ClearTestSession(t, testSessionUid)
58-
5969
}

0 commit comments

Comments
 (0)