Skip to content

Commit 3c47dfa

Browse files
smothikimboersma
authored andcommitted
refactor(tests): added tests/utils go package
1 parent 79cc261 commit 3c47dfa

10 files changed

Lines changed: 847 additions & 221 deletions

File tree

cache/test/cacheComponent_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,37 @@ package verbose
33
import (
44
"fmt"
55
"github.com/deis/deis/tests/dockercliutils"
6+
"strings"
67
"testing"
78
)
89

910
func runDeisCacheTest(t *testing.T) {
1011
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
1112

1213
done := make(chan bool, 1)
13-
// done1 :=make(chan bool, 1)
1414

1515
dockercliutils.BuildDockerfile(t, "../", " ")
1616
IPAddress := dockercliutils.GetInspectData(t, "{{ .NetworkSettings.IPAddress }}", "deis-etcd")
17+
if strings.Contains(IPAddress, "Error") {
18+
t.Fatalf("worng IP %s", IPAddress)
19+
}
20+
1721
fmt.Println(IPAddress + "IPADRESS")
1822
done <- true
1923
go func() {
2024
<-done
2125
fmt.Println("inside run cahce run continer")
2226
dockercliutils.RunContainer(t, cli, "--name", "deis-cache", "-p", "6379:6379", "-e", "PUBLISH=6379", "-e", "HOST="+IPAddress, "deis/cache")
2327
}()
28+
2429
dockercliutils.PrintToStdout(t, stdout, stdoutPipe, "Server started")
2530

2631
}
2732

2833
func TestBuild(t *testing.T) {
2934

3035
fmt.Println("1st")
31-
//dockercliutils.RunEtcdTest(t)
36+
dockercliutils.RunEtcdTest(t, "foobar")
3237
fmt.Println("2nd")
3338
runDeisCacheTest(t)
3439
}

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-
@echo no functional tests
55+
GOPATH=$(CURDIR)/../tests/_vendor:$(GOPATH) go test -timeout 30m -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+
"time"
11+
)
12+
13+
func runDeisRegistryTest(t *testing.T, testSessionUid string) {
14+
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
15+
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+
}
22+
done <- true
23+
go func() {
24+
<-done
25+
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)
27+
}()
28+
time.Sleep(10000 * time.Millisecond)
29+
dockercliutils.PrintToStdout(t, stdout, stdoutPipe, "Booting")
30+
31+
}
32+
33+
func deisRegistryServiceTest(t *testing.T, testSessionUid string) {
34+
IPAddress := dockercliutils.GetInspectData(t, "{{ .NetworkSettings.IPAddress }}", "deis-registry-"+testSessionUid)
35+
if strings.Contains(IPAddress, "Error") {
36+
t.Fatalf("worng IP %s", IPAddress)
37+
}
38+
url := "http://" + IPAddress + ":5000"
39+
response, err := http.Get(url)
40+
if err != nil {
41+
t.Fatalf("Not reachable %s", err)
42+
}
43+
fmt.Println(response)
44+
}
45+
46+
func TestBuild(t *testing.T) {
47+
48+
fmt.Println("1st")
49+
var testSessionUid = utils.GetnewUuid()
50+
testSessionUid = "352aea64"
51+
dockercliutils.RunEtcdTest(t, testSessionUid)
52+
fmt.Println("2nd")
53+
t.Logf("starting registry test: %v", testSessionUid)
54+
fmt.Println("starting registry test")
55+
runDeisRegistryTest(t, testSessionUid)
56+
deisRegistryServiceTest(t, testSessionUid)
57+
dockercliutils.ClearTestSession(t, testSessionUid)
58+
59+
}
Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,56 @@
11
package verbose
22

33
import (
4-
"github.com/deis/deis/tests/dockercliutils"
5-
"fmt"
6-
"testing"
4+
"fmt"
5+
"github.com/deis/deis/tests/dockercliutils"
6+
"github.com/deis/deis/tests/utils"
7+
"net/http"
8+
"strings"
9+
"testing"
710
)
811

9-
10-
11-
func runDeisLoggerTest(t *testing.T){
12-
cli,stdout,stdoutPipe := dockercliutils.GetNewClient( )
13-
done := make(chan bool, 1)
14-
dockercliutils.BuildDockerfile(t,"../"," ")
15-
dockercliutils.RunDeisDataTest(t,"--name", "deis-logger-data", "-v", "/var/log/deis", "deis/base", "true")
16-
IPAddress := dockercliutils.GetInspectData(t,"{{ .NetworkSettings.IPAddress }}", "deis-etcd")
17-
done <-true
18-
go func(){
19-
<- done
20-
fmt.Println("inside run etcd")
21-
dockercliutils.RunContainer(t,cli,"--name", "deis-logger", "-p", "514:514/udp", "-e", "PUBLISH=514", "-e", "HOST="+IPAddress, "--volumes-from", "deis-logger-data", "deis/logger")
22-
}()
23-
dockercliutils.PrintToStdout(t,stdout,stdoutPipe,"Booting")
24-
12+
func deisRegistryServiceTest(t *testing.T, testSessionUid string) {
13+
IPAddress := dockercliutils.GetInspectData(t, "{{ .NetworkSettings.IPAddress }}", "deis-registry-"+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)
2523
}
2624

25+
func runDeisLoggerTest(t *testing.T) {
26+
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
27+
done := make(chan bool, 1)
28+
dockercliutils.BuildDockerfile(t, "../", " ")
29+
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+
}
35+
done <- true
36+
go func() {
37+
<-done
38+
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")
40+
}()
41+
dockercliutils.PrintToStdout(t, stdout, stdoutPipe, "Booting")
42+
}
2743

2844
func TestBuild(t *testing.T) {
2945

30-
fmt.Println("1st")
31-
dockercliutils.RunEtcdTest(t)
32-
fmt.Println("2nd")
33-
34-
fmt.Println("3rd")
35-
36-
runDeisLoggerTest(t)
37-
46+
fmt.Println("1st")
47+
var testSessionUid = utils.GetnewUuid()
48+
dockercliutils.RunEtcdTest(t)
49+
t.Logf("starting registry test: %v", testSessionUid)
50+
fmt.Println("2nd")
51+
runDeisLoggerTest(t, testSessionUid)
52+
deisRegistryServiceTest(t, testSessionUid)
53+
dockercliutils.ClearTestSession(t, testSessionUid)
54+
fmt.Println("3rd")
3855

3956
}

registry/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ test-unit:
4141
../venv/bin/python -m unittest discover -s test
4242

4343
test-functional:
44-
GOPATH=$(CURDIR)/../tests/_vendor:$(GOPATH) go test -v ./test/...
44+
GOPATH=$(CURDIR)/../tests/_vendor:$(GOPATH) go test -timeout 30m -v ./test/...
Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,58 @@
11
package verbose
22

33
import (
4-
"github.com/deis/deis/tests/dockercliutils"
54
"fmt"
5+
"github.com/deis/deis/tests/dockercliutils"
6+
"github.com/deis/deis/tests/utils"
7+
"net/http"
8+
"strings"
69
"testing"
10+
"time"
711
)
812

9-
10-
11-
func runDeisRegistryTest(t *testing.T){
12-
cli,stdout,stdoutPipe := dockercliutils.GetNewClient( )
13+
func runDeisRegistryTest(t *testing.T, testSessionUid string) {
14+
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
1315
done := make(chan bool, 1)
14-
dockercliutils.BuildDockerfile(t,"../"," ")
15-
dockercliutils.RunDeisDataTest(t,"--name", "deis-registry-data", "-v", "/data", "deis/base", "/bin/true")
16-
IPAddress := dockercliutils.GetInspectData(t,"{{ .NetworkSettings.IPAddress }}", "deis-etcd")
17-
done <-true
18-
go func(){
19-
<- done
20-
fmt.Println("inside run etcd")
21-
dockercliutils.RunContainer(t,cli,"--name", "deis-registry", "-p", "5000:5000", "-e", "PUBLISH=5000", "-e", "HOST="+IPAddress, "--volumes-from", "deis-registry-data", "deis/registry")
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+
}
22+
done <- true
23+
go func() {
24+
<-done
25+
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)
2227
}()
23-
dockercliutils.PrintToStdout(t,stdout,stdoutPipe,"Booting")
28+
time.Sleep(10000 * time.Millisecond)
29+
dockercliutils.PrintToStdout(t, stdout, stdoutPipe, "Booting")
2430

2531
}
2632

33+
func deisRegistryServiceTest(t *testing.T, testSessionUid string) {
34+
IPAddress := dockercliutils.GetInspectData(t, "{{ .NetworkSettings.IPAddress }}", "deis-registry-"+testSessionUid)
35+
if strings.Contains(IPAddress, "Error") {
36+
t.Fatalf("worng IP %s", IPAddress)
37+
}
38+
url := "http://" + IPAddress + ":5000"
39+
response, err := http.Get(url)
40+
if err != nil {
41+
t.Fatalf("Not reachable %s", err)
42+
}
43+
fmt.Println(response)
44+
}
2745

2846
func TestBuild(t *testing.T) {
2947

30-
fmt.Println("1st")
31-
dockercliutils.RunEtcdTest(t)
48+
var testSessionUid = utils.GetnewUuid()
49+
testSessionUid = "352aea64"
50+
dockercliutils.RunEtcdTest(t, testSessionUid)
3251
fmt.Println("2nd")
33-
34-
fmt.Println("3rd")
35-
36-
runDeisRegistryTest(t)
37-
52+
t.Logf("starting registry test: %v", testSessionUid)
53+
fmt.Println("starting registry test")
54+
runDeisRegistryTest(t, testSessionUid)
55+
deisRegistryServiceTest(t, testSessionUid)
56+
dockercliutils.ClearTestSession(t, testSessionUid)
3857

3958
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (C) 2013 by Maxim Bublis <b@codemonkey.ru>
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)