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