mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
integration-cli: remove unnescessary conversions (unconvert)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com> Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
417eac47a0
commit
7c40c0a922
22 changed files with 96 additions and 99 deletions
|
@ -94,7 +94,7 @@ func (d *Daemon) CheckActiveContainerCount(c *testing.T) (interface{}, string) {
|
|||
if len(strings.TrimSpace(out)) == 0 {
|
||||
return 0, ""
|
||||
}
|
||||
return len(strings.Split(strings.TrimSpace(out), "\n")), fmt.Sprintf("output: %q", string(out))
|
||||
return len(strings.Split(strings.TrimSpace(out), "\n")), fmt.Sprintf("output: %q", out)
|
||||
}
|
||||
|
||||
// WaitRun waits for a container to be running for 10s
|
||||
|
|
|
@ -27,7 +27,7 @@ func (s *DockerSuite) TestGetContainersAttachWebsocket(c *testing.T) {
|
|||
testRequires(c, DaemonIsLinux)
|
||||
out, _ := dockerCmd(c, "run", "-dit", "busybox", "cat")
|
||||
|
||||
rwc, err := request.SockConn(time.Duration(10*time.Second), request.DaemonHost())
|
||||
rwc, err := request.SockConn(10*time.Second, request.DaemonHost())
|
||||
assert.NilError(c, err)
|
||||
|
||||
cleanedContainerID := strings.TrimSpace(out)
|
||||
|
@ -237,7 +237,7 @@ func sockRequestHijack(method, endpoint string, data io.Reader, ct string, daemo
|
|||
// Deprecated: Use New instead of NewRequestClient
|
||||
// Deprecated: use request.Do (or Get, Delete, Post) instead
|
||||
func newRequestClient(method, endpoint string, data io.Reader, ct, daemon string, modifiers ...func(*http.Request)) (*http.Request, *httputil.ClientConn, error) {
|
||||
c, err := request.SockConn(time.Duration(10*time.Second), daemon)
|
||||
c, err := request.SockConn(10*time.Second, daemon)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("could not dial docker daemon: %v", err)
|
||||
}
|
||||
|
|
|
@ -394,7 +394,7 @@ func (s *DockerSuite) TestContainerAPIPause(c *testing.T) {
|
|||
func (s *DockerSuite) TestContainerAPITop(c *testing.T) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "top")
|
||||
id := strings.TrimSpace(string(out))
|
||||
id := strings.TrimSpace(out)
|
||||
assert.NilError(c, waitRun(id))
|
||||
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
|
@ -417,7 +417,7 @@ func (s *DockerSuite) TestContainerAPITop(c *testing.T) {
|
|||
func (s *DockerSuite) TestContainerAPITopWindows(c *testing.T) {
|
||||
testRequires(c, DaemonIsWindows)
|
||||
out := runSleepingContainer(c, "-d")
|
||||
id := strings.TrimSpace(string(out))
|
||||
id := strings.TrimSpace(out)
|
||||
assert.NilError(c, waitRun(id))
|
||||
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
|
@ -614,7 +614,7 @@ func UtilCreateNetworkMode(c *testing.T, networkMode containertypes.NetworkMode)
|
|||
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID)
|
||||
assert.NilError(c, err)
|
||||
|
||||
assert.Equal(c, containerJSON.HostConfig.NetworkMode, containertypes.NetworkMode(networkMode), "Mismatched NetworkMode")
|
||||
assert.Equal(c, containerJSON.HostConfig.NetworkMode, networkMode, "Mismatched NetworkMode")
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestContainerAPICreateWithCpuSharesCpuset(c *testing.T) {
|
||||
|
|
|
@ -84,7 +84,7 @@ func (s *DockerSuite) TestAPIImagesSaveAndLoad(c *testing.T) {
|
|||
assert.Equal(c, res.StatusCode, http.StatusOK)
|
||||
|
||||
inspectOut := cli.InspectCmd(c, id, cli.Format(".Id")).Combined()
|
||||
assert.Equal(c, strings.TrimSpace(string(inspectOut)), id, "load did not work properly")
|
||||
assert.Equal(c, strings.TrimSpace(inspectOut), id, "load did not work properly")
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestAPIImagesDelete(c *testing.T) {
|
||||
|
|
|
@ -595,7 +595,7 @@ func (s *DockerSwarmSuite) TestAPISwarmForceNewCluster(c *testing.T) {
|
|||
|
||||
func simpleTestService(s *swarm.Service) {
|
||||
ureplicas := uint64(1)
|
||||
restartDelay := time.Duration(100 * time.Millisecond)
|
||||
restartDelay := 100 * time.Millisecond
|
||||
|
||||
s.Spec = swarm.ServiceSpec{
|
||||
TaskTemplate: swarm.TaskSpec{
|
||||
|
@ -618,7 +618,7 @@ func simpleTestService(s *swarm.Service) {
|
|||
|
||||
func serviceForUpdate(s *swarm.Service) {
|
||||
ureplicas := uint64(1)
|
||||
restartDelay := time.Duration(100 * time.Millisecond)
|
||||
restartDelay := 100 * time.Millisecond
|
||||
|
||||
s.Spec = swarm.ServiceSpec{
|
||||
TaskTemplate: swarm.TaskSpec{
|
||||
|
|
|
@ -2082,7 +2082,7 @@ CMD ["cat", "/foo"]`),
|
|||
}).Assert(c, icmd.Success)
|
||||
|
||||
res := inspectField(c, name, "Config.Cmd")
|
||||
assert.Equal(c, strings.TrimSpace(string(res)), `[cat /foo]`)
|
||||
assert.Equal(c, strings.TrimSpace(res), `[cat /foo]`)
|
||||
}
|
||||
|
||||
// FIXME(vdemeester) migrate to docker/cli tests (unit or e2e)
|
||||
|
|
|
@ -40,7 +40,7 @@ func (s *DockerSuite) TestCreateArgs(c *testing.T) {
|
|||
assert.Equal(c, len(containers), 1)
|
||||
|
||||
cont := containers[0]
|
||||
assert.Equal(c, string(cont.Path), "command", fmt.Sprintf("Unexpected container path. Expected command, received: %s", cont.Path))
|
||||
assert.Equal(c, cont.Path, "command", fmt.Sprintf("Unexpected container path. Expected command, received: %s", cont.Path))
|
||||
|
||||
b := false
|
||||
expected := []string{"arg1", "arg2", "arg with space", "-c", "flags"}
|
||||
|
@ -325,7 +325,7 @@ func (s *DockerSuite) TestCreateWithInvalidLogOpts(c *testing.T) {
|
|||
// #20972
|
||||
func (s *DockerSuite) TestCreate64ByteHexID(c *testing.T) {
|
||||
out := inspectField(c, "busybox", "Id")
|
||||
imageID := strings.TrimPrefix(strings.TrimSpace(string(out)), "sha256:")
|
||||
imageID := strings.TrimPrefix(strings.TrimSpace(out), "sha256:")
|
||||
|
||||
dockerCmd(c, "create", imageID)
|
||||
}
|
||||
|
|
|
@ -1854,11 +1854,11 @@ func (s *DockerDaemonSuite) TestDaemonCgroupParent(c *testing.T) {
|
|||
|
||||
out, err := s.d.Cmd("run", "--name", name, "busybox", "cat", "/proc/self/cgroup")
|
||||
assert.NilError(c, err)
|
||||
cgroupPaths := ParseCgroupPaths(string(out))
|
||||
assert.Assert(c, len(cgroupPaths) != 0, "unexpected output - %q", string(out))
|
||||
cgroupPaths := ParseCgroupPaths(out)
|
||||
assert.Assert(c, len(cgroupPaths) != 0, "unexpected output - %q", out)
|
||||
out, err = s.d.Cmd("inspect", "-f", "{{.Id}}", name)
|
||||
assert.NilError(c, err)
|
||||
id := strings.TrimSpace(string(out))
|
||||
id := strings.TrimSpace(out)
|
||||
expectedCgroup := path.Join(cgroupParent, id)
|
||||
found := false
|
||||
for _, path := range cgroupPaths {
|
||||
|
|
|
@ -329,7 +329,7 @@ func (s *DockerSuite) TestImagesFormat(c *testing.T) {
|
|||
dockerCmd(c, "tag", "busybox", tag+":v2")
|
||||
|
||||
out, _ := dockerCmd(c, "images", "--format", "{{.Repository}}", tag)
|
||||
lines := strings.Split(strings.TrimSpace(string(out)), "\n")
|
||||
lines := strings.Split(strings.TrimSpace(out), "\n")
|
||||
|
||||
expected := []string{"myimage", "myimage"}
|
||||
var names []string
|
||||
|
|
|
@ -161,7 +161,7 @@ func (s *DockerSuite) TestLinksUpdateOnRestart(c *testing.T) {
|
|||
testRequires(c, testEnv.IsLocalDaemon)
|
||||
dockerCmd(c, "run", "-d", "--name", "one", "busybox", "top")
|
||||
out, _ := dockerCmd(c, "run", "-d", "--name", "two", "--link", "one:onetwo", "--link", "one:one", "busybox", "top")
|
||||
id := strings.TrimSpace(string(out))
|
||||
id := strings.TrimSpace(out)
|
||||
|
||||
realIP := inspectField(c, "one", "NetworkSettings.Networks.bridge.IPAddress")
|
||||
content := readContainerFileWithExec(c, id, "/etc/hosts")
|
||||
|
|
|
@ -812,14 +812,14 @@ func (s *DockerDaemonSuite) TestDockerNetworkNoDiscoveryDefaultBridgeNetwork(c *
|
|||
// verify first container's etc/hosts file has not changed after spawning the second named container
|
||||
hostsPost, err := s.d.Cmd("exec", cid1, "cat", hostsFile)
|
||||
assert.NilError(c, err)
|
||||
assert.Equal(c, string(hosts), string(hostsPost), fmt.Sprintf("Unexpected %s change on second container creation", hostsFile))
|
||||
assert.Equal(c, hosts, hostsPost, fmt.Sprintf("Unexpected %s change on second container creation", hostsFile))
|
||||
// stop container 2 and verify first container's etc/hosts has not changed
|
||||
_, err = s.d.Cmd("stop", cid2)
|
||||
assert.NilError(c, err)
|
||||
|
||||
hostsPost, err = s.d.Cmd("exec", cid1, "cat", hostsFile)
|
||||
assert.NilError(c, err)
|
||||
assert.Equal(c, string(hosts), string(hostsPost), fmt.Sprintf("Unexpected %s change on second container creation", hostsFile))
|
||||
assert.Equal(c, hosts, hostsPost, fmt.Sprintf("Unexpected %s change on second container creation", hostsFile))
|
||||
// but discovery is on when connecting to non default bridge network
|
||||
network := "anotherbridge"
|
||||
out, err = s.d.Cmd("network", "create", network)
|
||||
|
@ -834,7 +834,7 @@ func (s *DockerDaemonSuite) TestDockerNetworkNoDiscoveryDefaultBridgeNetwork(c *
|
|||
|
||||
hostsPost, err = s.d.Cmd("exec", cid1, "cat", hostsFile)
|
||||
assert.NilError(c, err)
|
||||
assert.Equal(c, string(hosts), string(hostsPost), fmt.Sprintf("Unexpected %s change on second network connection", hostsFile))
|
||||
assert.Equal(c, hosts, hostsPost, fmt.Sprintf("Unexpected %s change on second network connection", hostsFile))
|
||||
}
|
||||
|
||||
func (s *DockerNetworkSuite) TestDockerNetworkAnonymousEndpoint(c *testing.T) {
|
||||
|
@ -1683,7 +1683,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartRestoreBridgeNetwork(t *testing.T)
|
|||
// Cleanup because these containers will not be shut down by daemon
|
||||
out, err = s.d.Cmd("stop", newCon)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v %v", err, string(out))
|
||||
t.Fatalf("err: %v %v", err, out)
|
||||
}
|
||||
_, err = s.d.Cmd("stop", strings.TrimSpace(id))
|
||||
if err != nil {
|
||||
|
|
|
@ -473,22 +473,22 @@ func (s *DockerSuite) TestPsRightTagName(c *testing.T) {
|
|||
|
||||
var id1 string
|
||||
out := runSleepingContainer(c)
|
||||
id1 = strings.TrimSpace(string(out))
|
||||
id1 = strings.TrimSpace(out)
|
||||
|
||||
var id2 string
|
||||
out = runSleepingContainerInImage(c, tag)
|
||||
id2 = strings.TrimSpace(string(out))
|
||||
id2 = strings.TrimSpace(out)
|
||||
|
||||
var imageID string
|
||||
out = inspectField(c, "busybox", "Id")
|
||||
imageID = strings.TrimSpace(string(out))
|
||||
imageID = strings.TrimSpace(out)
|
||||
|
||||
var id3 string
|
||||
out = runSleepingContainerInImage(c, imageID)
|
||||
id3 = strings.TrimSpace(string(out))
|
||||
id3 = strings.TrimSpace(out)
|
||||
|
||||
out, _ = dockerCmd(c, "ps", "--no-trunc")
|
||||
lines := strings.Split(strings.TrimSpace(string(out)), "\n")
|
||||
lines := strings.Split(strings.TrimSpace(out), "\n")
|
||||
lines = RemoveLinesForExistingElements(lines, existingContainers)
|
||||
// skip header
|
||||
lines = lines[1:]
|
||||
|
@ -557,7 +557,7 @@ func (s *DockerSuite) TestPsImageIDAfterUpdate(c *testing.T) {
|
|||
result = icmd.RunCommand(dockerBinary, "ps", "--no-trunc")
|
||||
result.Assert(c, icmd.Success)
|
||||
|
||||
lines := strings.Split(strings.TrimSpace(string(result.Combined())), "\n")
|
||||
lines := strings.Split(strings.TrimSpace(result.Combined()), "\n")
|
||||
lines = RemoveLinesForExistingElements(lines, existingContainers)
|
||||
// skip header
|
||||
lines = lines[1:]
|
||||
|
@ -574,7 +574,7 @@ func (s *DockerSuite) TestPsImageIDAfterUpdate(c *testing.T) {
|
|||
result = icmd.RunCommand(dockerBinary, "ps", "--no-trunc")
|
||||
result.Assert(c, icmd.Success)
|
||||
|
||||
lines = strings.Split(strings.TrimSpace(string(result.Combined())), "\n")
|
||||
lines = strings.Split(strings.TrimSpace(result.Combined()), "\n")
|
||||
lines = RemoveLinesForExistingElements(lines, existingContainers)
|
||||
// skip header
|
||||
lines = lines[1:]
|
||||
|
@ -592,7 +592,7 @@ func (s *DockerSuite) TestPsNotShowPortsOfStoppedContainer(c *testing.T) {
|
|||
dockerCmd(c, "run", "--name=foo", "-d", "-p", "5000:5000", "busybox", "top")
|
||||
assert.Assert(c, waitRun("foo") == nil)
|
||||
out, _ := dockerCmd(c, "ps")
|
||||
lines := strings.Split(strings.TrimSpace(string(out)), "\n")
|
||||
lines := strings.Split(strings.TrimSpace(out), "\n")
|
||||
expected := "0.0.0.0:5000->5000/tcp"
|
||||
fields := strings.Fields(lines[1])
|
||||
assert.Equal(c, fields[len(fields)-2], expected, fmt.Sprintf("Expected: %v, got: %v", expected, fields[len(fields)-2]))
|
||||
|
@ -600,7 +600,7 @@ func (s *DockerSuite) TestPsNotShowPortsOfStoppedContainer(c *testing.T) {
|
|||
dockerCmd(c, "kill", "foo")
|
||||
dockerCmd(c, "wait", "foo")
|
||||
out, _ = dockerCmd(c, "ps", "-l")
|
||||
lines = strings.Split(strings.TrimSpace(string(out)), "\n")
|
||||
lines = strings.Split(strings.TrimSpace(out), "\n")
|
||||
fields = strings.Fields(lines[1])
|
||||
assert.Assert(c, fields[len(fields)-2] != expected, "Should not got %v", expected)
|
||||
}
|
||||
|
@ -633,7 +633,7 @@ func (s *DockerSuite) TestPsShowMounts(c *testing.T) {
|
|||
|
||||
out, _ := dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}")
|
||||
|
||||
lines := strings.Split(strings.TrimSpace(string(out)), "\n")
|
||||
lines := strings.Split(strings.TrimSpace(out), "\n")
|
||||
lines = RemoveLinesForExistingElements(lines, existingContainers)
|
||||
assert.Equal(c, len(lines), 3)
|
||||
|
||||
|
@ -653,7 +653,7 @@ func (s *DockerSuite) TestPsShowMounts(c *testing.T) {
|
|||
// filter by volume name
|
||||
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume=ps-volume-test")
|
||||
|
||||
lines = strings.Split(strings.TrimSpace(string(out)), "\n")
|
||||
lines = strings.Split(strings.TrimSpace(out), "\n")
|
||||
lines = RemoveLinesForExistingElements(lines, existingContainers)
|
||||
assert.Equal(c, len(lines), 1)
|
||||
|
||||
|
@ -662,12 +662,12 @@ func (s *DockerSuite) TestPsShowMounts(c *testing.T) {
|
|||
|
||||
// empty results filtering by unknown volume
|
||||
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume=this-volume-should-not-exist")
|
||||
assert.Equal(c, len(strings.TrimSpace(string(out))), 0)
|
||||
assert.Equal(c, len(strings.TrimSpace(out)), 0)
|
||||
|
||||
// filter by mount destination
|
||||
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume="+mp)
|
||||
|
||||
lines = strings.Split(strings.TrimSpace(string(out)), "\n")
|
||||
lines = strings.Split(strings.TrimSpace(out), "\n")
|
||||
lines = RemoveLinesForExistingElements(lines, existingContainers)
|
||||
assert.Equal(c, len(lines), 2)
|
||||
|
||||
|
@ -679,7 +679,7 @@ func (s *DockerSuite) TestPsShowMounts(c *testing.T) {
|
|||
// filter by bind mount source
|
||||
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume="+bindMountSource)
|
||||
|
||||
lines = strings.Split(strings.TrimSpace(string(out)), "\n")
|
||||
lines = strings.Split(strings.TrimSpace(out), "\n")
|
||||
lines = RemoveLinesForExistingElements(lines, existingContainers)
|
||||
assert.Equal(c, len(lines), 1)
|
||||
|
||||
|
@ -691,7 +691,7 @@ func (s *DockerSuite) TestPsShowMounts(c *testing.T) {
|
|||
// filter by bind mount destination
|
||||
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume="+bindMountDestination)
|
||||
|
||||
lines = strings.Split(strings.TrimSpace(string(out)), "\n")
|
||||
lines = strings.Split(strings.TrimSpace(out), "\n")
|
||||
lines = RemoveLinesForExistingElements(lines, existingContainers)
|
||||
assert.Equal(c, len(lines), 1)
|
||||
|
||||
|
@ -702,7 +702,7 @@ func (s *DockerSuite) TestPsShowMounts(c *testing.T) {
|
|||
|
||||
// empty results filtering by unknown mount point
|
||||
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume="+prefix+slash+"this-path-was-never-mounted")
|
||||
assert.Equal(c, len(strings.TrimSpace(string(out))), 0)
|
||||
assert.Equal(c, len(strings.TrimSpace(out)), 0)
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestPsListContainersFilterNetwork(c *testing.T) {
|
||||
|
@ -718,7 +718,7 @@ func (s *DockerSuite) TestPsListContainersFilterNetwork(c *testing.T) {
|
|||
|
||||
// Filter docker ps on non existing network
|
||||
out, _ := dockerCmd(c, "ps", "--filter", "network=doesnotexist")
|
||||
containerOut := strings.TrimSpace(string(out))
|
||||
containerOut := strings.TrimSpace(out)
|
||||
lines := strings.Split(containerOut, "\n")
|
||||
|
||||
// skip header
|
||||
|
@ -729,7 +729,7 @@ func (s *DockerSuite) TestPsListContainersFilterNetwork(c *testing.T) {
|
|||
|
||||
// Filter docker ps on network bridge
|
||||
out, _ = dockerCmd(c, "ps", "--filter", "network=bridge")
|
||||
containerOut = strings.TrimSpace(string(out))
|
||||
containerOut = strings.TrimSpace(out)
|
||||
|
||||
lines = strings.Split(containerOut, "\n")
|
||||
|
||||
|
@ -743,7 +743,7 @@ func (s *DockerSuite) TestPsListContainersFilterNetwork(c *testing.T) {
|
|||
assert.Assert(c, strings.Contains(containerOut, "onbridgenetwork"), "Missing the container on network\n")
|
||||
// Filter docker ps on networks bridge and none
|
||||
out, _ = dockerCmd(c, "ps", "--filter", "network=bridge", "--filter", "network=none")
|
||||
containerOut = strings.TrimSpace(string(out))
|
||||
containerOut = strings.TrimSpace(out)
|
||||
|
||||
lines = strings.Split(containerOut, "\n")
|
||||
|
||||
|
@ -760,15 +760,15 @@ func (s *DockerSuite) TestPsListContainersFilterNetwork(c *testing.T) {
|
|||
|
||||
// Filter by network ID
|
||||
out, _ = dockerCmd(c, "ps", "--filter", "network="+nwID)
|
||||
containerOut = strings.TrimSpace(string(out))
|
||||
containerOut = strings.TrimSpace(out)
|
||||
|
||||
assert.Assert(c, is.Contains(containerOut, "onbridgenetwork"))
|
||||
|
||||
// Filter by partial network ID
|
||||
partialnwID := string(nwID[0:4])
|
||||
partialnwID := nwID[0:4]
|
||||
|
||||
out, _ = dockerCmd(c, "ps", "--filter", "network="+partialnwID)
|
||||
containerOut = strings.TrimSpace(string(out))
|
||||
containerOut = strings.TrimSpace(out)
|
||||
|
||||
lines = strings.Split(containerOut, "\n")
|
||||
|
||||
|
@ -844,7 +844,7 @@ func (s *DockerSuite) TestPsNotShowLinknamesOfDeletedContainer(c *testing.T) {
|
|||
dockerCmd(c, "create", "--name=bbb", "--link=aaa", "busybox", "top")
|
||||
|
||||
out, _ := dockerCmd(c, "ps", "--no-trunc", "-a", "--format", "{{.Names}}")
|
||||
lines := strings.Split(strings.TrimSpace(string(out)), "\n")
|
||||
lines := strings.Split(strings.TrimSpace(out), "\n")
|
||||
lines = RemoveLinesForExistingElements(lines, existingContainers)
|
||||
expected := []string{"bbb", "aaa,bbb/aaa"}
|
||||
var names []string
|
||||
|
|
|
@ -333,7 +333,7 @@ func (s *DockerRegistrySuite) TestPullManifestList(c *testing.T) {
|
|||
err = os.MkdirAll(blobDir, 0755)
|
||||
assert.NilError(c, err, "error creating blob dir")
|
||||
blobPath := filepath.Join(blobDir, "data")
|
||||
err = ioutil.WriteFile(blobPath, []byte(manifestListJSON), 0644)
|
||||
err = ioutil.WriteFile(blobPath, manifestListJSON, 0644)
|
||||
assert.NilError(c, err, "error writing manifest list")
|
||||
|
||||
// Add to revision store
|
||||
|
|
|
@ -18,13 +18,13 @@ func unescapeBackslashSemicolonParens(s string) string {
|
|||
ret := re.ReplaceAll([]byte(s), []byte(";"))
|
||||
|
||||
re = regexp.MustCompile(`\\\(`)
|
||||
ret = re.ReplaceAll([]byte(ret), []byte("("))
|
||||
ret = re.ReplaceAll(ret, []byte("("))
|
||||
|
||||
re = regexp.MustCompile(`\\\)`)
|
||||
ret = re.ReplaceAll([]byte(ret), []byte(")"))
|
||||
ret = re.ReplaceAll(ret, []byte(")"))
|
||||
|
||||
re = regexp.MustCompile(`\\\\`)
|
||||
ret = re.ReplaceAll([]byte(ret), []byte(`\`))
|
||||
ret = re.ReplaceAll(ret, []byte(`\`))
|
||||
|
||||
return string(ret)
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ func (s *DockerSuite) TestRestartDisconnectedContainer(c *testing.T) {
|
|||
func (s *DockerSuite) TestRestartPolicyNO(c *testing.T) {
|
||||
out, _ := dockerCmd(c, "create", "--restart=no", "busybox")
|
||||
|
||||
id := strings.TrimSpace(string(out))
|
||||
id := strings.TrimSpace(out)
|
||||
name := inspectField(c, id, "HostConfig.RestartPolicy.Name")
|
||||
assert.Equal(c, name, "no")
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ func (s *DockerSuite) TestRestartPolicyNO(c *testing.T) {
|
|||
func (s *DockerSuite) TestRestartPolicyAlways(c *testing.T) {
|
||||
out, _ := dockerCmd(c, "create", "--restart=always", "busybox")
|
||||
|
||||
id := strings.TrimSpace(string(out))
|
||||
id := strings.TrimSpace(out)
|
||||
name := inspectField(c, id, "HostConfig.RestartPolicy.Name")
|
||||
assert.Equal(c, name, "always")
|
||||
|
||||
|
@ -123,7 +123,7 @@ func (s *DockerSuite) TestRestartPolicyOnFailure(c *testing.T) {
|
|||
|
||||
out, _ = dockerCmd(c, "create", "--restart=on-failure:1", "busybox")
|
||||
|
||||
id := strings.TrimSpace(string(out))
|
||||
id := strings.TrimSpace(out)
|
||||
name := inspectField(c, id, "HostConfig.RestartPolicy.Name")
|
||||
maxRetry := inspectField(c, id, "HostConfig.RestartPolicy.MaximumRetryCount")
|
||||
|
||||
|
@ -132,7 +132,7 @@ func (s *DockerSuite) TestRestartPolicyOnFailure(c *testing.T) {
|
|||
|
||||
out, _ = dockerCmd(c, "create", "--restart=on-failure:0", "busybox")
|
||||
|
||||
id = strings.TrimSpace(string(out))
|
||||
id = strings.TrimSpace(out)
|
||||
name = inspectField(c, id, "HostConfig.RestartPolicy.Name")
|
||||
maxRetry = inspectField(c, id, "HostConfig.RestartPolicy.MaximumRetryCount")
|
||||
|
||||
|
@ -141,7 +141,7 @@ func (s *DockerSuite) TestRestartPolicyOnFailure(c *testing.T) {
|
|||
|
||||
out, _ = dockerCmd(c, "create", "--restart=on-failure", "busybox")
|
||||
|
||||
id = strings.TrimSpace(string(out))
|
||||
id = strings.TrimSpace(out)
|
||||
name = inspectField(c, id, "HostConfig.RestartPolicy.Name")
|
||||
maxRetry = inspectField(c, id, "HostConfig.RestartPolicy.MaximumRetryCount")
|
||||
|
||||
|
@ -154,7 +154,7 @@ func (s *DockerSuite) TestRestartPolicyOnFailure(c *testing.T) {
|
|||
func (s *DockerSuite) TestRestartContainerwithGoodContainer(c *testing.T) {
|
||||
out, _ := dockerCmd(c, "run", "-d", "--restart=on-failure:3", "busybox", "true")
|
||||
|
||||
id := strings.TrimSpace(string(out))
|
||||
id := strings.TrimSpace(out)
|
||||
err := waitInspect(id, "{{ .State.Restarting }} {{ .State.Running }}", "false false", 30*time.Second)
|
||||
assert.NilError(c, err)
|
||||
|
||||
|
@ -281,8 +281,8 @@ func (s *DockerSuite) TestRestartContainerwithRestartPolicy(c *testing.T) {
|
|||
out1, _ := dockerCmd(c, "run", "-d", "--restart=on-failure:3", "busybox", "false")
|
||||
out2, _ := dockerCmd(c, "run", "-d", "--restart=always", "busybox", "false")
|
||||
|
||||
id1 := strings.TrimSpace(string(out1))
|
||||
id2 := strings.TrimSpace(string(out2))
|
||||
id1 := strings.TrimSpace(out1)
|
||||
id2 := strings.TrimSpace(out2)
|
||||
waitTimeout := 15 * time.Second
|
||||
if testEnv.OSType == "windows" {
|
||||
waitTimeout = 150 * time.Second
|
||||
|
@ -311,7 +311,7 @@ func (s *DockerSuite) TestRestartContainerwithRestartPolicy(c *testing.T) {
|
|||
func (s *DockerSuite) TestRestartAutoRemoveContainer(c *testing.T) {
|
||||
out := runSleepingContainer(c, "--rm")
|
||||
|
||||
id := strings.TrimSpace(string(out))
|
||||
id := strings.TrimSpace(out)
|
||||
dockerCmd(c, "restart", id)
|
||||
err := waitInspect(id, "{{ .State.Restarting }} {{ .State.Running }}", "false true", 15*time.Second)
|
||||
assert.NilError(c, err)
|
||||
|
|
|
@ -1332,8 +1332,8 @@ func (s *DockerSuite) TestRunDNSOptionsBasedOnHostResolvConf(c *testing.T) {
|
|||
var out string
|
||||
out, _ = dockerCmd(c, "run", "--dns=127.0.0.1", "busybox", "cat", "/etc/resolv.conf")
|
||||
|
||||
if actualNameservers := resolvconf.GetNameservers([]byte(out), types.IP); string(actualNameservers[0]) != "127.0.0.1" {
|
||||
c.Fatalf("expected '127.0.0.1', but says: %q", string(actualNameservers[0]))
|
||||
if actualNameservers := resolvconf.GetNameservers([]byte(out), types.IP); actualNameservers[0] != "127.0.0.1" {
|
||||
c.Fatalf("expected '127.0.0.1', but says: %q", actualNameservers[0])
|
||||
}
|
||||
|
||||
actualSearch := resolvconf.GetSearchDomains([]byte(out))
|
||||
|
@ -1358,8 +1358,8 @@ func (s *DockerSuite) TestRunDNSOptionsBasedOnHostResolvConf(c *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
if actualSearch = resolvconf.GetSearchDomains([]byte(out)); string(actualSearch[0]) != "mydomain" {
|
||||
c.Fatalf("expected 'mydomain', but says: %q", string(actualSearch[0]))
|
||||
if actualSearch = resolvconf.GetSearchDomains([]byte(out)); actualSearch[0] != "mydomain" {
|
||||
c.Fatalf("expected 'mydomain', but says: %q", actualSearch[0])
|
||||
}
|
||||
|
||||
// test with file
|
||||
|
@ -1382,7 +1382,7 @@ func (s *DockerSuite) TestRunDNSOptionsBasedOnHostResolvConf(c *testing.T) {
|
|||
hostSearch = resolvconf.GetSearchDomains(resolvConf)
|
||||
|
||||
out, _ = dockerCmd(c, "run", "busybox", "cat", "/etc/resolv.conf")
|
||||
if actualNameservers = resolvconf.GetNameservers([]byte(out), types.IP); string(actualNameservers[0]) != "12.34.56.78" || len(actualNameservers) != 1 {
|
||||
if actualNameservers = resolvconf.GetNameservers([]byte(out), types.IP); actualNameservers[0] != "12.34.56.78" || len(actualNameservers) != 1 {
|
||||
c.Fatalf("expected '12.34.56.78', but has: %v", actualNameservers)
|
||||
}
|
||||
|
||||
|
@ -1458,8 +1458,7 @@ func (s *DockerSuite) TestRunResolvconfUpdate(c *testing.T) {
|
|||
containerID1 := getIDByName(c, "first")
|
||||
|
||||
// replace resolv.conf with our temporary copy
|
||||
bytesResolvConf := []byte(tmpResolvConf)
|
||||
if err := ioutil.WriteFile("/etc/resolv.conf", bytesResolvConf, 0644); err != nil {
|
||||
if err := ioutil.WriteFile("/etc/resolv.conf", tmpResolvConf, 0644); err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -1468,7 +1467,7 @@ func (s *DockerSuite) TestRunResolvconfUpdate(c *testing.T) {
|
|||
|
||||
// check for update in container
|
||||
containerResolv := readContainerFile(c, containerID1, "resolv.conf")
|
||||
if !bytes.Equal(containerResolv, bytesResolvConf) {
|
||||
if !bytes.Equal(containerResolv, tmpResolvConf) {
|
||||
c.Fatalf("Restarted container does not have updated resolv.conf; expected %q, got %q", tmpResolvConf, string(containerResolv))
|
||||
}
|
||||
|
||||
|
@ -1500,13 +1499,13 @@ func (s *DockerSuite) TestRunResolvconfUpdate(c *testing.T) {
|
|||
runningContainerID := strings.TrimSpace(out)
|
||||
|
||||
// replace resolv.conf
|
||||
if err := ioutil.WriteFile("/etc/resolv.conf", bytesResolvConf, 0644); err != nil {
|
||||
if err := ioutil.WriteFile("/etc/resolv.conf", tmpResolvConf, 0644); err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
|
||||
// check for update in container
|
||||
containerResolv = readContainerFile(c, runningContainerID, "resolv.conf")
|
||||
if bytes.Equal(containerResolv, bytesResolvConf) {
|
||||
if bytes.Equal(containerResolv, tmpResolvConf) {
|
||||
c.Fatalf("Running container should not have updated resolv.conf; expected %q, got %q", string(resolvConfSystem), string(containerResolv))
|
||||
}
|
||||
|
||||
|
@ -1516,16 +1515,15 @@ func (s *DockerSuite) TestRunResolvconfUpdate(c *testing.T) {
|
|||
|
||||
// check for update in container
|
||||
containerResolv = readContainerFile(c, runningContainerID, "resolv.conf")
|
||||
if !bytes.Equal(containerResolv, bytesResolvConf) {
|
||||
c.Fatalf("Restarted container should have updated resolv.conf; expected %q, got %q", string(bytesResolvConf), string(containerResolv))
|
||||
if !bytes.Equal(containerResolv, tmpResolvConf) {
|
||||
c.Fatalf("Restarted container should have updated resolv.conf; expected %q, got %q", string(tmpResolvConf), string(containerResolv))
|
||||
}
|
||||
|
||||
//5. test that additions of a localhost resolver are cleaned from
|
||||
// host resolv.conf before updating container's resolv.conf copies
|
||||
|
||||
// replace resolv.conf with a localhost-only nameserver copy
|
||||
bytesResolvConf = []byte(tmpLocalhostResolvConf)
|
||||
if err = ioutil.WriteFile("/etc/resolv.conf", bytesResolvConf, 0644); err != nil {
|
||||
if err = ioutil.WriteFile("/etc/resolv.conf", tmpLocalhostResolvConf, 0644); err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -1553,8 +1551,7 @@ func (s *DockerSuite) TestRunResolvconfUpdate(c *testing.T) {
|
|||
containerID3 := getIDByName(c, "third")
|
||||
|
||||
// Create a modified resolv.conf.aside and override resolv.conf with it
|
||||
bytesResolvConf = []byte(tmpResolvConf)
|
||||
if err := ioutil.WriteFile("/etc/resolv.conf.aside", bytesResolvConf, 0644); err != nil {
|
||||
if err := ioutil.WriteFile("/etc/resolv.conf.aside", tmpResolvConf, 0644); err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -1568,7 +1565,7 @@ func (s *DockerSuite) TestRunResolvconfUpdate(c *testing.T) {
|
|||
|
||||
// check for update in container
|
||||
containerResolv = readContainerFile(c, containerID3, "resolv.conf")
|
||||
if !bytes.Equal(containerResolv, bytesResolvConf) {
|
||||
if !bytes.Equal(containerResolv, tmpResolvConf) {
|
||||
c.Fatalf("Stopped container does not have updated resolv.conf; expected\n%q\n got\n%q", tmpResolvConf, string(containerResolv))
|
||||
}
|
||||
|
||||
|
@ -2661,7 +2658,7 @@ func (s *DockerSuite) TestRunRestartMaxRetries(c *testing.T) {
|
|||
timeout = 120 * time.Second
|
||||
}
|
||||
|
||||
id := strings.TrimSpace(string(out))
|
||||
id := strings.TrimSpace(out)
|
||||
if err := waitInspect(id, "{{ .State.Restarting }} {{ .State.Running }}", "false false", timeout); err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
|
@ -2704,7 +2701,7 @@ func (s *DockerSuite) TestPermissionsPtsReadonlyRootfs(c *testing.T) {
|
|||
c.Fatal("Could not obtain mounts when checking /dev/pts mntpnt.")
|
||||
}
|
||||
expected := "type devpts (rw,"
|
||||
if !strings.Contains(string(out), expected) {
|
||||
if !strings.Contains(out, expected) {
|
||||
c.Fatalf("expected output to contain %s but contains %s", expected, out)
|
||||
}
|
||||
}
|
||||
|
@ -2739,7 +2736,7 @@ func (s *DockerSuite) TestRunContainerWithReadonlyEtcHostsAndLinkedContainer(c *
|
|||
dockerCmd(c, "run", "-d", "--name", "test-etc-hosts-ro-linked", "busybox", "top")
|
||||
|
||||
out, _ := dockerCmd(c, "run", "--read-only", "--link", "test-etc-hosts-ro-linked:testlinked", "busybox", "cat", "/etc/hosts")
|
||||
if !strings.Contains(string(out), "testlinked") {
|
||||
if !strings.Contains(out, "testlinked") {
|
||||
c.Fatal("Expected /etc/hosts to be updated even if --read-only enabled")
|
||||
}
|
||||
}
|
||||
|
@ -2749,7 +2746,7 @@ func (s *DockerSuite) TestRunContainerWithReadonlyRootfsWithDNSFlag(c *testing.T
|
|||
testRequires(c, DaemonIsLinux, UserNamespaceROMount)
|
||||
|
||||
out, _ := dockerCmd(c, "run", "--read-only", "--dns", "1.1.1.1", "busybox", "/bin/cat", "/etc/resolv.conf")
|
||||
if !strings.Contains(string(out), "1.1.1.1") {
|
||||
if !strings.Contains(out, "1.1.1.1") {
|
||||
c.Fatal("Expected /etc/resolv.conf to be updated even if --read-only enabled and --dns flag used")
|
||||
}
|
||||
}
|
||||
|
@ -2759,7 +2756,7 @@ func (s *DockerSuite) TestRunContainerWithReadonlyRootfsWithAddHostFlag(c *testi
|
|||
testRequires(c, DaemonIsLinux, UserNamespaceROMount)
|
||||
|
||||
out, _ := dockerCmd(c, "run", "--read-only", "--add-host", "testreadonly:127.0.0.1", "busybox", "/bin/cat", "/etc/hosts")
|
||||
if !strings.Contains(string(out), "testreadonly") {
|
||||
if !strings.Contains(out, "testreadonly") {
|
||||
c.Fatal("Expected /etc/hosts to be updated even if --read-only enabled and --add-host flag used")
|
||||
}
|
||||
}
|
||||
|
@ -3249,11 +3246,11 @@ func (s *DockerSuite) TestRunContainerWithCgroupParent(c *testing.T) {
|
|||
func testRunContainerWithCgroupParent(c *testing.T, cgroupParent, name string) {
|
||||
out, _, err := dockerCmdWithError("run", "--cgroup-parent", cgroupParent, "--name", name, "busybox", "cat", "/proc/self/cgroup")
|
||||
if err != nil {
|
||||
c.Fatalf("unexpected failure when running container with --cgroup-parent option - %s\n%v", string(out), err)
|
||||
c.Fatalf("unexpected failure when running container with --cgroup-parent option - %s\n%v", out, err)
|
||||
}
|
||||
cgroupPaths := ParseCgroupPaths(string(out))
|
||||
cgroupPaths := ParseCgroupPaths(out)
|
||||
if len(cgroupPaths) == 0 {
|
||||
c.Fatalf("unexpected output - %q", string(out))
|
||||
c.Fatalf("unexpected output - %q", out)
|
||||
}
|
||||
id := getIDByName(c, name)
|
||||
expectedCgroup := path.Join(cgroupParent, id)
|
||||
|
@ -3283,7 +3280,7 @@ func testRunInvalidCgroupParent(c *testing.T, cgroupParent, cleanCgroupParent, n
|
|||
out, _, err := dockerCmdWithError("run", "--cgroup-parent", cgroupParent, "--name", name, "busybox", "cat", "/proc/self/cgroup")
|
||||
if err != nil {
|
||||
// XXX: This may include a daemon crash.
|
||||
c.Fatalf("unexpected failure when running container with --cgroup-parent option - %s\n%v", string(out), err)
|
||||
c.Fatalf("unexpected failure when running container with --cgroup-parent option - %s\n%v", out, err)
|
||||
}
|
||||
|
||||
// We expect "/SHOULD_NOT_EXIST" to not exist. If not, we have a security issue.
|
||||
|
@ -3291,9 +3288,9 @@ func testRunInvalidCgroupParent(c *testing.T, cgroupParent, cleanCgroupParent, n
|
|||
c.Fatalf("SECURITY: --cgroup-parent with ../../ relative paths cause files to be created in the host (this is bad) !!")
|
||||
}
|
||||
|
||||
cgroupPaths := ParseCgroupPaths(string(out))
|
||||
cgroupPaths := ParseCgroupPaths(out)
|
||||
if len(cgroupPaths) == 0 {
|
||||
c.Fatalf("unexpected output - %q", string(out))
|
||||
c.Fatalf("unexpected output - %q", out)
|
||||
}
|
||||
id := getIDByName(c, name)
|
||||
expectedCgroup := path.Join(cleanCgroupParent, id)
|
||||
|
@ -3947,11 +3944,11 @@ func (s *DockerSuite) TestRunAttachFailedNoLeak(c *testing.T) {
|
|||
assert.Assert(c, err != nil, "Command should have failed but succeeded with: %s\nContainer 'test' [%+v]: %s\nContainer 'fail' [%+v]: %s", out, err1, out1, err2, out2)
|
||||
// check for windows error as well
|
||||
// TODO Windows Post TP5. Fix the error message string
|
||||
assert.Assert(c, strings.Contains(string(out), "port is already allocated") ||
|
||||
strings.Contains(string(out), "were not connected because a duplicate name exists") ||
|
||||
strings.Contains(string(out), "The specified port already exists") ||
|
||||
strings.Contains(string(out), "HNS failed with error : Failed to create endpoint") ||
|
||||
strings.Contains(string(out), "HNS failed with error : The object already exists"), fmt.Sprintf("Output: %s", out))
|
||||
assert.Assert(c, strings.Contains(out, "port is already allocated") ||
|
||||
strings.Contains(out, "were not connected because a duplicate name exists") ||
|
||||
strings.Contains(out, "The specified port already exists") ||
|
||||
strings.Contains(out, "HNS failed with error : Failed to create endpoint") ||
|
||||
strings.Contains(out, "HNS failed with error : The object already exists"), fmt.Sprintf("Output: %s", out))
|
||||
dockerCmd(c, "rm", "-f", "test")
|
||||
|
||||
// NGoroutines is not updated right away, so we need to wait before failing
|
||||
|
|
|
@ -65,7 +65,7 @@ func countLogLines(d *daemon.Daemon, name string) func(*testing.T) (interface{},
|
|||
return 0, "Empty stdout"
|
||||
}
|
||||
lines := strings.Split(strings.TrimSpace(result.Stdout()), "\n")
|
||||
return len(lines), fmt.Sprintf("output, %q", string(result.Stdout()))
|
||||
return len(lines), fmt.Sprintf("output, %q", result.Stdout())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -900,15 +900,15 @@ func (s *DockerSwarmSuite) TestSwarmServiceNetworkUpdate(c *testing.T) {
|
|||
|
||||
result := icmd.RunCmd(d.Command("network", "create", "-d", "overlay", "foo"))
|
||||
result.Assert(c, icmd.Success)
|
||||
fooNetwork := strings.TrimSpace(string(result.Combined()))
|
||||
fooNetwork := strings.TrimSpace(result.Combined())
|
||||
|
||||
result = icmd.RunCmd(d.Command("network", "create", "-d", "overlay", "bar"))
|
||||
result.Assert(c, icmd.Success)
|
||||
barNetwork := strings.TrimSpace(string(result.Combined()))
|
||||
barNetwork := strings.TrimSpace(result.Combined())
|
||||
|
||||
result = icmd.RunCmd(d.Command("network", "create", "-d", "overlay", "baz"))
|
||||
result.Assert(c, icmd.Success)
|
||||
bazNetwork := strings.TrimSpace(string(result.Combined()))
|
||||
bazNetwork := strings.TrimSpace(result.Combined())
|
||||
|
||||
// Create a service
|
||||
name := "top"
|
||||
|
|
|
@ -50,7 +50,7 @@ func (s *DockerSwarmSuite) TestSwarmVolumePlugin(c *testing.T) {
|
|||
}
|
||||
|
||||
assert.NilError(c, json.NewDecoder(strings.NewReader(out)).Decode(&mounts))
|
||||
assert.Equal(c, len(mounts), 1, string(out))
|
||||
assert.Equal(c, len(mounts), 1, out)
|
||||
assert.Equal(c, mounts[0].Name, "my-volume")
|
||||
assert.Equal(c, mounts[0].Driver, "customvolumedriver")
|
||||
}
|
||||
|
|
|
@ -271,7 +271,7 @@ func (s *DockerSuite) TestUpdateNotAffectMonitorRestartPolicy(c *testing.T) {
|
|||
testRequires(c, DaemonIsLinux, cpuShare)
|
||||
|
||||
out, _ := dockerCmd(c, "run", "-tid", "--restart=always", "busybox", "sh")
|
||||
id := strings.TrimSpace(string(out))
|
||||
id := strings.TrimSpace(out)
|
||||
dockerCmd(c, "update", "--cpu-shares", "512", id)
|
||||
|
||||
cpty, tty, err := pty.Open()
|
||||
|
|
|
@ -106,7 +106,7 @@ func (s *DockerSuite) TestVolumeLsFormatDefaultFormat(c *testing.T) {
|
|||
}
|
||||
|
||||
func assertVolumesInList(c *testing.T, out string, expected []string) {
|
||||
lines := strings.Split(strings.TrimSpace(string(out)), "\n")
|
||||
lines := strings.Split(strings.TrimSpace(out), "\n")
|
||||
for _, expect := range expected {
|
||||
found := false
|
||||
for _, v := range lines {
|
||||
|
|
|
@ -82,8 +82,8 @@ func UnixCli() bool {
|
|||
|
||||
func Network() bool {
|
||||
// Set a timeout on the GET at 15s
|
||||
var timeout = time.Duration(15 * time.Second)
|
||||
var url = "https://hub.docker.com"
|
||||
const timeout = 15 * time.Second
|
||||
const url = "https://hub.docker.com"
|
||||
|
||||
client := http.Client{
|
||||
Timeout: timeout,
|
||||
|
|
Loading…
Reference in a new issue