Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 7c40c0a9227089a7e3ee7c23c2bc0685ed133391)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -94,7 +94,7 @@ func (d *Daemon) CheckActiveContainerCount(c *testing.T) (interface{}, string) {
|
| 94 | 94 |
if len(strings.TrimSpace(out)) == 0 {
|
| 95 | 95 |
return 0, "" |
| 96 | 96 |
} |
| 97 |
- return len(strings.Split(strings.TrimSpace(out), "\n")), fmt.Sprintf("output: %q", string(out))
|
|
| 97 |
+ return len(strings.Split(strings.TrimSpace(out), "\n")), fmt.Sprintf("output: %q", out)
|
|
| 98 | 98 |
} |
| 99 | 99 |
|
| 100 | 100 |
// WaitRun waits for a container to be running for 10s |
| ... | ... |
@@ -27,7 +27,7 @@ func (s *DockerSuite) TestGetContainersAttachWebsocket(c *testing.T) {
|
| 27 | 27 |
testRequires(c, DaemonIsLinux) |
| 28 | 28 |
out, _ := dockerCmd(c, "run", "-dit", "busybox", "cat") |
| 29 | 29 |
|
| 30 |
- rwc, err := request.SockConn(time.Duration(10*time.Second), request.DaemonHost()) |
|
| 30 |
+ rwc, err := request.SockConn(10*time.Second, request.DaemonHost()) |
|
| 31 | 31 |
assert.NilError(c, err) |
| 32 | 32 |
|
| 33 | 33 |
cleanedContainerID := strings.TrimSpace(out) |
| ... | ... |
@@ -237,7 +237,7 @@ func sockRequestHijack(method, endpoint string, data io.Reader, ct string, daemo |
| 237 | 237 |
// Deprecated: Use New instead of NewRequestClient |
| 238 | 238 |
// Deprecated: use request.Do (or Get, Delete, Post) instead |
| 239 | 239 |
func newRequestClient(method, endpoint string, data io.Reader, ct, daemon string, modifiers ...func(*http.Request)) (*http.Request, *httputil.ClientConn, error) {
|
| 240 |
- c, err := request.SockConn(time.Duration(10*time.Second), daemon) |
|
| 240 |
+ c, err := request.SockConn(10*time.Second, daemon) |
|
| 241 | 241 |
if err != nil {
|
| 242 | 242 |
return nil, nil, fmt.Errorf("could not dial docker daemon: %v", err)
|
| 243 | 243 |
} |
| ... | ... |
@@ -394,7 +394,7 @@ func (s *DockerSuite) TestContainerAPIPause(c *testing.T) {
|
| 394 | 394 |
func (s *DockerSuite) TestContainerAPITop(c *testing.T) {
|
| 395 | 395 |
testRequires(c, DaemonIsLinux) |
| 396 | 396 |
out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "top") |
| 397 |
- id := strings.TrimSpace(string(out)) |
|
| 397 |
+ id := strings.TrimSpace(out) |
|
| 398 | 398 |
assert.NilError(c, waitRun(id)) |
| 399 | 399 |
|
| 400 | 400 |
cli, err := client.NewClientWithOpts(client.FromEnv) |
| ... | ... |
@@ -417,7 +417,7 @@ func (s *DockerSuite) TestContainerAPITop(c *testing.T) {
|
| 417 | 417 |
func (s *DockerSuite) TestContainerAPITopWindows(c *testing.T) {
|
| 418 | 418 |
testRequires(c, DaemonIsWindows) |
| 419 | 419 |
out := runSleepingContainer(c, "-d") |
| 420 |
- id := strings.TrimSpace(string(out)) |
|
| 420 |
+ id := strings.TrimSpace(out) |
|
| 421 | 421 |
assert.NilError(c, waitRun(id)) |
| 422 | 422 |
|
| 423 | 423 |
cli, err := client.NewClientWithOpts(client.FromEnv) |
| ... | ... |
@@ -614,7 +614,7 @@ func UtilCreateNetworkMode(c *testing.T, networkMode containertypes.NetworkMode) |
| 614 | 614 |
containerJSON, err := cli.ContainerInspect(context.Background(), container.ID) |
| 615 | 615 |
assert.NilError(c, err) |
| 616 | 616 |
|
| 617 |
- assert.Equal(c, containerJSON.HostConfig.NetworkMode, containertypes.NetworkMode(networkMode), "Mismatched NetworkMode") |
|
| 617 |
+ assert.Equal(c, containerJSON.HostConfig.NetworkMode, networkMode, "Mismatched NetworkMode") |
|
| 618 | 618 |
} |
| 619 | 619 |
|
| 620 | 620 |
func (s *DockerSuite) TestContainerAPICreateWithCpuSharesCpuset(c *testing.T) {
|
| ... | ... |
@@ -84,7 +84,7 @@ func (s *DockerSuite) TestAPIImagesSaveAndLoad(c *testing.T) {
|
| 84 | 84 |
assert.Equal(c, res.StatusCode, http.StatusOK) |
| 85 | 85 |
|
| 86 | 86 |
inspectOut := cli.InspectCmd(c, id, cli.Format(".Id")).Combined()
|
| 87 |
- assert.Equal(c, strings.TrimSpace(string(inspectOut)), id, "load did not work properly") |
|
| 87 |
+ assert.Equal(c, strings.TrimSpace(inspectOut), id, "load did not work properly") |
|
| 88 | 88 |
} |
| 89 | 89 |
|
| 90 | 90 |
func (s *DockerSuite) TestAPIImagesDelete(c *testing.T) {
|
| ... | ... |
@@ -595,7 +595,7 @@ func (s *DockerSwarmSuite) TestAPISwarmForceNewCluster(c *testing.T) {
|
| 595 | 595 |
|
| 596 | 596 |
func simpleTestService(s *swarm.Service) {
|
| 597 | 597 |
ureplicas := uint64(1) |
| 598 |
- restartDelay := time.Duration(100 * time.Millisecond) |
|
| 598 |
+ restartDelay := 100 * time.Millisecond |
|
| 599 | 599 |
|
| 600 | 600 |
s.Spec = swarm.ServiceSpec{
|
| 601 | 601 |
TaskTemplate: swarm.TaskSpec{
|
| ... | ... |
@@ -618,7 +618,7 @@ func simpleTestService(s *swarm.Service) {
|
| 618 | 618 |
|
| 619 | 619 |
func serviceForUpdate(s *swarm.Service) {
|
| 620 | 620 |
ureplicas := uint64(1) |
| 621 |
- restartDelay := time.Duration(100 * time.Millisecond) |
|
| 621 |
+ restartDelay := 100 * time.Millisecond |
|
| 622 | 622 |
|
| 623 | 623 |
s.Spec = swarm.ServiceSpec{
|
| 624 | 624 |
TaskTemplate: swarm.TaskSpec{
|
| ... | ... |
@@ -2082,7 +2082,7 @@ CMD ["cat", "/foo"]`), |
| 2082 | 2082 |
}).Assert(c, icmd.Success) |
| 2083 | 2083 |
|
| 2084 | 2084 |
res := inspectField(c, name, "Config.Cmd") |
| 2085 |
- assert.Equal(c, strings.TrimSpace(string(res)), `[cat /foo]`) |
|
| 2085 |
+ assert.Equal(c, strings.TrimSpace(res), `[cat /foo]`) |
|
| 2086 | 2086 |
} |
| 2087 | 2087 |
|
| 2088 | 2088 |
// FIXME(vdemeester) migrate to docker/cli tests (unit or e2e) |
| ... | ... |
@@ -40,7 +40,7 @@ func (s *DockerSuite) TestCreateArgs(c *testing.T) {
|
| 40 | 40 |
assert.Equal(c, len(containers), 1) |
| 41 | 41 |
|
| 42 | 42 |
cont := containers[0] |
| 43 |
- assert.Equal(c, string(cont.Path), "command", fmt.Sprintf("Unexpected container path. Expected command, received: %s", cont.Path))
|
|
| 43 |
+ assert.Equal(c, cont.Path, "command", fmt.Sprintf("Unexpected container path. Expected command, received: %s", cont.Path))
|
|
| 44 | 44 |
|
| 45 | 45 |
b := false |
| 46 | 46 |
expected := []string{"arg1", "arg2", "arg with space", "-c", "flags"}
|
| ... | ... |
@@ -333,7 +333,7 @@ func (s *DockerSuite) TestCreateWithInvalidLogOpts(c *testing.T) {
|
| 333 | 333 |
// #20972 |
| 334 | 334 |
func (s *DockerSuite) TestCreate64ByteHexID(c *testing.T) {
|
| 335 | 335 |
out := inspectField(c, "busybox", "Id") |
| 336 |
- imageID := strings.TrimPrefix(strings.TrimSpace(string(out)), "sha256:") |
|
| 336 |
+ imageID := strings.TrimPrefix(strings.TrimSpace(out), "sha256:") |
|
| 337 | 337 |
|
| 338 | 338 |
dockerCmd(c, "create", imageID) |
| 339 | 339 |
} |
| ... | ... |
@@ -1854,11 +1854,11 @@ func (s *DockerDaemonSuite) TestDaemonCgroupParent(c *testing.T) {
|
| 1854 | 1854 |
|
| 1855 | 1855 |
out, err := s.d.Cmd("run", "--name", name, "busybox", "cat", "/proc/self/cgroup")
|
| 1856 | 1856 |
assert.NilError(c, err) |
| 1857 |
- cgroupPaths := ParseCgroupPaths(string(out)) |
|
| 1858 |
- assert.Assert(c, len(cgroupPaths) != 0, "unexpected output - %q", string(out)) |
|
| 1857 |
+ cgroupPaths := ParseCgroupPaths(out) |
|
| 1858 |
+ assert.Assert(c, len(cgroupPaths) != 0, "unexpected output - %q", out) |
|
| 1859 | 1859 |
out, err = s.d.Cmd("inspect", "-f", "{{.Id}}", name)
|
| 1860 | 1860 |
assert.NilError(c, err) |
| 1861 |
- id := strings.TrimSpace(string(out)) |
|
| 1861 |
+ id := strings.TrimSpace(out) |
|
| 1862 | 1862 |
expectedCgroup := path.Join(cgroupParent, id) |
| 1863 | 1863 |
found := false |
| 1864 | 1864 |
for _, path := range cgroupPaths {
|
| ... | ... |
@@ -329,7 +329,7 @@ func (s *DockerSuite) TestImagesFormat(c *testing.T) {
|
| 329 | 329 |
dockerCmd(c, "tag", "busybox", tag+":v2") |
| 330 | 330 |
|
| 331 | 331 |
out, _ := dockerCmd(c, "images", "--format", "{{.Repository}}", tag)
|
| 332 |
- lines := strings.Split(strings.TrimSpace(string(out)), "\n") |
|
| 332 |
+ lines := strings.Split(strings.TrimSpace(out), "\n") |
|
| 333 | 333 |
|
| 334 | 334 |
expected := []string{"myimage", "myimage"}
|
| 335 | 335 |
var names []string |
| ... | ... |
@@ -161,7 +161,7 @@ func (s *DockerSuite) TestLinksUpdateOnRestart(c *testing.T) {
|
| 161 | 161 |
testRequires(c, testEnv.IsLocalDaemon) |
| 162 | 162 |
dockerCmd(c, "run", "-d", "--name", "one", "busybox", "top") |
| 163 | 163 |
out, _ := dockerCmd(c, "run", "-d", "--name", "two", "--link", "one:onetwo", "--link", "one:one", "busybox", "top") |
| 164 |
- id := strings.TrimSpace(string(out)) |
|
| 164 |
+ id := strings.TrimSpace(out) |
|
| 165 | 165 |
|
| 166 | 166 |
realIP := inspectField(c, "one", "NetworkSettings.Networks.bridge.IPAddress") |
| 167 | 167 |
content := readContainerFileWithExec(c, id, "/etc/hosts") |
| ... | ... |
@@ -812,14 +812,14 @@ func (s *DockerDaemonSuite) TestDockerNetworkNoDiscoveryDefaultBridgeNetwork(c * |
| 812 | 812 |
// verify first container's etc/hosts file has not changed after spawning the second named container |
| 813 | 813 |
hostsPost, err := s.d.Cmd("exec", cid1, "cat", hostsFile)
|
| 814 | 814 |
assert.NilError(c, err) |
| 815 |
- assert.Equal(c, string(hosts), string(hostsPost), fmt.Sprintf("Unexpected %s change on second container creation", hostsFile))
|
|
| 815 |
+ assert.Equal(c, hosts, hostsPost, fmt.Sprintf("Unexpected %s change on second container creation", hostsFile))
|
|
| 816 | 816 |
// stop container 2 and verify first container's etc/hosts has not changed |
| 817 | 817 |
_, err = s.d.Cmd("stop", cid2)
|
| 818 | 818 |
assert.NilError(c, err) |
| 819 | 819 |
|
| 820 | 820 |
hostsPost, err = s.d.Cmd("exec", cid1, "cat", hostsFile)
|
| 821 | 821 |
assert.NilError(c, err) |
| 822 |
- assert.Equal(c, string(hosts), string(hostsPost), fmt.Sprintf("Unexpected %s change on second container creation", hostsFile))
|
|
| 822 |
+ assert.Equal(c, hosts, hostsPost, fmt.Sprintf("Unexpected %s change on second container creation", hostsFile))
|
|
| 823 | 823 |
// but discovery is on when connecting to non default bridge network |
| 824 | 824 |
network := "anotherbridge" |
| 825 | 825 |
out, err = s.d.Cmd("network", "create", network)
|
| ... | ... |
@@ -834,7 +834,7 @@ func (s *DockerDaemonSuite) TestDockerNetworkNoDiscoveryDefaultBridgeNetwork(c * |
| 834 | 834 |
|
| 835 | 835 |
hostsPost, err = s.d.Cmd("exec", cid1, "cat", hostsFile)
|
| 836 | 836 |
assert.NilError(c, err) |
| 837 |
- assert.Equal(c, string(hosts), string(hostsPost), fmt.Sprintf("Unexpected %s change on second network connection", hostsFile))
|
|
| 837 |
+ assert.Equal(c, hosts, hostsPost, fmt.Sprintf("Unexpected %s change on second network connection", hostsFile))
|
|
| 838 | 838 |
} |
| 839 | 839 |
|
| 840 | 840 |
func (s *DockerNetworkSuite) TestDockerNetworkAnonymousEndpoint(c *testing.T) {
|
| ... | ... |
@@ -1683,7 +1683,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartRestoreBridgeNetwork(t *testing.T) |
| 1683 | 1683 |
// Cleanup because these containers will not be shut down by daemon |
| 1684 | 1684 |
out, err = s.d.Cmd("stop", newCon)
|
| 1685 | 1685 |
if err != nil {
|
| 1686 |
- t.Fatalf("err: %v %v", err, string(out))
|
|
| 1686 |
+ t.Fatalf("err: %v %v", err, out)
|
|
| 1687 | 1687 |
} |
| 1688 | 1688 |
_, err = s.d.Cmd("stop", strings.TrimSpace(id))
|
| 1689 | 1689 |
if err != nil {
|
| ... | ... |
@@ -478,22 +478,22 @@ func (s *DockerSuite) TestPsRightTagName(c *testing.T) {
|
| 478 | 478 |
|
| 479 | 479 |
var id1 string |
| 480 | 480 |
out := runSleepingContainer(c) |
| 481 |
- id1 = strings.TrimSpace(string(out)) |
|
| 481 |
+ id1 = strings.TrimSpace(out) |
|
| 482 | 482 |
|
| 483 | 483 |
var id2 string |
| 484 | 484 |
out = runSleepingContainerInImage(c, tag) |
| 485 |
- id2 = strings.TrimSpace(string(out)) |
|
| 485 |
+ id2 = strings.TrimSpace(out) |
|
| 486 | 486 |
|
| 487 | 487 |
var imageID string |
| 488 | 488 |
out = inspectField(c, "busybox", "Id") |
| 489 |
- imageID = strings.TrimSpace(string(out)) |
|
| 489 |
+ imageID = strings.TrimSpace(out) |
|
| 490 | 490 |
|
| 491 | 491 |
var id3 string |
| 492 | 492 |
out = runSleepingContainerInImage(c, imageID) |
| 493 |
- id3 = strings.TrimSpace(string(out)) |
|
| 493 |
+ id3 = strings.TrimSpace(out) |
|
| 494 | 494 |
|
| 495 | 495 |
out, _ = dockerCmd(c, "ps", "--no-trunc") |
| 496 |
- lines := strings.Split(strings.TrimSpace(string(out)), "\n") |
|
| 496 |
+ lines := strings.Split(strings.TrimSpace(out), "\n") |
|
| 497 | 497 |
lines = RemoveLinesForExistingElements(lines, existingContainers) |
| 498 | 498 |
// skip header |
| 499 | 499 |
lines = lines[1:] |
| ... | ... |
@@ -562,7 +562,7 @@ func (s *DockerSuite) TestPsImageIDAfterUpdate(c *testing.T) {
|
| 562 | 562 |
result = icmd.RunCommand(dockerBinary, "ps", "--no-trunc") |
| 563 | 563 |
result.Assert(c, icmd.Success) |
| 564 | 564 |
|
| 565 |
- lines := strings.Split(strings.TrimSpace(string(result.Combined())), "\n") |
|
| 565 |
+ lines := strings.Split(strings.TrimSpace(result.Combined()), "\n") |
|
| 566 | 566 |
lines = RemoveLinesForExistingElements(lines, existingContainers) |
| 567 | 567 |
// skip header |
| 568 | 568 |
lines = lines[1:] |
| ... | ... |
@@ -579,7 +579,7 @@ func (s *DockerSuite) TestPsImageIDAfterUpdate(c *testing.T) {
|
| 579 | 579 |
result = icmd.RunCommand(dockerBinary, "ps", "--no-trunc") |
| 580 | 580 |
result.Assert(c, icmd.Success) |
| 581 | 581 |
|
| 582 |
- lines = strings.Split(strings.TrimSpace(string(result.Combined())), "\n") |
|
| 582 |
+ lines = strings.Split(strings.TrimSpace(result.Combined()), "\n") |
|
| 583 | 583 |
lines = RemoveLinesForExistingElements(lines, existingContainers) |
| 584 | 584 |
// skip header |
| 585 | 585 |
lines = lines[1:] |
| ... | ... |
@@ -597,7 +597,7 @@ func (s *DockerSuite) TestPsNotShowPortsOfStoppedContainer(c *testing.T) {
|
| 597 | 597 |
dockerCmd(c, "run", "--name=foo", "-d", "-p", "5000:5000", "busybox", "top") |
| 598 | 598 |
assert.Assert(c, waitRun("foo") == nil)
|
| 599 | 599 |
out, _ := dockerCmd(c, "ps") |
| 600 |
- lines := strings.Split(strings.TrimSpace(string(out)), "\n") |
|
| 600 |
+ lines := strings.Split(strings.TrimSpace(out), "\n") |
|
| 601 | 601 |
expected := "0.0.0.0:5000->5000/tcp" |
| 602 | 602 |
fields := strings.Fields(lines[1]) |
| 603 | 603 |
assert.Equal(c, fields[len(fields)-2], expected, fmt.Sprintf("Expected: %v, got: %v", expected, fields[len(fields)-2]))
|
| ... | ... |
@@ -605,7 +605,7 @@ func (s *DockerSuite) TestPsNotShowPortsOfStoppedContainer(c *testing.T) {
|
| 605 | 605 |
dockerCmd(c, "kill", "foo") |
| 606 | 606 |
dockerCmd(c, "wait", "foo") |
| 607 | 607 |
out, _ = dockerCmd(c, "ps", "-l") |
| 608 |
- lines = strings.Split(strings.TrimSpace(string(out)), "\n") |
|
| 608 |
+ lines = strings.Split(strings.TrimSpace(out), "\n") |
|
| 609 | 609 |
fields = strings.Fields(lines[1]) |
| 610 | 610 |
assert.Assert(c, fields[len(fields)-2] != expected, "Should not got %v", expected) |
| 611 | 611 |
} |
| ... | ... |
@@ -638,7 +638,7 @@ func (s *DockerSuite) TestPsShowMounts(c *testing.T) {
|
| 638 | 638 |
|
| 639 | 639 |
out, _ := dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}")
|
| 640 | 640 |
|
| 641 |
- lines := strings.Split(strings.TrimSpace(string(out)), "\n") |
|
| 641 |
+ lines := strings.Split(strings.TrimSpace(out), "\n") |
|
| 642 | 642 |
lines = RemoveLinesForExistingElements(lines, existingContainers) |
| 643 | 643 |
assert.Equal(c, len(lines), 3) |
| 644 | 644 |
|
| ... | ... |
@@ -658,7 +658,7 @@ func (s *DockerSuite) TestPsShowMounts(c *testing.T) {
|
| 658 | 658 |
// filter by volume name |
| 659 | 659 |
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume=ps-volume-test")
|
| 660 | 660 |
|
| 661 |
- lines = strings.Split(strings.TrimSpace(string(out)), "\n") |
|
| 661 |
+ lines = strings.Split(strings.TrimSpace(out), "\n") |
|
| 662 | 662 |
lines = RemoveLinesForExistingElements(lines, existingContainers) |
| 663 | 663 |
assert.Equal(c, len(lines), 1) |
| 664 | 664 |
|
| ... | ... |
@@ -667,12 +667,12 @@ func (s *DockerSuite) TestPsShowMounts(c *testing.T) {
|
| 667 | 667 |
|
| 668 | 668 |
// empty results filtering by unknown volume |
| 669 | 669 |
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume=this-volume-should-not-exist")
|
| 670 |
- assert.Equal(c, len(strings.TrimSpace(string(out))), 0) |
|
| 670 |
+ assert.Equal(c, len(strings.TrimSpace(out)), 0) |
|
| 671 | 671 |
|
| 672 | 672 |
// filter by mount destination |
| 673 | 673 |
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume="+mp)
|
| 674 | 674 |
|
| 675 |
- lines = strings.Split(strings.TrimSpace(string(out)), "\n") |
|
| 675 |
+ lines = strings.Split(strings.TrimSpace(out), "\n") |
|
| 676 | 676 |
lines = RemoveLinesForExistingElements(lines, existingContainers) |
| 677 | 677 |
assert.Equal(c, len(lines), 2) |
| 678 | 678 |
|
| ... | ... |
@@ -684,7 +684,7 @@ func (s *DockerSuite) TestPsShowMounts(c *testing.T) {
|
| 684 | 684 |
// filter by bind mount source |
| 685 | 685 |
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume="+bindMountSource)
|
| 686 | 686 |
|
| 687 |
- lines = strings.Split(strings.TrimSpace(string(out)), "\n") |
|
| 687 |
+ lines = strings.Split(strings.TrimSpace(out), "\n") |
|
| 688 | 688 |
lines = RemoveLinesForExistingElements(lines, existingContainers) |
| 689 | 689 |
assert.Equal(c, len(lines), 1) |
| 690 | 690 |
|
| ... | ... |
@@ -696,7 +696,7 @@ func (s *DockerSuite) TestPsShowMounts(c *testing.T) {
|
| 696 | 696 |
// filter by bind mount destination |
| 697 | 697 |
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume="+bindMountDestination)
|
| 698 | 698 |
|
| 699 |
- lines = strings.Split(strings.TrimSpace(string(out)), "\n") |
|
| 699 |
+ lines = strings.Split(strings.TrimSpace(out), "\n") |
|
| 700 | 700 |
lines = RemoveLinesForExistingElements(lines, existingContainers) |
| 701 | 701 |
assert.Equal(c, len(lines), 1) |
| 702 | 702 |
|
| ... | ... |
@@ -707,7 +707,7 @@ func (s *DockerSuite) TestPsShowMounts(c *testing.T) {
|
| 707 | 707 |
|
| 708 | 708 |
// empty results filtering by unknown mount point |
| 709 | 709 |
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume="+prefix+slash+"this-path-was-never-mounted")
|
| 710 |
- assert.Equal(c, len(strings.TrimSpace(string(out))), 0) |
|
| 710 |
+ assert.Equal(c, len(strings.TrimSpace(out)), 0) |
|
| 711 | 711 |
} |
| 712 | 712 |
|
| 713 | 713 |
func (s *DockerSuite) TestPsListContainersFilterNetwork(c *testing.T) {
|
| ... | ... |
@@ -723,7 +723,7 @@ func (s *DockerSuite) TestPsListContainersFilterNetwork(c *testing.T) {
|
| 723 | 723 |
|
| 724 | 724 |
// Filter docker ps on non existing network |
| 725 | 725 |
out, _ := dockerCmd(c, "ps", "--filter", "network=doesnotexist") |
| 726 |
- containerOut := strings.TrimSpace(string(out)) |
|
| 726 |
+ containerOut := strings.TrimSpace(out) |
|
| 727 | 727 |
lines := strings.Split(containerOut, "\n") |
| 728 | 728 |
|
| 729 | 729 |
// skip header |
| ... | ... |
@@ -734,7 +734,7 @@ func (s *DockerSuite) TestPsListContainersFilterNetwork(c *testing.T) {
|
| 734 | 734 |
|
| 735 | 735 |
// Filter docker ps on network bridge |
| 736 | 736 |
out, _ = dockerCmd(c, "ps", "--filter", "network=bridge") |
| 737 |
- containerOut = strings.TrimSpace(string(out)) |
|
| 737 |
+ containerOut = strings.TrimSpace(out) |
|
| 738 | 738 |
|
| 739 | 739 |
lines = strings.Split(containerOut, "\n") |
| 740 | 740 |
|
| ... | ... |
@@ -748,7 +748,7 @@ func (s *DockerSuite) TestPsListContainersFilterNetwork(c *testing.T) {
|
| 748 | 748 |
assert.Assert(c, strings.Contains(containerOut, "onbridgenetwork"), "Missing the container on network\n") |
| 749 | 749 |
// Filter docker ps on networks bridge and none |
| 750 | 750 |
out, _ = dockerCmd(c, "ps", "--filter", "network=bridge", "--filter", "network=none") |
| 751 |
- containerOut = strings.TrimSpace(string(out)) |
|
| 751 |
+ containerOut = strings.TrimSpace(out) |
|
| 752 | 752 |
|
| 753 | 753 |
lines = strings.Split(containerOut, "\n") |
| 754 | 754 |
|
| ... | ... |
@@ -765,15 +765,15 @@ func (s *DockerSuite) TestPsListContainersFilterNetwork(c *testing.T) {
|
| 765 | 765 |
|
| 766 | 766 |
// Filter by network ID |
| 767 | 767 |
out, _ = dockerCmd(c, "ps", "--filter", "network="+nwID) |
| 768 |
- containerOut = strings.TrimSpace(string(out)) |
|
| 768 |
+ containerOut = strings.TrimSpace(out) |
|
| 769 | 769 |
|
| 770 | 770 |
assert.Assert(c, is.Contains(containerOut, "onbridgenetwork")) |
| 771 | 771 |
|
| 772 | 772 |
// Filter by partial network ID |
| 773 |
- partialnwID := string(nwID[0:4]) |
|
| 773 |
+ partialnwID := nwID[0:4] |
|
| 774 | 774 |
|
| 775 | 775 |
out, _ = dockerCmd(c, "ps", "--filter", "network="+partialnwID) |
| 776 |
- containerOut = strings.TrimSpace(string(out)) |
|
| 776 |
+ containerOut = strings.TrimSpace(out) |
|
| 777 | 777 |
|
| 778 | 778 |
lines = strings.Split(containerOut, "\n") |
| 779 | 779 |
|
| ... | ... |
@@ -849,7 +849,7 @@ func (s *DockerSuite) TestPsNotShowLinknamesOfDeletedContainer(c *testing.T) {
|
| 849 | 849 |
dockerCmd(c, "create", "--name=bbb", "--link=aaa", "busybox", "top") |
| 850 | 850 |
|
| 851 | 851 |
out, _ := dockerCmd(c, "ps", "--no-trunc", "-a", "--format", "{{.Names}}")
|
| 852 |
- lines := strings.Split(strings.TrimSpace(string(out)), "\n") |
|
| 852 |
+ lines := strings.Split(strings.TrimSpace(out), "\n") |
|
| 853 | 853 |
lines = RemoveLinesForExistingElements(lines, existingContainers) |
| 854 | 854 |
expected := []string{"bbb", "aaa,bbb/aaa"}
|
| 855 | 855 |
var names []string |
| ... | ... |
@@ -333,7 +333,7 @@ func (s *DockerRegistrySuite) TestPullManifestList(c *testing.T) {
|
| 333 | 333 |
err = os.MkdirAll(blobDir, 0755) |
| 334 | 334 |
assert.NilError(c, err, "error creating blob dir") |
| 335 | 335 |
blobPath := filepath.Join(blobDir, "data") |
| 336 |
- err = ioutil.WriteFile(blobPath, []byte(manifestListJSON), 0644) |
|
| 336 |
+ err = ioutil.WriteFile(blobPath, manifestListJSON, 0644) |
|
| 337 | 337 |
assert.NilError(c, err, "error writing manifest list") |
| 338 | 338 |
|
| 339 | 339 |
// Add to revision store |
| ... | ... |
@@ -18,13 +18,13 @@ func unescapeBackslashSemicolonParens(s string) string {
|
| 18 | 18 |
ret := re.ReplaceAll([]byte(s), []byte(";"))
|
| 19 | 19 |
|
| 20 | 20 |
re = regexp.MustCompile(`\\\(`) |
| 21 |
- ret = re.ReplaceAll([]byte(ret), []byte("("))
|
|
| 21 |
+ ret = re.ReplaceAll(ret, []byte("("))
|
|
| 22 | 22 |
|
| 23 | 23 |
re = regexp.MustCompile(`\\\)`) |
| 24 |
- ret = re.ReplaceAll([]byte(ret), []byte(")"))
|
|
| 24 |
+ ret = re.ReplaceAll(ret, []byte(")"))
|
|
| 25 | 25 |
|
| 26 | 26 |
re = regexp.MustCompile(`\\\\`) |
| 27 |
- ret = re.ReplaceAll([]byte(ret), []byte(`\`)) |
|
| 27 |
+ ret = re.ReplaceAll(ret, []byte(`\`)) |
|
| 28 | 28 |
|
| 29 | 29 |
return string(ret) |
| 30 | 30 |
} |
| ... | ... |
@@ -98,7 +98,7 @@ func (s *DockerSuite) TestRestartDisconnectedContainer(c *testing.T) {
|
| 98 | 98 |
func (s *DockerSuite) TestRestartPolicyNO(c *testing.T) {
|
| 99 | 99 |
out, _ := dockerCmd(c, "create", "--restart=no", "busybox") |
| 100 | 100 |
|
| 101 |
- id := strings.TrimSpace(string(out)) |
|
| 101 |
+ id := strings.TrimSpace(out) |
|
| 102 | 102 |
name := inspectField(c, id, "HostConfig.RestartPolicy.Name") |
| 103 | 103 |
assert.Equal(c, name, "no") |
| 104 | 104 |
} |
| ... | ... |
@@ -106,7 +106,7 @@ func (s *DockerSuite) TestRestartPolicyNO(c *testing.T) {
|
| 106 | 106 |
func (s *DockerSuite) TestRestartPolicyAlways(c *testing.T) {
|
| 107 | 107 |
out, _ := dockerCmd(c, "create", "--restart=always", "busybox") |
| 108 | 108 |
|
| 109 |
- id := strings.TrimSpace(string(out)) |
|
| 109 |
+ id := strings.TrimSpace(out) |
|
| 110 | 110 |
name := inspectField(c, id, "HostConfig.RestartPolicy.Name") |
| 111 | 111 |
assert.Equal(c, name, "always") |
| 112 | 112 |
|
| ... | ... |
@@ -123,7 +123,7 @@ func (s *DockerSuite) TestRestartPolicyOnFailure(c *testing.T) {
|
| 123 | 123 |
|
| 124 | 124 |
out, _ = dockerCmd(c, "create", "--restart=on-failure:1", "busybox") |
| 125 | 125 |
|
| 126 |
- id := strings.TrimSpace(string(out)) |
|
| 126 |
+ id := strings.TrimSpace(out) |
|
| 127 | 127 |
name := inspectField(c, id, "HostConfig.RestartPolicy.Name") |
| 128 | 128 |
maxRetry := inspectField(c, id, "HostConfig.RestartPolicy.MaximumRetryCount") |
| 129 | 129 |
|
| ... | ... |
@@ -132,7 +132,7 @@ func (s *DockerSuite) TestRestartPolicyOnFailure(c *testing.T) {
|
| 132 | 132 |
|
| 133 | 133 |
out, _ = dockerCmd(c, "create", "--restart=on-failure:0", "busybox") |
| 134 | 134 |
|
| 135 |
- id = strings.TrimSpace(string(out)) |
|
| 135 |
+ id = strings.TrimSpace(out) |
|
| 136 | 136 |
name = inspectField(c, id, "HostConfig.RestartPolicy.Name") |
| 137 | 137 |
maxRetry = inspectField(c, id, "HostConfig.RestartPolicy.MaximumRetryCount") |
| 138 | 138 |
|
| ... | ... |
@@ -141,7 +141,7 @@ func (s *DockerSuite) TestRestartPolicyOnFailure(c *testing.T) {
|
| 141 | 141 |
|
| 142 | 142 |
out, _ = dockerCmd(c, "create", "--restart=on-failure", "busybox") |
| 143 | 143 |
|
| 144 |
- id = strings.TrimSpace(string(out)) |
|
| 144 |
+ id = strings.TrimSpace(out) |
|
| 145 | 145 |
name = inspectField(c, id, "HostConfig.RestartPolicy.Name") |
| 146 | 146 |
maxRetry = inspectField(c, id, "HostConfig.RestartPolicy.MaximumRetryCount") |
| 147 | 147 |
|
| ... | ... |
@@ -154,7 +154,7 @@ func (s *DockerSuite) TestRestartPolicyOnFailure(c *testing.T) {
|
| 154 | 154 |
func (s *DockerSuite) TestRestartContainerwithGoodContainer(c *testing.T) {
|
| 155 | 155 |
out, _ := dockerCmd(c, "run", "-d", "--restart=on-failure:3", "busybox", "true") |
| 156 | 156 |
|
| 157 |
- id := strings.TrimSpace(string(out)) |
|
| 157 |
+ id := strings.TrimSpace(out) |
|
| 158 | 158 |
err := waitInspect(id, "{{ .State.Restarting }} {{ .State.Running }}", "false false", 30*time.Second)
|
| 159 | 159 |
assert.NilError(c, err) |
| 160 | 160 |
|
| ... | ... |
@@ -281,8 +281,8 @@ func (s *DockerSuite) TestRestartContainerwithRestartPolicy(c *testing.T) {
|
| 281 | 281 |
out1, _ := dockerCmd(c, "run", "-d", "--restart=on-failure:3", "busybox", "false") |
| 282 | 282 |
out2, _ := dockerCmd(c, "run", "-d", "--restart=always", "busybox", "false") |
| 283 | 283 |
|
| 284 |
- id1 := strings.TrimSpace(string(out1)) |
|
| 285 |
- id2 := strings.TrimSpace(string(out2)) |
|
| 284 |
+ id1 := strings.TrimSpace(out1) |
|
| 285 |
+ id2 := strings.TrimSpace(out2) |
|
| 286 | 286 |
waitTimeout := 15 * time.Second |
| 287 | 287 |
if testEnv.OSType == "windows" {
|
| 288 | 288 |
waitTimeout = 150 * time.Second |
| ... | ... |
@@ -311,7 +311,7 @@ func (s *DockerSuite) TestRestartContainerwithRestartPolicy(c *testing.T) {
|
| 311 | 311 |
func (s *DockerSuite) TestRestartAutoRemoveContainer(c *testing.T) {
|
| 312 | 312 |
out := runSleepingContainer(c, "--rm") |
| 313 | 313 |
|
| 314 |
- id := strings.TrimSpace(string(out)) |
|
| 314 |
+ id := strings.TrimSpace(out) |
|
| 315 | 315 |
dockerCmd(c, "restart", id) |
| 316 | 316 |
err := waitInspect(id, "{{ .State.Restarting }} {{ .State.Running }}", "false true", 15*time.Second)
|
| 317 | 317 |
assert.NilError(c, err) |
| ... | ... |
@@ -1332,8 +1332,8 @@ func (s *DockerSuite) TestRunDNSOptionsBasedOnHostResolvConf(c *testing.T) {
|
| 1332 | 1332 |
var out string |
| 1333 | 1333 |
out, _ = dockerCmd(c, "run", "--dns=127.0.0.1", "busybox", "cat", "/etc/resolv.conf") |
| 1334 | 1334 |
|
| 1335 |
- if actualNameservers := resolvconf.GetNameservers([]byte(out), types.IP); string(actualNameservers[0]) != "127.0.0.1" {
|
|
| 1336 |
- c.Fatalf("expected '127.0.0.1', but says: %q", string(actualNameservers[0]))
|
|
| 1335 |
+ if actualNameservers := resolvconf.GetNameservers([]byte(out), types.IP); actualNameservers[0] != "127.0.0.1" {
|
|
| 1336 |
+ c.Fatalf("expected '127.0.0.1', but says: %q", actualNameservers[0])
|
|
| 1337 | 1337 |
} |
| 1338 | 1338 |
|
| 1339 | 1339 |
actualSearch := resolvconf.GetSearchDomains([]byte(out)) |
| ... | ... |
@@ -1358,8 +1358,8 @@ func (s *DockerSuite) TestRunDNSOptionsBasedOnHostResolvConf(c *testing.T) {
|
| 1358 | 1358 |
} |
| 1359 | 1359 |
} |
| 1360 | 1360 |
|
| 1361 |
- if actualSearch = resolvconf.GetSearchDomains([]byte(out)); string(actualSearch[0]) != "mydomain" {
|
|
| 1362 |
- c.Fatalf("expected 'mydomain', but says: %q", string(actualSearch[0]))
|
|
| 1361 |
+ if actualSearch = resolvconf.GetSearchDomains([]byte(out)); actualSearch[0] != "mydomain" {
|
|
| 1362 |
+ c.Fatalf("expected 'mydomain', but says: %q", actualSearch[0])
|
|
| 1363 | 1363 |
} |
| 1364 | 1364 |
|
| 1365 | 1365 |
// test with file |
| ... | ... |
@@ -1382,7 +1382,7 @@ func (s *DockerSuite) TestRunDNSOptionsBasedOnHostResolvConf(c *testing.T) {
|
| 1382 | 1382 |
hostSearch = resolvconf.GetSearchDomains(resolvConf) |
| 1383 | 1383 |
|
| 1384 | 1384 |
out, _ = dockerCmd(c, "run", "busybox", "cat", "/etc/resolv.conf") |
| 1385 |
- if actualNameservers = resolvconf.GetNameservers([]byte(out), types.IP); string(actualNameservers[0]) != "12.34.56.78" || len(actualNameservers) != 1 {
|
|
| 1385 |
+ if actualNameservers = resolvconf.GetNameservers([]byte(out), types.IP); actualNameservers[0] != "12.34.56.78" || len(actualNameservers) != 1 {
|
|
| 1386 | 1386 |
c.Fatalf("expected '12.34.56.78', but has: %v", actualNameservers)
|
| 1387 | 1387 |
} |
| 1388 | 1388 |
|
| ... | ... |
@@ -1458,8 +1458,7 @@ func (s *DockerSuite) TestRunResolvconfUpdate(c *testing.T) {
|
| 1458 | 1458 |
containerID1 := getIDByName(c, "first") |
| 1459 | 1459 |
|
| 1460 | 1460 |
// replace resolv.conf with our temporary copy |
| 1461 |
- bytesResolvConf := []byte(tmpResolvConf) |
|
| 1462 |
- if err := ioutil.WriteFile("/etc/resolv.conf", bytesResolvConf, 0644); err != nil {
|
|
| 1461 |
+ if err := ioutil.WriteFile("/etc/resolv.conf", tmpResolvConf, 0644); err != nil {
|
|
| 1463 | 1462 |
c.Fatal(err) |
| 1464 | 1463 |
} |
| 1465 | 1464 |
|
| ... | ... |
@@ -1468,7 +1467,7 @@ func (s *DockerSuite) TestRunResolvconfUpdate(c *testing.T) {
|
| 1468 | 1468 |
|
| 1469 | 1469 |
// check for update in container |
| 1470 | 1470 |
containerResolv := readContainerFile(c, containerID1, "resolv.conf") |
| 1471 |
- if !bytes.Equal(containerResolv, bytesResolvConf) {
|
|
| 1471 |
+ if !bytes.Equal(containerResolv, tmpResolvConf) {
|
|
| 1472 | 1472 |
c.Fatalf("Restarted container does not have updated resolv.conf; expected %q, got %q", tmpResolvConf, string(containerResolv))
|
| 1473 | 1473 |
} |
| 1474 | 1474 |
|
| ... | ... |
@@ -1500,13 +1499,13 @@ func (s *DockerSuite) TestRunResolvconfUpdate(c *testing.T) {
|
| 1500 | 1500 |
runningContainerID := strings.TrimSpace(out) |
| 1501 | 1501 |
|
| 1502 | 1502 |
// replace resolv.conf |
| 1503 |
- if err := ioutil.WriteFile("/etc/resolv.conf", bytesResolvConf, 0644); err != nil {
|
|
| 1503 |
+ if err := ioutil.WriteFile("/etc/resolv.conf", tmpResolvConf, 0644); err != nil {
|
|
| 1504 | 1504 |
c.Fatal(err) |
| 1505 | 1505 |
} |
| 1506 | 1506 |
|
| 1507 | 1507 |
// check for update in container |
| 1508 | 1508 |
containerResolv = readContainerFile(c, runningContainerID, "resolv.conf") |
| 1509 |
- if bytes.Equal(containerResolv, bytesResolvConf) {
|
|
| 1509 |
+ if bytes.Equal(containerResolv, tmpResolvConf) {
|
|
| 1510 | 1510 |
c.Fatalf("Running container should not have updated resolv.conf; expected %q, got %q", string(resolvConfSystem), string(containerResolv))
|
| 1511 | 1511 |
} |
| 1512 | 1512 |
|
| ... | ... |
@@ -1516,16 +1515,15 @@ func (s *DockerSuite) TestRunResolvconfUpdate(c *testing.T) {
|
| 1516 | 1516 |
|
| 1517 | 1517 |
// check for update in container |
| 1518 | 1518 |
containerResolv = readContainerFile(c, runningContainerID, "resolv.conf") |
| 1519 |
- if !bytes.Equal(containerResolv, bytesResolvConf) {
|
|
| 1520 |
- c.Fatalf("Restarted container should have updated resolv.conf; expected %q, got %q", string(bytesResolvConf), string(containerResolv))
|
|
| 1519 |
+ if !bytes.Equal(containerResolv, tmpResolvConf) {
|
|
| 1520 |
+ c.Fatalf("Restarted container should have updated resolv.conf; expected %q, got %q", string(tmpResolvConf), string(containerResolv))
|
|
| 1521 | 1521 |
} |
| 1522 | 1522 |
|
| 1523 | 1523 |
//5. test that additions of a localhost resolver are cleaned from |
| 1524 | 1524 |
// host resolv.conf before updating container's resolv.conf copies |
| 1525 | 1525 |
|
| 1526 | 1526 |
// replace resolv.conf with a localhost-only nameserver copy |
| 1527 |
- bytesResolvConf = []byte(tmpLocalhostResolvConf) |
|
| 1528 |
- if err = ioutil.WriteFile("/etc/resolv.conf", bytesResolvConf, 0644); err != nil {
|
|
| 1527 |
+ if err = ioutil.WriteFile("/etc/resolv.conf", tmpLocalhostResolvConf, 0644); err != nil {
|
|
| 1529 | 1528 |
c.Fatal(err) |
| 1530 | 1529 |
} |
| 1531 | 1530 |
|
| ... | ... |
@@ -1553,8 +1551,7 @@ func (s *DockerSuite) TestRunResolvconfUpdate(c *testing.T) {
|
| 1553 | 1553 |
containerID3 := getIDByName(c, "third") |
| 1554 | 1554 |
|
| 1555 | 1555 |
// Create a modified resolv.conf.aside and override resolv.conf with it |
| 1556 |
- bytesResolvConf = []byte(tmpResolvConf) |
|
| 1557 |
- if err := ioutil.WriteFile("/etc/resolv.conf.aside", bytesResolvConf, 0644); err != nil {
|
|
| 1556 |
+ if err := ioutil.WriteFile("/etc/resolv.conf.aside", tmpResolvConf, 0644); err != nil {
|
|
| 1558 | 1557 |
c.Fatal(err) |
| 1559 | 1558 |
} |
| 1560 | 1559 |
|
| ... | ... |
@@ -1568,7 +1565,7 @@ func (s *DockerSuite) TestRunResolvconfUpdate(c *testing.T) {
|
| 1568 | 1568 |
|
| 1569 | 1569 |
// check for update in container |
| 1570 | 1570 |
containerResolv = readContainerFile(c, containerID3, "resolv.conf") |
| 1571 |
- if !bytes.Equal(containerResolv, bytesResolvConf) {
|
|
| 1571 |
+ if !bytes.Equal(containerResolv, tmpResolvConf) {
|
|
| 1572 | 1572 |
c.Fatalf("Stopped container does not have updated resolv.conf; expected\n%q\n got\n%q", tmpResolvConf, string(containerResolv))
|
| 1573 | 1573 |
} |
| 1574 | 1574 |
|
| ... | ... |
@@ -2661,7 +2658,7 @@ func (s *DockerSuite) TestRunRestartMaxRetries(c *testing.T) {
|
| 2661 | 2661 |
timeout = 120 * time.Second |
| 2662 | 2662 |
} |
| 2663 | 2663 |
|
| 2664 |
- id := strings.TrimSpace(string(out)) |
|
| 2664 |
+ id := strings.TrimSpace(out) |
|
| 2665 | 2665 |
if err := waitInspect(id, "{{ .State.Restarting }} {{ .State.Running }}", "false false", timeout); err != nil {
|
| 2666 | 2666 |
c.Fatal(err) |
| 2667 | 2667 |
} |
| ... | ... |
@@ -2704,7 +2701,7 @@ func (s *DockerSuite) TestPermissionsPtsReadonlyRootfs(c *testing.T) {
|
| 2704 | 2704 |
c.Fatal("Could not obtain mounts when checking /dev/pts mntpnt.")
|
| 2705 | 2705 |
} |
| 2706 | 2706 |
expected := "type devpts (rw," |
| 2707 |
- if !strings.Contains(string(out), expected) {
|
|
| 2707 |
+ if !strings.Contains(out, expected) {
|
|
| 2708 | 2708 |
c.Fatalf("expected output to contain %s but contains %s", expected, out)
|
| 2709 | 2709 |
} |
| 2710 | 2710 |
} |
| ... | ... |
@@ -2739,7 +2736,7 @@ func (s *DockerSuite) TestRunContainerWithReadonlyEtcHostsAndLinkedContainer(c * |
| 2739 | 2739 |
dockerCmd(c, "run", "-d", "--name", "test-etc-hosts-ro-linked", "busybox", "top") |
| 2740 | 2740 |
|
| 2741 | 2741 |
out, _ := dockerCmd(c, "run", "--read-only", "--link", "test-etc-hosts-ro-linked:testlinked", "busybox", "cat", "/etc/hosts") |
| 2742 |
- if !strings.Contains(string(out), "testlinked") {
|
|
| 2742 |
+ if !strings.Contains(out, "testlinked") {
|
|
| 2743 | 2743 |
c.Fatal("Expected /etc/hosts to be updated even if --read-only enabled")
|
| 2744 | 2744 |
} |
| 2745 | 2745 |
} |
| ... | ... |
@@ -2749,7 +2746,7 @@ func (s *DockerSuite) TestRunContainerWithReadonlyRootfsWithDNSFlag(c *testing.T |
| 2749 | 2749 |
testRequires(c, DaemonIsLinux, UserNamespaceROMount) |
| 2750 | 2750 |
|
| 2751 | 2751 |
out, _ := dockerCmd(c, "run", "--read-only", "--dns", "1.1.1.1", "busybox", "/bin/cat", "/etc/resolv.conf") |
| 2752 |
- if !strings.Contains(string(out), "1.1.1.1") {
|
|
| 2752 |
+ if !strings.Contains(out, "1.1.1.1") {
|
|
| 2753 | 2753 |
c.Fatal("Expected /etc/resolv.conf to be updated even if --read-only enabled and --dns flag used")
|
| 2754 | 2754 |
} |
| 2755 | 2755 |
} |
| ... | ... |
@@ -2759,7 +2756,7 @@ func (s *DockerSuite) TestRunContainerWithReadonlyRootfsWithAddHostFlag(c *testi |
| 2759 | 2759 |
testRequires(c, DaemonIsLinux, UserNamespaceROMount) |
| 2760 | 2760 |
|
| 2761 | 2761 |
out, _ := dockerCmd(c, "run", "--read-only", "--add-host", "testreadonly:127.0.0.1", "busybox", "/bin/cat", "/etc/hosts") |
| 2762 |
- if !strings.Contains(string(out), "testreadonly") {
|
|
| 2762 |
+ if !strings.Contains(out, "testreadonly") {
|
|
| 2763 | 2763 |
c.Fatal("Expected /etc/hosts to be updated even if --read-only enabled and --add-host flag used")
|
| 2764 | 2764 |
} |
| 2765 | 2765 |
} |
| ... | ... |
@@ -3249,11 +3246,11 @@ func (s *DockerSuite) TestRunContainerWithCgroupParent(c *testing.T) {
|
| 3249 | 3249 |
func testRunContainerWithCgroupParent(c *testing.T, cgroupParent, name string) {
|
| 3250 | 3250 |
out, _, err := dockerCmdWithError("run", "--cgroup-parent", cgroupParent, "--name", name, "busybox", "cat", "/proc/self/cgroup")
|
| 3251 | 3251 |
if err != nil {
|
| 3252 |
- c.Fatalf("unexpected failure when running container with --cgroup-parent option - %s\n%v", string(out), err)
|
|
| 3252 |
+ c.Fatalf("unexpected failure when running container with --cgroup-parent option - %s\n%v", out, err)
|
|
| 3253 | 3253 |
} |
| 3254 |
- cgroupPaths := ParseCgroupPaths(string(out)) |
|
| 3254 |
+ cgroupPaths := ParseCgroupPaths(out) |
|
| 3255 | 3255 |
if len(cgroupPaths) == 0 {
|
| 3256 |
- c.Fatalf("unexpected output - %q", string(out))
|
|
| 3256 |
+ c.Fatalf("unexpected output - %q", out)
|
|
| 3257 | 3257 |
} |
| 3258 | 3258 |
id := getIDByName(c, name) |
| 3259 | 3259 |
expectedCgroup := path.Join(cgroupParent, id) |
| ... | ... |
@@ -3283,7 +3280,7 @@ func testRunInvalidCgroupParent(c *testing.T, cgroupParent, cleanCgroupParent, n |
| 3283 | 3283 |
out, _, err := dockerCmdWithError("run", "--cgroup-parent", cgroupParent, "--name", name, "busybox", "cat", "/proc/self/cgroup")
|
| 3284 | 3284 |
if err != nil {
|
| 3285 | 3285 |
// XXX: This may include a daemon crash. |
| 3286 |
- c.Fatalf("unexpected failure when running container with --cgroup-parent option - %s\n%v", string(out), err)
|
|
| 3286 |
+ c.Fatalf("unexpected failure when running container with --cgroup-parent option - %s\n%v", out, err)
|
|
| 3287 | 3287 |
} |
| 3288 | 3288 |
|
| 3289 | 3289 |
// 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 |
| 3291 | 3291 |
c.Fatalf("SECURITY: --cgroup-parent with ../../ relative paths cause files to be created in the host (this is bad) !!")
|
| 3292 | 3292 |
} |
| 3293 | 3293 |
|
| 3294 |
- cgroupPaths := ParseCgroupPaths(string(out)) |
|
| 3294 |
+ cgroupPaths := ParseCgroupPaths(out) |
|
| 3295 | 3295 |
if len(cgroupPaths) == 0 {
|
| 3296 |
- c.Fatalf("unexpected output - %q", string(out))
|
|
| 3296 |
+ c.Fatalf("unexpected output - %q", out)
|
|
| 3297 | 3297 |
} |
| 3298 | 3298 |
id := getIDByName(c, name) |
| 3299 | 3299 |
expectedCgroup := path.Join(cleanCgroupParent, id) |
| ... | ... |
@@ -3947,11 +3944,11 @@ func (s *DockerSuite) TestRunAttachFailedNoLeak(c *testing.T) {
|
| 3947 | 3947 |
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) |
| 3948 | 3948 |
// check for windows error as well |
| 3949 | 3949 |
// TODO Windows Post TP5. Fix the error message string |
| 3950 |
- assert.Assert(c, strings.Contains(string(out), "port is already allocated") || |
|
| 3951 |
- strings.Contains(string(out), "were not connected because a duplicate name exists") || |
|
| 3952 |
- strings.Contains(string(out), "The specified port already exists") || |
|
| 3953 |
- strings.Contains(string(out), "HNS failed with error : Failed to create endpoint") || |
|
| 3954 |
- strings.Contains(string(out), "HNS failed with error : The object already exists"), fmt.Sprintf("Output: %s", out))
|
|
| 3950 |
+ assert.Assert(c, strings.Contains(out, "port is already allocated") || |
|
| 3951 |
+ strings.Contains(out, "were not connected because a duplicate name exists") || |
|
| 3952 |
+ strings.Contains(out, "The specified port already exists") || |
|
| 3953 |
+ strings.Contains(out, "HNS failed with error : Failed to create endpoint") || |
|
| 3954 |
+ strings.Contains(out, "HNS failed with error : The object already exists"), fmt.Sprintf("Output: %s", out))
|
|
| 3955 | 3955 |
dockerCmd(c, "rm", "-f", "test") |
| 3956 | 3956 |
|
| 3957 | 3957 |
// 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{},
|
| 65 | 65 |
return 0, "Empty stdout" |
| 66 | 66 |
} |
| 67 | 67 |
lines := strings.Split(strings.TrimSpace(result.Stdout()), "\n") |
| 68 |
- return len(lines), fmt.Sprintf("output, %q", string(result.Stdout()))
|
|
| 68 |
+ return len(lines), fmt.Sprintf("output, %q", result.Stdout())
|
|
| 69 | 69 |
} |
| 70 | 70 |
} |
| 71 | 71 |
|
| ... | ... |
@@ -900,15 +900,15 @@ func (s *DockerSwarmSuite) TestSwarmServiceNetworkUpdate(c *testing.T) {
|
| 900 | 900 |
|
| 901 | 901 |
result := icmd.RunCmd(d.Command("network", "create", "-d", "overlay", "foo"))
|
| 902 | 902 |
result.Assert(c, icmd.Success) |
| 903 |
- fooNetwork := strings.TrimSpace(string(result.Combined())) |
|
| 903 |
+ fooNetwork := strings.TrimSpace(result.Combined()) |
|
| 904 | 904 |
|
| 905 | 905 |
result = icmd.RunCmd(d.Command("network", "create", "-d", "overlay", "bar"))
|
| 906 | 906 |
result.Assert(c, icmd.Success) |
| 907 |
- barNetwork := strings.TrimSpace(string(result.Combined())) |
|
| 907 |
+ barNetwork := strings.TrimSpace(result.Combined()) |
|
| 908 | 908 |
|
| 909 | 909 |
result = icmd.RunCmd(d.Command("network", "create", "-d", "overlay", "baz"))
|
| 910 | 910 |
result.Assert(c, icmd.Success) |
| 911 |
- bazNetwork := strings.TrimSpace(string(result.Combined())) |
|
| 911 |
+ bazNetwork := strings.TrimSpace(result.Combined()) |
|
| 912 | 912 |
|
| 913 | 913 |
// Create a service |
| 914 | 914 |
name := "top" |
| ... | ... |
@@ -50,7 +50,7 @@ func (s *DockerSwarmSuite) TestSwarmVolumePlugin(c *testing.T) {
|
| 50 | 50 |
} |
| 51 | 51 |
|
| 52 | 52 |
assert.NilError(c, json.NewDecoder(strings.NewReader(out)).Decode(&mounts)) |
| 53 |
- assert.Equal(c, len(mounts), 1, string(out)) |
|
| 53 |
+ assert.Equal(c, len(mounts), 1, out) |
|
| 54 | 54 |
assert.Equal(c, mounts[0].Name, "my-volume") |
| 55 | 55 |
assert.Equal(c, mounts[0].Driver, "customvolumedriver") |
| 56 | 56 |
} |
| ... | ... |
@@ -271,7 +271,7 @@ func (s *DockerSuite) TestUpdateNotAffectMonitorRestartPolicy(c *testing.T) {
|
| 271 | 271 |
testRequires(c, DaemonIsLinux, cpuShare) |
| 272 | 272 |
|
| 273 | 273 |
out, _ := dockerCmd(c, "run", "-tid", "--restart=always", "busybox", "sh") |
| 274 |
- id := strings.TrimSpace(string(out)) |
|
| 274 |
+ id := strings.TrimSpace(out) |
|
| 275 | 275 |
dockerCmd(c, "update", "--cpu-shares", "512", id) |
| 276 | 276 |
|
| 277 | 277 |
cpty, tty, err := pty.Open() |
| ... | ... |
@@ -106,7 +106,7 @@ func (s *DockerSuite) TestVolumeLsFormatDefaultFormat(c *testing.T) {
|
| 106 | 106 |
} |
| 107 | 107 |
|
| 108 | 108 |
func assertVolumesInList(c *testing.T, out string, expected []string) {
|
| 109 |
- lines := strings.Split(strings.TrimSpace(string(out)), "\n") |
|
| 109 |
+ lines := strings.Split(strings.TrimSpace(out), "\n") |
|
| 110 | 110 |
for _, expect := range expected {
|
| 111 | 111 |
found := false |
| 112 | 112 |
for _, v := range lines {
|
| ... | ... |
@@ -82,8 +82,8 @@ func UnixCli() bool {
|
| 82 | 82 |
|
| 83 | 83 |
func Network() bool {
|
| 84 | 84 |
// Set a timeout on the GET at 15s |
| 85 |
- var timeout = time.Duration(15 * time.Second) |
|
| 86 |
- var url = "https://hub.docker.com" |
|
| 85 |
+ const timeout = 15 * time.Second |
|
| 86 |
+ const url = "https://hub.docker.com" |
|
| 87 | 87 |
|
| 88 | 88 |
client := http.Client{
|
| 89 | 89 |
Timeout: timeout, |