github.com/chasestarr/deis@v1.13.5-0.20170519182049-1d9e59fbdbfc/logger/tests/logger_test.go (about) 1 package tests 2 3 import ( 4 "fmt" 5 "io/ioutil" 6 "os" 7 "testing" 8 "time" 9 10 "github.com/deis/deis/tests/dockercli" 11 "github.com/deis/deis/tests/etcdutils" 12 "github.com/deis/deis/tests/utils" 13 ) 14 15 func TestLogger(t *testing.T) { 16 var err error 17 tag, etcdPort := utils.BuildTag(), utils.RandomPort() 18 imageName := utils.ImagePrefix() + "logger" + ":" + tag 19 20 //start etcd container 21 etcdName := "deis-etcd-" + tag 22 cli, stdout, stdoutPipe := dockercli.NewClient() 23 dockercli.RunTestEtcd(t, etcdName, etcdPort) 24 defer cli.CmdRm("-f", etcdName) 25 26 host, port := utils.HostAddress(), utils.RandomPort() 27 fmt.Printf("--- Run %s at %s:%s\n", imageName, host, port) 28 name := "deis-logger-" + tag 29 defer cli.CmdRm("-f", name) 30 tempLogDir, err := ioutil.TempDir("", "log-tests") 31 defer os.Remove(tempLogDir) 32 go func() { 33 _ = cli.CmdRm("-f", name) 34 err = dockercli.RunContainer(cli, 35 "--name", name, 36 "--rm", 37 "-p", port+":514/udp", 38 "-v", tempLogDir+":/data/logs", 39 imageName, 40 "--enable-publish", 41 "--log-host="+host, 42 "--log-port="+port, 43 "--publish-host="+host, 44 "--publish-port="+etcdPort) 45 }() 46 dockercli.PrintToStdout(t, stdout, stdoutPipe, "deis-logger running") 47 if err != nil { 48 t.Fatal(err) 49 } 50 // FIXME: Wait until etcd keys are published 51 time.Sleep(15 * time.Second) 52 dockercli.DeisServiceTest(t, name, port, "udp") 53 etcdutils.VerifyEtcdValue(t, "/deis/logs/host", host, etcdPort) 54 etcdutils.VerifyEtcdValue(t, "/deis/logs/port", port, etcdPort) 55 }