github.com/technosophos/deis@v1.7.1-0.20150915173815-f9005256004b/cache/tests/cache_test.go (about) 1 package tests 2 3 import ( 4 "fmt" 5 "testing" 6 "time" 7 8 "github.com/deis/deis/tests/dockercli" 9 "github.com/deis/deis/tests/etcdutils" 10 "github.com/deis/deis/tests/utils" 11 ) 12 13 func TestCache(t *testing.T) { 14 var err error 15 tag := utils.BuildTag() 16 imageName := utils.ImagePrefix() + "cache" + ":" + tag 17 etcdPort := utils.RandomPort() 18 etcdName := "deis-etcd-" + tag 19 cli, stdout, stdoutPipe := dockercli.NewClient() 20 dockercli.RunTestEtcd(t, etcdName, etcdPort) 21 defer cli.CmdRm("-f", etcdName) 22 host, port := utils.HostAddress(), utils.RandomPort() 23 fmt.Printf("--- Run %s at %s:%s\n", imageName, host, port) 24 name := "deis-cache-" + tag 25 defer cli.CmdRm("-f", name) 26 go func() { 27 _ = cli.CmdRm("-f", name) 28 err = dockercli.RunContainer(cli, 29 "--name", name, 30 "--rm", 31 "-p", port+":6379", 32 "-e", "EXTERNAL_PORT="+port, 33 "-e", "HOST="+host, 34 "-e", "ETCD_PORT="+etcdPort, 35 imageName) 36 }() 37 dockercli.PrintToStdout(t, stdout, stdoutPipe, "started") 38 if err != nil { 39 t.Fatal(err) 40 } 41 // FIXME: Wait until etcd keys are published 42 time.Sleep(5000 * time.Millisecond) 43 dockercli.DeisServiceTest(t, name, port, "tcp") 44 etcdutils.VerifyEtcdValue(t, "/deis/cache/host", host, etcdPort) 45 etcdutils.VerifyEtcdValue(t, "/deis/cache/port", port, etcdPort) 46 }