func TestController(t *testing.T) { setkeys := []string{ "/deis/registry/protocol", "deis/registry/host", "/deis/registry/port", "/deis/cache/host", "/deis/cache/port", } setdir := []string{ "/deis/controller", "/deis/cache", "/deis/database", "/deis/registry", "/deis/domains", } testID := utils.NewID() err := dockercli.BuildImage(t, "../", "deis/controller:"+testID) if err != nil { t.Fatal(err) } etcdPort := utils.GetRandomPort() dockercli.RunEtcdTest(t, testID, etcdPort) handler := etcdutils.InitetcdValues(setdir, setkeys, etcdPort) etcdutils.Publishvalues(t, handler) dbPort := utils.GetRandomPort() mock.RunMockDatabase(t, testID, etcdPort, dbPort) servicePort := utils.GetRandomPort() fmt.Printf("--- Test deis-controller-%s at port %s\n", testID, servicePort) runDeisControllerTest(t, testID, etcdPort, servicePort) dockercli.DeisServiceTest( t, "deis-controller-"+testID, servicePort, "http") dockercli.ClearTestSession(t, testID) }
func TestBuilder(t *testing.T) { setkeys := []string{"/deis/registry/protocol", "deis/registry/host", "/deis/registry/port", "/deis/cache/host", "/deis/cache/port"} setdir := []string{"/deis/controller", "/deis/cache", "/deis/database", "/deis/registry", "/deis/domains"} var testSessionUID = utils.NewUuid() fmt.Println("UUID for the session Builder Test :" + testSessionUID) etcdPort := utils.GetRandomPort() servicePort := utils.GetRandomPort() dockercliutils.RunEtcdTest(t, testSessionUID, etcdPort) Builderhandler := etcdutils.InitetcdValues(setdir, setkeys, etcdPort) etcdutils.Publishvalues(t, Builderhandler) fmt.Println("starting Builder Component test") runDeisBuilderTest(t, testSessionUID, etcdPort, servicePort) // TODO: builder needs a few seconds to wake up here--fixme! time.Sleep(5000 * time.Millisecond) dockercliutils.DeisServiceTest( t, "deis-builder-"+testSessionUID, servicePort, "tcp") dockercliutils.ClearTestSession(t, testSessionUID) }
func TestBuilder(t *testing.T) { setkeys := []string{ "/deis/registry/protocol", "deis/registry/host", "/deis/registry/port", "/deis/cache/host", "/deis/cache/port", } setdir := []string{ "/deis/controller", "/deis/cache", "/deis/database", "/deis/registry", "/deis/domains", "/deis/services", } testID := utils.NewUuid() err := dockercliutils.BuildImage(t, "../", "deis/builder:"+testID) if err != nil { t.Fatal(err) } etcdPort := utils.GetRandomPort() dockercliutils.RunEtcdTest(t, testID, etcdPort) handler := etcdutils.InitetcdValues(setdir, setkeys, etcdPort) etcdutils.Publishvalues(t, handler) servicePort := utils.GetRandomPort() fmt.Printf("--- Test deis-builder-%s at port %s\n", testID, servicePort) runDeisBuilderTest(t, testID, etcdPort, servicePort) // TODO: builder needs a few seconds to wake up here--fixme! time.Sleep(5000 * time.Millisecond) dockercliutils.DeisServiceTest( t, "deis-builder-"+testID, servicePort, "tcp") dockercliutils.ClearTestSession(t, testID) }
// RunMockDatabase starts a mock postgresql database for testing. func RunMockDatabase(t *testing.T, uid string, etcdPort string, dbPort string) { var err error cli, stdout, stdoutPipe := dockercliutils.GetNewClient() done := make(chan bool, 1) var imageID string var imageTag string ipaddr := utils.GetHostIPAddress() fmt.Println("starting Mock Database") done <- true go func() { <-done dockercliutils.PullImage(t, cli, "paintedfox/postgresql") imageID = dockercliutils.GetImageID(t, "paintedfox/postgresql") imageTag = "deis/test-database:" + uid cli.CmdTag(imageID, imageTag) err = dockercliutils.RunContainer(cli, "--name", "deis-test-database-"+uid, "--rm", "-p", dbPort+":5432", "-e", "PUBLISH="+dbPort, "-e", "HOST="+ipaddr, "-e", "USER=deis", "-e", "DB=deis", "-e", "PASS=deis", "deis/test-database:"+uid) }() time.Sleep(1000 * time.Millisecond) dockercliutils.PrintToStdout(t, stdout, stdoutPipe, "Starting") // docker run --name="deis-database" -p -e PUBLISH=5432 // -e HOST=172.17.8.100 -e USER="******" -e DB="deis" // -e PASS="******" deis/database setkeys := []string{"/deis/database/user", "/deis/database/password", "/deis/database/name"} setdir := []string{} dbhandler := etcdutils.InitetcdValues(setdir, setkeys, etcdPort) etcdutils.Publishvalues(t, dbhandler) etcdutils.SetEtcdValues(t, []string{"/deis/database/host", "/deis/database/port", "/deis/database/engine"}, []string{ipaddr, dbPort, "postgresql_psycopg2"}, dbhandler.C) if err != nil { t.Fatal(err) } }
// RunMockDatabase starts a mock postgresql database for testing. func RunMockDatabase(t *testing.T, uid string, etcdPort string, dbPort string) { var err error cli, stdout, stdoutPipe := dockercli.GetNewClient() done := make(chan bool, 1) dbImage := "paintedfox/postgresql:latest" ipaddr := utils.GetHostIPAddress() done <- true go func() { <-done err = dockercli.RunContainer(cli, "--name", "deis-test-database-"+uid, "--rm", "-p", dbPort+":5432", "-e", "PUBLISH="+dbPort, "-e", "HOST="+ipaddr, "-e", "USER=deis", "-e", "DB=deis", "-e", "PASS=deis", dbImage) }() time.Sleep(1000 * time.Millisecond) dockercli.PrintToStdout(t, stdout, stdoutPipe, "Starting") setkeys := []string{ "/deis/database/user", "/deis/database/password", "/deis/database/name", } setdir := []string{} dbhandler := etcdutils.InitetcdValues(setdir, setkeys, etcdPort) etcdutils.Publishvalues(t, dbhandler) etcdutils.SetEtcdValues(t, []string{"/deis/database/host", "/deis/database/port", "/deis/database/engine"}, []string{ipaddr, dbPort, "postgresql_psycopg2"}, dbhandler.C) if err != nil { t.Fatal(err) } }
func TestRegistry(t *testing.T) { setkeys := []string{ "/deis/cache/host", "/deis/cache/port", } setdir := []string{ "/deis/cache", } testID := utils.NewID() err := dockercli.BuildImage(t, "../", "deis/registry:"+testID) if err != nil { t.Fatal(err) } etcdPort := utils.GetRandomPort() dockercli.RunEtcdTest(t, testID, etcdPort) handler := etcdutils.InitetcdValues(setdir, setkeys, etcdPort) etcdutils.Publishvalues(t, handler) servicePort := utils.GetRandomPort() fmt.Printf("--- Test deis-registry-%s at port %s\n", testID, servicePort) runDeisRegistryTest(t, testID, etcdPort, servicePort) dockercli.DeisServiceTest( t, "deis-registry-"+testID, servicePort, "http") dockercli.ClearTestSession(t, testID) }