Skip to content

Commit c331def

Browse files
committed
refactor(tests): add comments to some test packages and clean up with goimports
1 parent a1ba071 commit c331def

26 files changed

Lines changed: 420 additions & 340 deletions

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,10 @@ test-components:
127127
)
128128

129129
test-integration:
130-
GOPATH=$(CURDIR)/tests/_vendor:$(GOPATH) $(MAKE) -C tests/ test
130+
$(MAKE) -C tests/ test
131+
132+
test-smoke:
133+
$(MAKE) -C tests/ test-smoke
131134

132135
uninstall: check-fleet stop
133136
$(FLEETCTL) unload -block-attempts=600 $(call deis_units,launched,.)

builder/Makefile

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

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

builder/test/builderComponent_test.go

Lines changed: 0 additions & 51 deletions
This file was deleted.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package verbose
2+
3+
import (
4+
"fmt"
5+
"testing"
6+
"time"
7+
8+
"github.com/deis/deis/tests/dockercliutils"
9+
"github.com/deis/deis/tests/etcdutils"
10+
"github.com/deis/deis/tests/utils"
11+
)
12+
13+
func runDeisBuilderTest(t *testing.T, testSessionUID string, port string) {
14+
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
15+
done := make(chan bool, 1)
16+
dockercliutils.BuildDockerfile(t, "../", "deis/builder:"+testSessionUID)
17+
dockercliutils.RunDeisDataTest(t, "--name", "deis-builder-data",
18+
"-v", "/var/lib/docker", "deis/base", "/bin/true")
19+
//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
20+
IPAddress := utils.GetHostIPAddress()
21+
done <- true
22+
go func() {
23+
<-done
24+
dockercliutils.RunContainer(t, cli, "--name",
25+
"deis-builder-"+testSessionUID, "-p", "2223:22", "-e", "PUBLISH=22",
26+
"-e", "STORAGE_DRIVER=aufs", "-e", "HOST="+IPAddress, "-e",
27+
"ETCD_PORT="+port, "-e", "PORT=2223", "--volumes-from",
28+
"deis-builder-data", "--privileged", "deis/builder:"+testSessionUID)
29+
}()
30+
time.Sleep(5000 * time.Millisecond)
31+
dockercliutils.PrintToStdout(t, stdout, stdoutPipe, "deis-builder running")
32+
}
33+
34+
func TestBuild(t *testing.T) {
35+
setkeys := []string{"/deis/registry/protocol",
36+
"deis/registry/host",
37+
"/deis/registry/port",
38+
"/deis/cache/host",
39+
"/deis/cache/port"}
40+
setdir := []string{"/deis/controller",
41+
"/deis/cache",
42+
"/deis/database",
43+
"/deis/registry",
44+
"/deis/domains"}
45+
var testSessionUID = utils.NewUuid()
46+
fmt.Println("UUID for the session Builder Test :" + testSessionUID)
47+
port := utils.GetRandomPort()
48+
//testSessionUID := "352aea64"
49+
dockercliutils.RunEtcdTest(t, testSessionUID, port)
50+
Builderhandler := etcdutils.InitetcdValues(setdir, setkeys, port)
51+
etcdutils.Publishvalues(t, Builderhandler)
52+
fmt.Println("starting Builder Component test")
53+
runDeisBuilderTest(t, testSessionUID, port)
54+
dockercliutils.DeisServiceTest(
55+
t, "deis-builder-"+testSessionUID, "22", "tcp")
56+
dockercliutils.ClearTestSession(t, testSessionUID)
57+
}

cache/Makefile

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

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

cache/test/cacheComponent_test.go

Lines changed: 0 additions & 38 deletions
This file was deleted.

cache/tests/cacheComponent_test.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package verbose
2+
3+
import (
4+
"fmt"
5+
"testing"
6+
7+
"github.com/deis/deis/tests/dockercliutils"
8+
"github.com/deis/deis/tests/utils"
9+
)
10+
11+
func runDeisCacheTest(t *testing.T, testSessionUID string, port string) {
12+
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
13+
done := make(chan bool, 1)
14+
dockercliutils.BuildDockerfile(t, "../", "deis/cache:"+testSessionUID)
15+
IPAddress := utils.GetHostIPAddress()
16+
done <- true
17+
go func() {
18+
<-done
19+
//docker run --name deis-cache -p 6379:6379 -e PUBLISH=6379 -e HOST=${COREOS_PRIVATE_IPV4} deis/cache
20+
dockercliutils.RunContainer(t, cli, "--name",
21+
"deis-cache-"+testSessionUID, "-p", "6379:6379", "-e",
22+
"PUBLISH=6379", "-e", "HOST="+IPAddress, "-e", "ETCD_PORT="+port,
23+
"deis/cache:"+testSessionUID)
24+
}()
25+
dockercliutils.PrintToStdout(t, stdout, stdoutPipe, "started")
26+
}
27+
28+
func TestBuild(t *testing.T) {
29+
var testSessionUID = utils.NewUuid()
30+
fmt.Println("UUID for the session Cache Test :" + testSessionUID)
31+
port := utils.GetRandomPort()
32+
//testSessionUID := "352aea64"
33+
dockercliutils.RunEtcdTest(t, testSessionUID, port)
34+
fmt.Println("starting cache compotest:")
35+
runDeisCacheTest(t, testSessionUID, port)
36+
dockercliutils.DeisServiceTest(
37+
t, "deis-cache-"+testSessionUID, "6379", "tcp")
38+
dockercliutils.ClearTestSession(t, testSessionUID)
39+
}

controller/Makefile

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

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

controller/test/controllerComponent_test.go renamed to controller/tests/controllerComponent_test.go

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,34 @@ package verbose
22

33
import (
44
"fmt"
5+
"testing"
6+
"time"
7+
58
"github.com/deis/deis/tests/dockercliutils"
69
"github.com/deis/deis/tests/etcdutils"
710
"github.com/deis/deis/tests/mockserviceutils"
811
"github.com/deis/deis/tests/utils"
9-
"testing"
10-
"time"
1112
)
1213

13-
func runDeisControllerTest(t *testing.T, testSessionUid string,port string) {
14+
func runDeisControllerTest(t *testing.T, testSessionUID string, port string) {
1415
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
1516
done := make(chan bool, 1)
16-
dockercliutils.BuildDockerfile(t, "../", "deis/controller:"+testSessionUid)
17+
dockercliutils.BuildDockerfile(t, "../", "deis/controller:"+testSessionUID)
1718
//docker run --name deis-controller -p 8000:8000 -e PUBLISH=8000 -e HOST=${COREOS_PRIVATE_IPV4} --volumes-from=deis-logger deis/controller
18-
IPAddress := utils.GetHostIpAddress()
19+
IPAddress := utils.GetHostIPAddress()
1920
done <- true
2021
go func() {
2122
<-done
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)
23+
dockercliutils.RunContainer(t, cli, "--name",
24+
"deis-controller-"+testSessionUID, "-p", "8000:8000",
25+
"-e", "PUBLISH=8000", "-e", "HOST="+IPAddress,
26+
"-e", "ETCD_PORT="+port, "deis/controller:"+testSessionUID)
2327
}()
2428
time.Sleep(5000 * time.Millisecond)
2529
dockercliutils.PrintToStdout(t, stdout, stdoutPipe, "Booting")
2630

2731
}
2832

29-
3033
func TestBuild(t *testing.T) {
3134
setkeys := []string{"/deis/registry/protocol",
3235
"deis/registry/host",
@@ -38,17 +41,18 @@ func TestBuild(t *testing.T) {
3841
"/deis/database",
3942
"/deis/registry",
4043
"/deis/domains"}
41-
var testSessionUid = utils.GetnewUuid()
42-
fmt.Println("UUID for the session Controller Test :"+testSessionUid)
44+
var testSessionUID = utils.NewUuid()
45+
fmt.Println("UUID for the session Controller Test :" + testSessionUID)
4346
port := utils.GetRandomPort()
44-
//testSessionUid := "352aea64"
45-
dockercliutils.RunEtcdTest(t, testSessionUid,port)
47+
//testSessionUID := "352aea64"
48+
dockercliutils.RunEtcdTest(t, testSessionUID, port)
4649
fmt.Println("starting controller test:")
47-
Controllerhandler := etcdutils.InitetcdValues(setdir, setkeys,port)
50+
Controllerhandler := etcdutils.InitetcdValues(setdir, setkeys, port)
4851
etcdutils.Publishvalues(t, Controllerhandler)
49-
mockserviceutils.RunMockDatabase(t, testSessionUid,port)
52+
mockserviceutils.RunMockDatabase(t, testSessionUID, port)
5053
fmt.Println("starting Controller component test")
51-
runDeisControllerTest(t, testSessionUid,port)
52-
dockercliutils.DeisServiceTest(t,"deis-controller-"+testSessionUid,"8000","http")
53-
dockercliutils.ClearTestSession(t, testSessionUid)
54+
runDeisControllerTest(t, testSessionUID, port)
55+
dockercliutils.DeisServiceTest(
56+
t, "deis-controller-"+testSessionUID, "8000", "http")
57+
dockercliutils.ClearTestSession(t, testSessionUID)
5458
}

database/Makefile

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

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

0 commit comments

Comments
 (0)