Skip to content

Commit 6edda25

Browse files
smothikimboersma
authored andcommitted
test(workingframework):framework working
Added component tests for all the services and tested .
1 parent 59b5f28 commit 6edda25

14 files changed

Lines changed: 322 additions & 75 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-
@echo no functional tests
36+
GOPATH=$(CURDIR)/../tests/_vendor:$(GOPATH) go test -timeout 30m -v ./test/...
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package verbose
2+
3+
import (
4+
"fmt"
5+
"github.com/deis/deis/tests/dockercliutils"
6+
"github.com/deis/deis/tests/etcdutils"
7+
"github.com/deis/deis/tests/mockserviceutils"
8+
"github.com/deis/deis/tests/utils"
9+
"net/http"
10+
"strings"
11+
"testing"
12+
"time"
13+
)
14+
15+
func runDeisBuilderTest(t *testing.T, testSessionUid string) {
16+
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
17+
done := make(chan bool, 1)
18+
dockercliutils.BuildDockerfile(t, "../", "deis/builder:"+testSessionUid)
19+
dockercliutils.RunDeisDataTest(t, "--name", "deis-builder-data", "-v", "/var/lib/docker", "deis/base", "/bin/true")
20+
//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+
}()
28+
done <- true
29+
go func() {
30+
<-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)
33+
}()
34+
time.Sleep(5000 * time.Millisecond)
35+
dockercliutils.PrintToStdout(t, stdout, stdoutPipe, "deis-builder running")
36+
}
37+
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+
51+
func TestBuild(t *testing.T) {
52+
setkeys := []string{"/deis/registry/protocol",
53+
"deis/registry/host",
54+
"/deis/registry/port",
55+
"/deis/cache/host",
56+
"/deis/cache/port"}
57+
setdir := []string{"/deis/controller",
58+
"/deis/cache",
59+
"/deis/database",
60+
"/deis/registry",
61+
"/deis/domains"}
62+
fmt.Println("1st")
63+
var testSessionUid = utils.GetnewUuid()
64+
//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)
69+
etcdutils.Publishvalues(t, Builderhandler)
70+
fmt.Println("starting registry test")
71+
runDeisBuilderTest(t, testSessionUid)
72+
//deisBuilderServiceTest(t, testSessionUid)
73+
//dockercliutils.ClearTestSession(t, testSessionUid)
74+
}

cache/test/cacheComponent_test.go

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,55 @@ package verbose
33
import (
44
"fmt"
55
"github.com/deis/deis/tests/dockercliutils"
6+
"github.com/deis/deis/tests/utils"
7+
"net/http"
68
"strings"
79
"testing"
810
)
911

10-
func runDeisCacheTest(t *testing.T) {
11-
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
12-
13-
done := make(chan bool, 1)
14-
15-
dockercliutils.BuildDockerfile(t, "../", " ")
16-
IPAddress := dockercliutils.GetInspectData(t, "{{ .NetworkSettings.IPAddress }}", "deis-etcd")
12+
func deisCacheServiceTest(t *testing.T, testSessionUid string) {
13+
IPAddress := dockercliutils.GetInspectData(t, "{{ .NetworkSettings.IPAddress }}", "deis-logger-"+testSessionUid)
1714
if strings.Contains(IPAddress, "Error") {
1815
t.Fatalf("worng IP %s", IPAddress)
1916
}
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+
}
2024

21-
fmt.Println(IPAddress + "IPADRESS")
25+
func runDeisCacheTest(t *testing.T, testSessionUid string) {
26+
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
27+
done := make(chan bool, 1)
28+
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+
}()
2236
done <- true
2337
go func() {
2438
<-done
25-
fmt.Println("inside run cahce run continer")
26-
dockercliutils.RunContainer(t, cli, "--name", "deis-cache", "-p", "6379:6379", "-e", "PUBLISH=6379", "-e", "HOST="+IPAddress, "deis/cache")
39+
fmt.Println("inside run etcd")
40+
//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)
2742
}()
28-
29-
dockercliutils.PrintToStdout(t, stdout, stdoutPipe, "Server started")
30-
43+
dockercliutils.PrintToStdout(t, stdout, stdoutPipe, "started")
3144
}
3245

3346
func TestBuild(t *testing.T) {
34-
3547
fmt.Println("1st")
36-
dockercliutils.RunEtcdTest(t, "foobar")
48+
var testSessionUid = utils.GetnewUuid()
49+
dockercliutils.RunDummyEtcdTest(t, testSessionUid)
50+
t.Logf("starting cache test: %v", testSessionUid)
3751
fmt.Println("2nd")
38-
runDeisCacheTest(t)
52+
runDeisCacheTest(t, testSessionUid)
53+
//deisCacheServiceTest(t, testSessionUid)
54+
//dockercliutils.ClearTestSession(t, testSessionUid)
55+
fmt.Println("3rd")
56+
3957
}

controller/test/controllerComponent_test.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ func runDeisControllerTest(t *testing.T, testSessionUid string) {
1717
done := make(chan bool, 1)
1818
dockercliutils.BuildDockerfile(t, "../", "deis/controller:"+testSessionUid)
1919
//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"
20+
IPAddress := func() string {
21+
var Ip string
22+
if utils.GetHostOs() == "darwin" {
23+
Ip = "172.17.8.100"
24+
}
25+
return Ip
26+
}()
2127
done <- true
2228
go func() {
2329
<-done
@@ -56,11 +62,11 @@ func TestBuild(t *testing.T) {
5662
fmt.Println("1st")
5763
var testSessionUid = utils.GetnewUuid()
5864
//testSessionUid := "352aea64"
59-
dockercliutils.RunEtcdTest(t, testSessionUid)
65+
dockercliutils.RunDummyEtcdTest(t, testSessionUid)
6066
fmt.Println("2nd")
6167
t.Logf("starting controller test: %v", testSessionUid)
6268
Controllerhandler := etcdutils.InitetcdValues(setdir, setkeys)
63-
etcdutils.PublishControllervalues(t, Controllerhandler)
69+
etcdutils.Publishvalues(t, Controllerhandler)
6470
fmt.Println("starting registry test")
6571
mockserviceutils.RunMockDatabase(t, testSessionUid)
6672
runDeisControllerTest(t, testSessionUid)

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-
@echo no functional tests
36+
GOPATH=$(CURDIR)/../tests/_vendor:$(GOPATH) go test -v ./test/...
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package verbose
2+
3+
import (
4+
"fmt"
5+
"github.com/deis/deis/tests/dockercliutils"
6+
"github.com/deis/deis/tests/utils"
7+
"net/http"
8+
"strings"
9+
"testing"
10+
)
11+
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+
}
24+
25+
func runDeisDatabaseTest(t *testing.T, testSessionUid string,port string) {
26+
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
27+
done := make(chan bool, 1)
28+
dockercliutils.BuildDockerfile(t, "../", "deis/database:"+testSessionUid)
29+
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+
}()
37+
done <- true
38+
go func() {
39+
<-done
40+
fmt.Println("inside run etcd")
41+
//docker run --name deis-database -p 5432:5432 -e PUBLISH=5432 -e HOST=${COREOS_PRIVATE_IPV4} --volumes-from deis-database-data deis/database
42+
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)
43+
}()
44+
dockercliutils.PrintToStdout(t, stdout, stdoutPipe, "deis-database running")
45+
}
46+
47+
func TestBuild(t *testing.T) {
48+
fmt.Println("1st")
49+
var testSessionUid = utils.GetnewUuid()
50+
port := utils.GetRandomPort()
51+
dockercliutils.RunDummyEtcdTest(t, testSessionUid,port)
52+
t.Logf("starting registry test: %v", testSessionUid)
53+
fmt.Println("2nd")
54+
runDeisDatabaseTest(t, testSessionUid,port)
55+
//deisRegistryServiceTest(t, testSessionUid)
56+
//dockercliutils.ClearTestSession(t, testSessionUid)
57+
fmt.Println("3rd")
58+
59+
}

logger/test/loggerComponent_test.go

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ import (
77
"net/http"
88
"strings"
99
"testing"
10+
"time"
1011
)
1112

12-
func deisRegistryServiceTest(t *testing.T, testSessionUid string) {
13-
IPAddress := dockercliutils.GetInspectData(t, "{{ .NetworkSettings.IPAddress }}", "deis-registry-"+testSessionUid)
13+
func deisLoggerServiceTest(t *testing.T, testSessionUid string) {
14+
IPAddress := dockercliutils.GetInspectData(t, "{{ .NetworkSettings.IPAddress }}", "deis-logger-"+testSessionUid)
1415
if strings.Contains(IPAddress, "Error") {
1516
t.Fatalf("worng IP %s", IPAddress)
1617
}
@@ -22,34 +23,35 @@ func deisRegistryServiceTest(t *testing.T, testSessionUid string) {
2223
fmt.Println(response)
2324
}
2425

25-
func runDeisLoggerTest(t *testing.T) {
26+
func runDeisLoggerTest(t *testing.T, testSessionUid string) {
2627
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
2728
done := make(chan bool, 1)
28-
dockercliutils.BuildDockerfile(t, "../", " ")
29+
dockercliutils.BuildDockerfile(t, "../", "deis/logger:"+testSessionUid)
2930
dockercliutils.RunDeisDataTest(t, "--name", "deis-logger-data", "-v", "/var/log/deis", "deis/base", "true")
30-
dockercliutils.RunDeisDataTest(t, "--name", "deis-logger-data", "-v", "/var/log/deis", "deis/base", "true")
31-
IPAddress := dockercliutils.GetInspectData(t, "{{ .NetworkSettings.IPAddress }}", "deis-etcd")
32-
if strings.Contains(IPAddress, "Error") {
33-
t.Fatalf("worng IP %s", IPAddress)
34-
}
31+
IPAddress := func() string {
32+
var Ip string
33+
if utils.GetHostOs() == "darwin" {
34+
Ip = "172.17.8.100"
35+
}
36+
return Ip
37+
}()
3538
done <- true
3639
go func() {
3740
<-done
3841
fmt.Println("inside run etcd")
39-
dockercliutils.RunContainer(t, cli, "--name", "deis-logger", "-p", "514:514/udp", "-e", "PUBLISH=514", "-e", "HOST="+IPAddress, "--volumes-from", "deis-logger-data", "deis/logger")
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)
4043
}()
41-
dockercliutils.PrintToStdout(t, stdout, stdoutPipe, "Booting")
44+
dockercliutils.PrintToStdout(t, stdout, stdoutPipe, "deis-logger running")
4245
}
4346

4447
func TestBuild(t *testing.T) {
45-
4648
fmt.Println("1st")
4749
var testSessionUid = utils.GetnewUuid()
48-
dockercliutils.RunEtcdTest(t)
49-
t.Logf("starting registry test: %v", testSessionUid)
50+
dockercliutils.RunDummyEtcdTest(t, testSessionUid)
51+
fmt.Println("starting registry test: %v", testSessionUid)
5052
fmt.Println("2nd")
5153
runDeisLoggerTest(t, testSessionUid)
52-
deisRegistryServiceTest(t, testSessionUid)
54+
//deisRegistryServiceTest(t, testSessionUid)*/
5355
dockercliutils.ClearTestSession(t, testSessionUid)
5456
fmt.Println("3rd")
5557

registry/test/registryComponent_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,18 @@ func runDeisRegistryTest(t *testing.T, testSessionUid string) {
1515
done := make(chan bool, 1)
1616
dockercliutils.BuildDockerfile(t, "../", "deis/registry:"+testSessionUid)
1717
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+
IPAddress := func() string {
19+
if utils.GetHostOs() == "darwin" {
20+
return "172.17.8.100"
21+
}
22+
}()
2223
done <- true
2324
go func() {
2425
<-done
2526
fmt.Println("inside run container")
2627
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)
2728
}()
28-
time.Sleep(10000 * time.Millisecond)
29+
time.Sleep(2000 * time.Millisecond)
2930
dockercliutils.PrintToStdout(t, stdout, stdoutPipe, "Booting")
3031

3132
}
@@ -44,10 +45,9 @@ func deisRegistryServiceTest(t *testing.T, testSessionUid string) {
4445
}
4546

4647
func TestBuild(t *testing.T) {
47-
4848
var testSessionUid = utils.GetnewUuid()
49-
testSessionUid = "352aea64"
50-
dockercliutils.RunEtcdTest(t, testSessionUid)
49+
//testSessionUid = "352aea64"
50+
dockercliutils.RunDummyEtcdTest(t, testSessionUid)
5151
fmt.Println("2nd")
5252
t.Logf("starting registry test: %v", testSessionUid)
5353
fmt.Println("starting registry test")

router/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ test-unit:
4949
@echo no unit tests
5050

5151
test-functional:
52-
@echo no functional tests
52+
GOPATH=$(CURDIR)/../tests/_vendor:$(GOPATH) go test -timeout 30m -v ./test/...

0 commit comments

Comments
 (0)