1
0
mirror of https://github.com/moby/moby.git synced 2025-07-30 18:23:29 +03:00

integration-cli: normalize comment formatting

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2019-11-27 15:36:45 +01:00
parent a4a0429eec
commit 580d3677c8
15 changed files with 64 additions and 71 deletions

View File

@ -210,26 +210,21 @@ func (s *DockerSuite) TestBuildAPIUnnormalizedTarPaths(c *testing.T) {
Name: "Dockerfile", Name: "Dockerfile",
Size: int64(len(dockerfile)), Size: int64(len(dockerfile)),
}) })
//failed to write tar file header assert.NilError(c, err, "failed to write tar file header")
assert.NilError(c, err)
_, err = tw.Write(dockerfile) _, err = tw.Write(dockerfile)
// failed to write Dockerfile in tar file content assert.NilError(c, err, "failed to write Dockerfile in tar file content")
assert.NilError(c, err)
err = tw.WriteHeader(&tar.Header{ err = tw.WriteHeader(&tar.Header{
Name: "dir/./file", Name: "dir/./file",
Size: int64(len(fileContents)), Size: int64(len(fileContents)),
}) })
//failed to write tar file header assert.NilError(c, err, "failed to write tar file header")
assert.NilError(c, err)
_, err = tw.Write(fileContents) _, err = tw.Write(fileContents)
// failed to write file contents in tar file content assert.NilError(c, err, "failed to write file contents in tar file content")
assert.NilError(c, err)
// failed to close tar archive assert.NilError(c, tw.Close(), "failed to close tar archive")
assert.NilError(c, tw.Close())
res, body, err := request.Post("/build", request.RawContent(ioutil.NopCloser(buffer)), request.ContentType("application/x-tar")) res, body, err := request.Post("/build", request.RawContent(ioutil.NopCloser(buffer)), request.ContentType("application/x-tar"))
assert.NilError(c, err) assert.NilError(c, err)

View File

@ -689,7 +689,7 @@ func (s *DockerSuite) TestContainerAPIVerifyHeader(c *testing.T) {
body.Close() body.Close()
} }
//Issue 14230. daemon should return 500 for invalid port syntax // Issue 14230. daemon should return 500 for invalid port syntax
func (s *DockerSuite) TestContainerAPIInvalidPortSyntax(c *testing.T) { func (s *DockerSuite) TestContainerAPIInvalidPortSyntax(c *testing.T) {
config := `{ config := `{
"Image": "busybox", "Image": "busybox",

View File

@ -44,7 +44,7 @@ func (s *DockerSuite) TestAPIImagesFilter(c *testing.T) {
return images return images
} }
//incorrect number of matches returned // incorrect number of matches returned
images := getImages("utest*/*") images := getImages("utest*/*")
assert.Equal(c, len(images[0].RepoTags), 2) assert.Equal(c, len(images[0].RepoTags), 2)

View File

@ -356,7 +356,7 @@ func (s *DockerSwarmSuite) TestAPISwarmServiceConstraintRole(c *testing.T) {
node := daemons[0].GetNode(c, task.NodeID) node := daemons[0].GetNode(c, task.NodeID)
assert.Equal(c, node.Spec.Role, swarm.NodeRoleWorker) assert.Equal(c, node.Spec.Role, swarm.NodeRoleWorker)
} }
//remove service // remove service
daemons[0].RemoveService(c, id) daemons[0].RemoveService(c, id)
// create service // create service
@ -370,7 +370,7 @@ func (s *DockerSwarmSuite) TestAPISwarmServiceConstraintRole(c *testing.T) {
node := daemons[0].GetNode(c, task.NodeID) node := daemons[0].GetNode(c, task.NodeID)
assert.Equal(c, node.Spec.Role, swarm.NodeRoleManager) assert.Equal(c, node.Spec.Role, swarm.NodeRoleManager)
} }
//remove service // remove service
daemons[0].RemoveService(c, id) daemons[0].RemoveService(c, id)
// create service // create service
@ -423,7 +423,7 @@ func (s *DockerSwarmSuite) TestAPISwarmServiceConstraintLabel(c *testing.T) {
for _, task := range tasks { for _, task := range tasks {
assert.Assert(c, task.NodeID == nodes[0].ID) assert.Assert(c, task.NodeID == nodes[0].ID)
} }
//remove service // remove service
daemons[0].RemoveService(c, id) daemons[0].RemoveService(c, id)
// create service // create service
@ -436,7 +436,7 @@ func (s *DockerSwarmSuite) TestAPISwarmServiceConstraintLabel(c *testing.T) {
for _, task := range tasks { for _, task := range tasks {
assert.Assert(c, task.NodeID != nodes[0].ID) assert.Assert(c, task.NodeID != nodes[0].ID)
} }
//remove service // remove service
daemons[0].RemoveService(c, id) daemons[0].RemoveService(c, id)
constraints = []string{"node.labels.security==medium"} constraints = []string{"node.labels.security==medium"}
@ -450,7 +450,7 @@ func (s *DockerSwarmSuite) TestAPISwarmServiceConstraintLabel(c *testing.T) {
for _, task := range tasks { for _, task := range tasks {
assert.Assert(c, task.NodeID == "") assert.Assert(c, task.NodeID == "")
} }
//remove service // remove service
daemons[0].RemoveService(c, id) daemons[0].RemoveService(c, id)
// multiple constraints // multiple constraints

View File

@ -175,7 +175,7 @@ func (s *DockerRegistrySuite) TestRemoveImageByDigest(c *testing.T) {
// try to inspect again - it should error this time // try to inspect again - it should error this time
_, err = inspectFieldWithError(imageReference, "Id") _, err = inspectFieldWithError(imageReference, "Id")
//unexpected nil err trying to inspect what should be a non-existent image // unexpected nil err trying to inspect what should be a non-existent image
assert.ErrorContains(c, err, "No such object") assert.ErrorContains(c, err, "No such object")
} }
@ -255,8 +255,7 @@ func (s *DockerRegistrySuite) TestListImagesWithDigests(c *testing.T) {
assert.Assert(c, re1.MatchString(out), "expected %q: %s", re1.String(), out) assert.Assert(c, re1.MatchString(out), "expected %q: %s", re1.String(), out)
// setup image2 // setup image2
digest2, err := setupImageWithTag(c, "tag2") digest2, err := setupImageWithTag(c, "tag2")
//error setting up image assert.NilError(c, err, "error setting up image")
assert.NilError(c, err)
imageReference2 := fmt.Sprintf("%s@%s", repoName, digest2) imageReference2 := fmt.Sprintf("%s@%s", repoName, digest2)
c.Logf("imageReference2 = %s", imageReference2) c.Logf("imageReference2 = %s", imageReference2)

View File

@ -38,7 +38,7 @@ func (s *DockerSuite) TestCommitWithoutPause(c *testing.T) {
dockerCmd(c, "inspect", cleanedImageID) dockerCmd(c, "inspect", cleanedImageID)
} }
//test commit a paused container should not unpause it after commit // TestCommitPausedContainer tests that a paused container is not unpaused after being committed
func (s *DockerSuite) TestCommitPausedContainer(c *testing.T) { func (s *DockerSuite) TestCommitPausedContainer(c *testing.T) {
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
out, _ := dockerCmd(c, "run", "-i", "-d", "busybox") out, _ := dockerCmd(c, "run", "-i", "-d", "busybox")

View File

@ -213,7 +213,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithInvalidBasesize(c *testing.T) {
s.d.Start(c) s.d.Start(c)
oldBasesizeBytes := getBaseDeviceSize(c, s.d) oldBasesizeBytes := getBaseDeviceSize(c, s.d)
var newBasesizeBytes int64 = 1073741824 //1GB in bytes var newBasesizeBytes int64 = 1073741824 // 1GB in bytes
if newBasesizeBytes < oldBasesizeBytes { if newBasesizeBytes < oldBasesizeBytes {
err := s.d.RestartWithError("--storage-opt", fmt.Sprintf("dm.basesize=%d", newBasesizeBytes)) err := s.d.RestartWithError("--storage-opt", fmt.Sprintf("dm.basesize=%d", newBasesizeBytes))
@ -234,7 +234,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithIncreasedBasesize(c *testing.T)
oldBasesizeBytes := getBaseDeviceSize(c, s.d) oldBasesizeBytes := getBaseDeviceSize(c, s.d)
var newBasesizeBytes int64 = 53687091200 //50GB in bytes var newBasesizeBytes int64 = 53687091200 // 50GB in bytes
if newBasesizeBytes < oldBasesizeBytes { if newBasesizeBytes < oldBasesizeBytes {
c.Skip(fmt.Sprintf("New base device size (%v) must be greater than (%s)", units.HumanSize(float64(newBasesizeBytes)), units.HumanSize(float64(oldBasesizeBytes)))) c.Skip(fmt.Sprintf("New base device size (%v) must be greater than (%s)", units.HumanSize(float64(newBasesizeBytes)), units.HumanSize(float64(oldBasesizeBytes))))
@ -572,16 +572,16 @@ func (s *DockerDaemonSuite) TestDaemonKeyGeneration(c *testing.T) {
// Note that this explicitly tests the conflict of {-b,--bridge} and {--bip} options as the means // Note that this explicitly tests the conflict of {-b,--bridge} and {--bip} options as the means
// to get a daemon init failure; no other tests for -b/--bip conflict are therefore required // to get a daemon init failure; no other tests for -b/--bip conflict are therefore required
func (s *DockerDaemonSuite) TestDaemonExitOnFailure(c *testing.T) { func (s *DockerDaemonSuite) TestDaemonExitOnFailure(c *testing.T) {
//attempt to start daemon with incorrect flags (we know -b and --bip conflict) // attempt to start daemon with incorrect flags (we know -b and --bip conflict)
if err := s.d.StartWithError("--bridge", "nosuchbridge", "--bip", "1.1.1.1"); err != nil { if err := s.d.StartWithError("--bridge", "nosuchbridge", "--bip", "1.1.1.1"); err != nil {
//verify we got the right error // verify we got the right error
if !strings.Contains(err.Error(), "daemon exited") { if !strings.Contains(err.Error(), "daemon exited") {
c.Fatalf("Expected daemon not to start, got %v", err) c.Fatalf("Expected daemon not to start, got %v", err)
} }
// look in the log and make sure we got the message that daemon is shutting down // look in the log and make sure we got the message that daemon is shutting down
icmd.RunCommand("grep", "failed to start daemon", s.d.LogFileName()).Assert(c, icmd.Success) icmd.RunCommand("grep", "failed to start daemon", s.d.LogFileName()).Assert(c, icmd.Success)
} else { } else {
//if we didn't get an error and the daemon is running, this is a failure // if we didn't get an error and the daemon is running, this is a failure
c.Fatal("Conflicting options should cause the daemon to error out with a failure") c.Fatal("Conflicting options should cause the daemon to error out with a failure")
} }
} }
@ -697,7 +697,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithBridgeIPChange(c *testing.T) {
s.d.Start(c, "--bip", bridgeIP) s.d.Start(c, "--bip", bridgeIP)
//check if the iptables contains new bridgeIP MASQUERADE rule // check if the iptables contains new bridgeIP MASQUERADE rule
ipTablesSearchString := bridgeIPNet.String() ipTablesSearchString := bridgeIPNet.String()
icmd.RunCommand("iptables", "-t", "nat", "-nvL").Assert(c, icmd.Expected{ icmd.RunCommand("iptables", "-t", "nat", "-nvL").Assert(c, icmd.Expected{
Out: ipTablesSearchString, Out: ipTablesSearchString,
@ -1203,7 +1203,7 @@ func (s *DockerDaemonSuite) TestDaemonWithWrongkey(c *testing.T) {
c.Fatalf("Error Unmarshal: %s", err) c.Fatalf("Error Unmarshal: %s", err)
} }
//replace config.Kid with the fake value // replace config.Kid with the fake value
config.Kid = "VSAJ:FUYR:X3H2:B2VZ:KZ6U:CJD5:K7BX:ZXHY:UZXT:P4FT:MJWG:HRJ4" config.Kid = "VSAJ:FUYR:X3H2:B2VZ:KZ6U:CJD5:K7BX:ZXHY:UZXT:P4FT:MJWG:HRJ4"
// NEW Data-Struct to byte[] // NEW Data-Struct to byte[]

View File

@ -48,7 +48,7 @@ func (s *DockerSuite) TestEventsTimestampFormats(c *testing.T) {
events = events[:len(events)-1] events = events[:len(events)-1]
nEvents := len(events) nEvents := len(events)
assert.Assert(c, nEvents >= 5) //Missing expected event assert.Assert(c, nEvents >= 5)
containerEvents := eventActionsByIDAndType(c, events, name, "container") containerEvents := eventActionsByIDAndType(c, events, name, "container")
assert.Assert(c, is.DeepEqual(containerEvents, []string{"create", "attach", "start", "die", "destroy"}), out) assert.Assert(c, is.DeepEqual(containerEvents, []string{"create", "attach", "start", "die", "destroy"}), out)
} }
@ -99,7 +99,7 @@ func (s *DockerSuite) TestEventsContainerEventsAttrSort(c *testing.T) {
events := strings.Split(out, "\n") events := strings.Split(out, "\n")
nEvents := len(events) nEvents := len(events)
assert.Assert(c, nEvents >= 3) //Missing expected event assert.Assert(c, nEvents >= 3)
matchedEvents := 0 matchedEvents := 0
for _, event := range events { for _, event := range events {
matches := eventstestutils.ScanMap(event) matches := eventstestutils.ScanMap(event)
@ -124,7 +124,7 @@ func (s *DockerSuite) TestEventsContainerEventsSinceUnixEpoch(c *testing.T) {
events = events[:len(events)-1] events = events[:len(events)-1]
nEvents := len(events) nEvents := len(events)
assert.Assert(c, nEvents >= 5) //Missing expected event assert.Assert(c, nEvents >= 5)
containerEvents := eventActionsByIDAndType(c, events, "since-epoch-test", "container") containerEvents := eventActionsByIDAndType(c, events, "since-epoch-test", "container")
assert.Assert(c, is.DeepEqual(containerEvents, []string{"create", "attach", "start", "die", "destroy"}), out) assert.Assert(c, is.DeepEqual(containerEvents, []string{"create", "attach", "start", "die", "destroy"}), out)
} }
@ -664,7 +664,7 @@ func (s *DockerSuite) TestEventsContainerRestart(c *testing.T) {
events := strings.Split(strings.TrimSpace(out), "\n") events := strings.Split(strings.TrimSpace(out), "\n")
nEvents := len(events) nEvents := len(events)
assert.Assert(c, nEvents >= 1) //Missing expected event assert.Assert(c, nEvents >= 1)
actions := eventActionsByIDAndType(c, events, "testEvent", "container") actions := eventActionsByIDAndType(c, events, "testEvent", "container")
for _, a := range actions { for _, a := range actions {

View File

@ -243,7 +243,7 @@ func (s *DockerSuite) TestEventsContainerWithMultiNetwork(c *testing.T) {
assert.Assert(c, strings.Contains(netEvents[0], "disconnect")) assert.Assert(c, strings.Contains(netEvents[0], "disconnect"))
assert.Assert(c, strings.Contains(netEvents[1], "disconnect")) assert.Assert(c, strings.Contains(netEvents[1], "disconnect"))
//both networks appeared in the network event output // both networks appeared in the network event output
assert.Assert(c, strings.Contains(out, "test-event-network-local-1")) assert.Assert(c, strings.Contains(out, "test-event-network-local-1"))
assert.Assert(c, strings.Contains(out, "test-event-network-local-2")) assert.Assert(c, strings.Contains(out, "test-event-network-local-2"))
} }

View File

@ -242,10 +242,10 @@ func (s *DockerSuite) TestImagesEnsureDanglingImageOnlyListedOnce(c *testing.T)
assert.Equal(c, strings.Count(out, imageID), 1) assert.Equal(c, strings.Count(out, imageID), 1)
out, _ = dockerCmd(c, "images", "-q", "-f", "dangling=false") out, _ = dockerCmd(c, "images", "-q", "-f", "dangling=false")
//dangling=false would not include dangling images // dangling=false would not include dangling images
assert.Assert(c, !strings.Contains(out, imageID)) assert.Assert(c, !strings.Contains(out, imageID))
out, _ = dockerCmd(c, "images") out, _ = dockerCmd(c, "images")
//docker images still include dangling images // docker images still include dangling images
assert.Assert(c, strings.Contains(out, imageID)) assert.Assert(c, strings.Contains(out, imageID))
} }

View File

@ -42,8 +42,8 @@ func (s *DockerSuite) TestInspectInt64(c *testing.T) {
} }
func (s *DockerSuite) TestInspectDefault(c *testing.T) { func (s *DockerSuite) TestInspectDefault(c *testing.T) {
//Both the container and image are named busybox. docker inspect will fetch the container JSON. // Both the container and image are named busybox. docker inspect will fetch the container JSON.
//If the container JSON is not available, it will go for the image JSON. // If the container JSON is not available, it will go for the image JSON.
out, _ := dockerCmd(c, "run", "--name=busybox", "-d", "busybox", "true") out, _ := dockerCmd(c, "run", "--name=busybox", "-d", "busybox", "true")
containerID := strings.TrimSpace(out) containerID := strings.TrimSpace(out)
@ -78,8 +78,8 @@ func (s *DockerSuite) TestInspectStatus(c *testing.T) {
} }
func (s *DockerSuite) TestInspectTypeFlagContainer(c *testing.T) { func (s *DockerSuite) TestInspectTypeFlagContainer(c *testing.T) {
//Both the container and image are named busybox. docker inspect will fetch container // Both the container and image are named busybox. docker inspect will fetch container
//JSON State.Running field. If the field is true, it's a container. // JSON State.Running field. If the field is true, it's a container.
runSleepingContainer(c, "--name=busybox", "-d") runSleepingContainer(c, "--name=busybox", "-d")
formatStr := "--format={{.State.Running}}" formatStr := "--format={{.State.Running}}"
@ -88,9 +88,9 @@ func (s *DockerSuite) TestInspectTypeFlagContainer(c *testing.T) {
} }
func (s *DockerSuite) TestInspectTypeFlagWithNoContainer(c *testing.T) { func (s *DockerSuite) TestInspectTypeFlagWithNoContainer(c *testing.T) {
//Run this test on an image named busybox. docker inspect will try to fetch container // Run this test on an image named busybox. docker inspect will try to fetch container
//JSON. Since there is no container named busybox and --type=container, docker inspect will // JSON. Since there is no container named busybox and --type=container, docker inspect will
//not try to get the image JSON. It will throw an error. // not try to get the image JSON. It will throw an error.
dockerCmd(c, "run", "-d", "busybox", "true") dockerCmd(c, "run", "-d", "busybox", "true")
@ -100,9 +100,9 @@ func (s *DockerSuite) TestInspectTypeFlagWithNoContainer(c *testing.T) {
} }
func (s *DockerSuite) TestInspectTypeFlagWithImage(c *testing.T) { func (s *DockerSuite) TestInspectTypeFlagWithImage(c *testing.T) {
//Both the container and image are named busybox. docker inspect will fetch image // Both the container and image are named busybox. docker inspect will fetch image
//JSON as --type=image. if there is no image with name busybox, docker inspect // JSON as --type=image. if there is no image with name busybox, docker inspect
//will throw an error. // will throw an error.
dockerCmd(c, "run", "--name=busybox", "-d", "busybox", "true") dockerCmd(c, "run", "--name=busybox", "-d", "busybox", "true")
@ -112,8 +112,8 @@ func (s *DockerSuite) TestInspectTypeFlagWithImage(c *testing.T) {
} }
func (s *DockerSuite) TestInspectTypeFlagWithInvalidValue(c *testing.T) { func (s *DockerSuite) TestInspectTypeFlagWithInvalidValue(c *testing.T) {
//Both the container and image are named busybox. docker inspect will fail // Both the container and image are named busybox. docker inspect will fail
//as --type=foobar is not a valid value for the flag. // as --type=foobar is not a valid value for the flag.
dockerCmd(c, "run", "--name=busybox", "-d", "busybox", "true") dockerCmd(c, "run", "--name=busybox", "-d", "busybox", "true")
@ -295,9 +295,8 @@ func (s *DockerSuite) TestInspectLogConfigNoType(c *testing.T) {
} }
func (s *DockerSuite) TestInspectNoSizeFlagContainer(c *testing.T) { func (s *DockerSuite) TestInspectNoSizeFlagContainer(c *testing.T) {
// Both the container and image are named busybox. docker inspect will fetch container
//Both the container and image are named busybox. docker inspect will fetch container // JSON SizeRw and SizeRootFs field. If there is no flag --size/-s, there are no size fields.
//JSON SizeRw and SizeRootFs field. If there is no flag --size/-s, there are no size fields.
runSleepingContainer(c, "--name=busybox", "-d") runSleepingContainer(c, "--name=busybox", "-d")

View File

@ -755,7 +755,7 @@ func (s *DockerSuite) TestPsListContainersFilterNetwork(c *testing.T) {
// skip header // skip header
lines = lines[1:] lines = lines[1:]
//ps output should have both the containers // ps output should have both the containers
assert.Equal(c, len(RemoveLinesForExistingElements(lines, existing)), 2) assert.Equal(c, len(RemoveLinesForExistingElements(lines, existing)), 2)
// Making sure onbridgenetwork and onnonenetwork is on the output // Making sure onbridgenetwork and onnonenetwork is on the output

View File

@ -175,7 +175,7 @@ func (s *DockerSuite) TestRunWithoutNetworking(c *testing.T) {
} }
} }
//test --link use container name to link target // test --link use container name to link target
func (s *DockerSuite) TestRunLinksContainerWithContainerName(c *testing.T) { func (s *DockerSuite) TestRunLinksContainerWithContainerName(c *testing.T) {
// TODO Windows: This test cannot run on a Windows daemon as the networking // TODO Windows: This test cannot run on a Windows daemon as the networking
// settings are not populated back yet on inspect. // settings are not populated back yet on inspect.
@ -190,7 +190,7 @@ func (s *DockerSuite) TestRunLinksContainerWithContainerName(c *testing.T) {
} }
} }
//test --link use container id to link target // test --link use container id to link target
func (s *DockerSuite) TestRunLinksContainerWithContainerID(c *testing.T) { func (s *DockerSuite) TestRunLinksContainerWithContainerID(c *testing.T) {
// TODO Windows: This test cannot run on a Windows daemon as the networking // TODO Windows: This test cannot run on a Windows daemon as the networking
// settings are not populated back yet on inspect. // settings are not populated back yet on inspect.
@ -1430,7 +1430,7 @@ func (s *DockerSuite) TestRunResolvconfUpdate(c *testing.T) {
tmpResolvConf := []byte("search pommesfrites.fr\nnameserver 12.34.56.78\n") tmpResolvConf := []byte("search pommesfrites.fr\nnameserver 12.34.56.78\n")
tmpLocalhostResolvConf := []byte("nameserver 127.0.0.1") tmpLocalhostResolvConf := []byte("nameserver 127.0.0.1")
//take a copy of resolv.conf for restoring after test completes // take a copy of resolv.conf for restoring after test completes
resolvConfSystem, err := ioutil.ReadFile("/etc/resolv.conf") resolvConfSystem, err := ioutil.ReadFile("/etc/resolv.conf")
if err != nil { if err != nil {
c.Fatal(err) c.Fatal(err)
@ -1447,14 +1447,14 @@ func (s *DockerSuite) TestRunResolvconfUpdate(c *testing.T) {
icmd.RunCommand("umount", "/etc/resolv.conf").Assert(c, icmd.Success) icmd.RunCommand("umount", "/etc/resolv.conf").Assert(c, icmd.Success)
} }
//cleanup // cleanup
defer func() { defer func() {
if err := ioutil.WriteFile("/etc/resolv.conf", resolvConfSystem, 0644); err != nil { if err := ioutil.WriteFile("/etc/resolv.conf", resolvConfSystem, 0644); err != nil {
c.Fatal(err) c.Fatal(err)
} }
}() }()
//1. test that a restarting container gets an updated resolv.conf // 1. test that a restarting container gets an updated resolv.conf
dockerCmd(c, "run", "--name=first", "busybox", "true") dockerCmd(c, "run", "--name=first", "busybox", "true")
containerID1 := getIDByName(c, "first") containerID1 := getIDByName(c, "first")
@ -1472,16 +1472,16 @@ func (s *DockerSuite) TestRunResolvconfUpdate(c *testing.T) {
c.Fatalf("Restarted container does not have updated resolv.conf; expected %q, got %q", tmpResolvConf, string(containerResolv)) c.Fatalf("Restarted container does not have updated resolv.conf; expected %q, got %q", tmpResolvConf, string(containerResolv))
} }
/* //make a change to resolv.conf (in this case replacing our tmp copy with orig copy) /* // make a change to resolv.conf (in this case replacing our tmp copy with orig copy)
if err := ioutil.WriteFile("/etc/resolv.conf", resolvConfSystem, 0644); err != nil { if err := ioutil.WriteFile("/etc/resolv.conf", resolvConfSystem, 0644); err != nil {
c.Fatal(err) c.Fatal(err)
} */ } */
//2. test that a restarting container does not receive resolv.conf updates // 2. test that a restarting container does not receive resolv.conf updates
// if it modified the container copy of the starting point resolv.conf // if it modified the container copy of the starting point resolv.conf
dockerCmd(c, "run", "--name=second", "busybox", "sh", "-c", "echo 'search mylittlepony.com' >>/etc/resolv.conf") dockerCmd(c, "run", "--name=second", "busybox", "sh", "-c", "echo 'search mylittlepony.com' >>/etc/resolv.conf")
containerID2 := getIDByName(c, "second") containerID2 := getIDByName(c, "second")
//make a change to resolv.conf (in this case replacing our tmp copy with orig copy) // make a change to resolv.conf (in this case replacing our tmp copy with orig copy)
if err := ioutil.WriteFile("/etc/resolv.conf", resolvConfSystem, 0644); err != nil { if err := ioutil.WriteFile("/etc/resolv.conf", resolvConfSystem, 0644); err != nil {
c.Fatal(err) c.Fatal(err)
} }
@ -1495,7 +1495,7 @@ func (s *DockerSuite) TestRunResolvconfUpdate(c *testing.T) {
c.Fatalf("Container's resolv.conf should not have been updated with host resolv.conf: %q", string(containerResolv)) c.Fatalf("Container's resolv.conf should not have been updated with host resolv.conf: %q", string(containerResolv))
} }
//3. test that a running container's resolv.conf is not modified while running // 3. test that a running container's resolv.conf is not modified while running
out, _ := dockerCmd(c, "run", "-d", "busybox", "top") out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
runningContainerID := strings.TrimSpace(out) runningContainerID := strings.TrimSpace(out)
@ -1510,7 +1510,7 @@ func (s *DockerSuite) TestRunResolvconfUpdate(c *testing.T) {
c.Fatalf("Running container should not have updated resolv.conf; expected %q, got %q", string(resolvConfSystem), string(containerResolv)) c.Fatalf("Running container should not have updated resolv.conf; expected %q, got %q", string(resolvConfSystem), string(containerResolv))
} }
//4. test that a running container's resolv.conf is updated upon restart // 4. test that a running container's resolv.conf is updated upon restart
// (the above container is still running..) // (the above container is still running..)
dockerCmd(c, "restart", runningContainerID) dockerCmd(c, "restart", runningContainerID)
@ -1520,7 +1520,7 @@ func (s *DockerSuite) TestRunResolvconfUpdate(c *testing.T) {
c.Fatalf("Restarted container should have updated resolv.conf; expected %q, got %q", string(tmpResolvConf), string(containerResolv)) 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 // 5. test that additions of a localhost resolver are cleaned from
// host resolv.conf before updating container's resolv.conf copies // host resolv.conf before updating container's resolv.conf copies
// replace resolv.conf with a localhost-only nameserver copy // replace resolv.conf with a localhost-only nameserver copy
@ -1539,7 +1539,7 @@ func (s *DockerSuite) TestRunResolvconfUpdate(c *testing.T) {
c.Fatalf("Container does not have cleaned/replaced DNS in resolv.conf; expected %q, got %q", expected, string(containerResolv)) c.Fatalf("Container does not have cleaned/replaced DNS in resolv.conf; expected %q, got %q", expected, string(containerResolv))
} }
//6. Test that replacing (as opposed to modifying) resolv.conf triggers an update // 6. Test that replacing (as opposed to modifying) resolv.conf triggers an update
// of containers' resolv.conf. // of containers' resolv.conf.
// Restore the original resolv.conf // Restore the original resolv.conf
@ -1570,7 +1570,7 @@ func (s *DockerSuite) TestRunResolvconfUpdate(c *testing.T) {
c.Fatalf("Stopped container does not have updated resolv.conf; expected\n%q\n got\n%q", tmpResolvConf, string(containerResolv)) c.Fatalf("Stopped container does not have updated resolv.conf; expected\n%q\n got\n%q", tmpResolvConf, string(containerResolv))
} }
//cleanup, restore original resolv.conf happens in defer func() // cleanup, restore original resolv.conf happens in defer func()
} }
func (s *DockerSuite) TestRunAddHost(c *testing.T) { func (s *DockerSuite) TestRunAddHost(c *testing.T) {
@ -1958,7 +1958,7 @@ func (s *DockerSuite) TestRunCidFileCleanupIfEmpty(c *testing.T) {
} }
// #2098 - Docker cidFiles only contain short version of the containerId // #2098 - Docker cidFiles only contain short version of the containerId
//sudo docker run --cidfile /tmp/docker_tesc.cid ubuntu echo "test" // sudo docker run --cidfile /tmp/docker_tesc.cid ubuntu echo "test"
// TestRunCidFile tests that run --cidfile returns the longid // TestRunCidFile tests that run --cidfile returns the longid
func (s *DockerSuite) TestRunCidFileCheckIDLength(c *testing.T) { func (s *DockerSuite) TestRunCidFileCheckIDLength(c *testing.T) {
tmpDir, err := ioutil.TempDir("", "TestRunCidFile") tmpDir, err := ioutil.TempDir("", "TestRunCidFile")
@ -2016,7 +2016,7 @@ func (s *DockerSuite) TestRunInspectMacAddress(c *testing.T) {
// test docker run use an invalid mac address // test docker run use an invalid mac address
func (s *DockerSuite) TestRunWithInvalidMacAddress(c *testing.T) { func (s *DockerSuite) TestRunWithInvalidMacAddress(c *testing.T) {
out, _, err := dockerCmdWithError("run", "--mac-address", "92:d0:c6:0a:29", "busybox") out, _, err := dockerCmdWithError("run", "--mac-address", "92:d0:c6:0a:29", "busybox")
//use an invalid mac address should with an error out // use an invalid mac address should with an error out
if err == nil || !strings.Contains(out, "is not a valid mac address") { if err == nil || !strings.Contains(out, "is not a valid mac address") {
c.Fatalf("run with an invalid --mac-address should with error out") c.Fatalf("run with an invalid --mac-address should with error out")
} }
@ -2148,7 +2148,7 @@ func (s *DockerSuite) TestRunReuseBindVolumeThatIsSymlink(c *testing.T) {
dockerCmd(c, "run", "-v", fmt.Sprintf("%s:"+prefix+"/tmp/test", linkPath), "busybox", "ls", prefix+"/tmp/test") dockerCmd(c, "run", "-v", fmt.Sprintf("%s:"+prefix+"/tmp/test", linkPath), "busybox", "ls", prefix+"/tmp/test")
} }
//GH#10604: Test an "/etc" volume doesn't overlay special bind mounts in container // GH#10604: Test an "/etc" volume doesn't overlay special bind mounts in container
func (s *DockerSuite) TestRunCreateVolumeEtc(c *testing.T) { func (s *DockerSuite) TestRunCreateVolumeEtc(c *testing.T) {
// While Windows supports volumes, it does not support --add-host hence // While Windows supports volumes, it does not support --add-host hence
// this test is not applicable on Windows. // this test is not applicable on Windows.

View File

@ -66,7 +66,7 @@ func (s *DockerSuite) TestSaveAndLoadRepoStdout(c *testing.T) {
buf := make([]byte, 1024) buf := make([]byte, 1024)
n, err := pty.Read(buf) n, err := pty.Read(buf)
assert.NilError(c, err) //could not read tty output assert.NilError(c, err, "could not read tty output")
assert.Assert(c, strings.Contains(string(buf[:n]), "cowardly refusing"), "help output is not being yielded") assert.Assert(c, strings.Contains(string(buf[:n]), "cowardly refusing"), "help output is not being yielded")
} }

View File

@ -36,19 +36,19 @@ func (s *DockerSuite) TestSearchCmdOptions(c *testing.T) {
outSearchCmd, _ := dockerCmd(c, "search", "busybox") outSearchCmd, _ := dockerCmd(c, "search", "busybox")
assert.Assert(c, strings.Count(outSearchCmd, "\n") > 3, outSearchCmd) assert.Assert(c, strings.Count(outSearchCmd, "\n") > 3, outSearchCmd)
outSearchCmdautomated, _ := dockerCmd(c, "search", "--filter", "is-automated=true", "busybox") //The busybox is a busybox base image, not an AUTOMATED image. outSearchCmdautomated, _ := dockerCmd(c, "search", "--filter", "is-automated=true", "busybox") // The busybox is a busybox base image, not an AUTOMATED image.
outSearchCmdautomatedSlice := strings.Split(outSearchCmdautomated, "\n") outSearchCmdautomatedSlice := strings.Split(outSearchCmdautomated, "\n")
for i := range outSearchCmdautomatedSlice { for i := range outSearchCmdautomatedSlice {
assert.Assert(c, !strings.HasPrefix(outSearchCmdautomatedSlice[i], "busybox "), "The busybox is not an AUTOMATED image: %s", outSearchCmdautomated) assert.Assert(c, !strings.HasPrefix(outSearchCmdautomatedSlice[i], "busybox "), "The busybox is not an AUTOMATED image: %s", outSearchCmdautomated)
} }
outSearchCmdNotOfficial, _ := dockerCmd(c, "search", "--filter", "is-official=false", "busybox") //The busybox is a busybox base image, official image. outSearchCmdNotOfficial, _ := dockerCmd(c, "search", "--filter", "is-official=false", "busybox") // The busybox is a busybox base image, official image.
outSearchCmdNotOfficialSlice := strings.Split(outSearchCmdNotOfficial, "\n") outSearchCmdNotOfficialSlice := strings.Split(outSearchCmdNotOfficial, "\n")
for i := range outSearchCmdNotOfficialSlice { for i := range outSearchCmdNotOfficialSlice {
assert.Assert(c, !strings.HasPrefix(outSearchCmdNotOfficialSlice[i], "busybox "), "The busybox is not an OFFICIAL image: %s", outSearchCmdNotOfficial) assert.Assert(c, !strings.HasPrefix(outSearchCmdNotOfficialSlice[i], "busybox "), "The busybox is not an OFFICIAL image: %s", outSearchCmdNotOfficial)
} }
outSearchCmdOfficial, _ := dockerCmd(c, "search", "--filter", "is-official=true", "busybox") //The busybox is a busybox base image, official image. outSearchCmdOfficial, _ := dockerCmd(c, "search", "--filter", "is-official=true", "busybox") // The busybox is a busybox base image, official image.
outSearchCmdOfficialSlice := strings.Split(outSearchCmdOfficial, "\n") outSearchCmdOfficialSlice := strings.Split(outSearchCmdOfficial, "\n")
assert.Equal(c, len(outSearchCmdOfficialSlice), 3) // 1 header, 1 line, 1 carriage return assert.Equal(c, len(outSearchCmdOfficialSlice), 3) // 1 header, 1 line, 1 carriage return
assert.Assert(c, strings.HasPrefix(outSearchCmdOfficialSlice[1], "busybox "), "The busybox is an OFFICIAL image: %s", outSearchCmdOfficial) assert.Assert(c, strings.HasPrefix(outSearchCmdOfficialSlice[1], "busybox "), "The busybox is an OFFICIAL image: %s", outSearchCmdOfficial)