Use suite for integration-cli

It prints test name and duration for each test.
Also performs deleteAllContainers after each test.

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: dc944ea7e48d11a2906e751d3e61daf08faee054
Component: engine
This commit is contained in:
Alexander Morozov
2015-04-18 09:46:47 -07:00
parent 36fe7b2098
commit 1884ef3b9b
60 changed files with 3746 additions and 4807 deletions

View File

@ -4,30 +4,30 @@ import (
"net"
"os/exec"
"strings"
"testing"
"github.com/go-check/check"
)
func TestCliProxyDisableProxyUnixSock(t *testing.T) {
testRequires(t, SameHostDaemon) // test is valid when DOCKER_HOST=unix://..
func (s *DockerSuite) TestCliProxyDisableProxyUnixSock(c *check.C) {
testRequires(c, SameHostDaemon) // test is valid when DOCKER_HOST=unix://..
cmd := exec.Command(dockerBinary, "info")
cmd.Env = appendBaseEnv([]string{"HTTP_PROXY=http://127.0.0.1:9999"})
if out, _, err := runCommandWithOutput(cmd); err != nil {
t.Fatal(err, out)
c.Fatal(err, out)
}
logDone("cli proxy - HTTP_PROXY is not used when connecting to unix sock")
}
// Can't use localhost here since go has a special case to not use proxy if connecting to localhost
// See https://golang.org/pkg/net/http/#ProxyFromEnvironment
func TestCliProxyProxyTCPSock(t *testing.T) {
testRequires(t, SameHostDaemon)
func (s *DockerSuite) TestCliProxyProxyTCPSock(c *check.C) {
testRequires(c, SameHostDaemon)
// get the IP to use to connect since we can't use localhost
addrs, err := net.InterfaceAddrs()
if err != nil {
t.Fatal(err)
c.Fatal(err)
}
var ip string
for _, addr := range addrs {
@ -40,25 +40,24 @@ func TestCliProxyProxyTCPSock(t *testing.T) {
}
if ip == "" {
t.Fatal("could not find ip to connect to")
c.Fatal("could not find ip to connect to")
}
d := NewDaemon(t)
d := NewDaemon(c)
if err := d.Start("-H", "tcp://"+ip+":2375"); err != nil {
t.Fatal(err)
c.Fatal(err)
}
cmd := exec.Command(dockerBinary, "info")
cmd.Env = []string{"DOCKER_HOST=tcp://" + ip + ":2375", "HTTP_PROXY=127.0.0.1:9999"}
if out, _, err := runCommandWithOutput(cmd); err == nil {
t.Fatal(err, out)
c.Fatal(err, out)
}
// Test with no_proxy
cmd.Env = append(cmd.Env, "NO_PROXY="+ip)
if out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "info")); err != nil {
t.Fatal(err, out)
c.Fatal(err, out)
}
logDone("cli proxy - HTTP_PROXY is used for TCP sock")
}