Skip to content

Commit 12e3fa6

Browse files
smothikimboersma
authored andcommitted
refactor(tests): added tests/utils go package
1 parent 7e6f776 commit 12e3fa6

2 files changed

Lines changed: 60 additions & 1 deletion

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-
@echo no functional tests
55+
GOPATH=$(CURDIR)/../tests/_vendor:$(GOPATH) go test -timeout 30m -v ./test/...

test/controllerComponent_test.go

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+
}

0 commit comments

Comments
 (0)