Signed-off-by: Mohammed Aaqib Ansari <maaquib@gmail.com>
| ... | ... |
@@ -11,6 +11,7 @@ import ( |
| 11 | 11 |
"strconv" |
| 12 | 12 |
"strings" |
| 13 | 13 |
|
| 14 |
+ "github.com/docker/docker/pkg/integration/checker" |
|
| 14 | 15 |
"github.com/docker/docker/pkg/system" |
| 15 | 16 |
"github.com/go-check/check" |
| 16 | 17 |
) |
| ... | ... |
@@ -19,14 +20,12 @@ func (s *DockerSuite) TestExperimentalVersion(c *check.C) {
|
| 19 | 19 |
out, _ := dockerCmd(c, "version") |
| 20 | 20 |
for _, line := range strings.Split(out, "\n") {
|
| 21 | 21 |
if strings.HasPrefix(line, "Experimental (client):") || strings.HasPrefix(line, "Experimental (server):") {
|
| 22 |
- c.Assert(line, check.Matches, "*true") |
|
| 22 |
+ c.Assert(line, checker.Matches, "*true") |
|
| 23 | 23 |
} |
| 24 | 24 |
} |
| 25 | 25 |
|
| 26 | 26 |
out, _ = dockerCmd(c, "-v") |
| 27 |
- if !strings.Contains(out, ", experimental") {
|
|
| 28 |
- c.Fatalf("docker version did not contain experimental: %s", out)
|
|
| 29 |
- } |
|
| 27 |
+ c.Assert(out, checker.Contains, ", experimental", check.Commentf("docker version did not contain experimental"))
|
|
| 30 | 28 |
} |
| 31 | 29 |
|
| 32 | 30 |
// user namespaces test: run daemon with remapped root setting |
| ... | ... |
@@ -36,49 +35,43 @@ func (s *DockerDaemonSuite) TestDaemonUserNamespaceRootSetting(c *check.C) {
|
| 36 | 36 |
testRequires(c, NativeExecDriver) |
| 37 | 37 |
testRequires(c, SameHostDaemon) |
| 38 | 38 |
|
| 39 |
- c.Assert(s.d.StartWithBusybox("--userns-remap", "default"), check.IsNil)
|
|
| 39 |
+ c.Assert(s.d.StartWithBusybox("--userns-remap", "default"), checker.IsNil)
|
|
| 40 | 40 |
|
| 41 | 41 |
tmpDir, err := ioutil.TempDir("", "userns")
|
| 42 |
- if err != nil {
|
|
| 43 |
- c.Fatal(err) |
|
| 44 |
- } |
|
| 42 |
+ c.Assert(err, checker.IsNil) |
|
| 45 | 43 |
defer os.RemoveAll(tmpDir) |
| 46 | 44 |
|
| 47 | 45 |
// we need to find the uid and gid of the remapped root from the daemon's root dir info |
| 48 | 46 |
uidgid := strings.Split(filepath.Base(s.d.root), ".") |
| 49 |
- c.Assert(len(uidgid), check.Equals, 2, check.Commentf("Should have gotten uid/gid strings from root dirname: %s", filepath.Base(s.d.root)))
|
|
| 47 |
+ c.Assert(uidgid, checker.HasLen, 2, check.Commentf("Should have gotten uid/gid strings from root dirname: %s", filepath.Base(s.d.root)))
|
|
| 50 | 48 |
uid, err := strconv.Atoi(uidgid[0]) |
| 51 |
- c.Assert(err, check.IsNil, check.Commentf("Can't parse uid: %v", err))
|
|
| 49 |
+ c.Assert(err, checker.IsNil, check.Commentf("Can't parse uid"))
|
|
| 52 | 50 |
gid, err := strconv.Atoi(uidgid[1]) |
| 53 |
- c.Assert(err, check.IsNil, check.Commentf("Can't parse gid: %v", err))
|
|
| 51 |
+ c.Assert(err, checker.IsNil, check.Commentf("Can't parse gid"))
|
|
| 54 | 52 |
|
| 55 | 53 |
//writeable by the remapped root UID/GID pair |
| 56 |
- c.Assert(os.Chown(tmpDir, uid, gid), check.IsNil) |
|
| 54 |
+ c.Assert(os.Chown(tmpDir, uid, gid), checker.IsNil) |
|
| 57 | 55 |
|
| 58 | 56 |
out, err := s.d.Cmd("run", "-d", "--name", "userns", "-v", tmpDir+":/goofy", "busybox", "sh", "-c", "touch /goofy/testfile; top")
|
| 59 |
- c.Assert(err, check.IsNil, check.Commentf("Output: %s", out))
|
|
| 57 |
+ c.Assert(err, checker.IsNil, check.Commentf("Output: %s", out))
|
|
| 60 | 58 |
|
| 61 | 59 |
pid, err := s.d.Cmd("inspect", "--format='{{.State.Pid}}'", "userns")
|
| 62 |
- if err != nil {
|
|
| 63 |
- c.Fatalf("Could not inspect running container: out: %q; err: %v", pid, err)
|
|
| 64 |
- } |
|
| 60 |
+ c.Assert(err, checker.IsNil, check.Commentf("Could not inspect running container: out: %q", pid))
|
|
| 65 | 61 |
// check the uid and gid maps for the PID to ensure root is remapped |
| 66 | 62 |
// (cmd = cat /proc/<pid>/uid_map | grep -E '0\s+9999\s+1') |
| 67 | 63 |
out, rc1, err := runCommandPipelineWithOutput( |
| 68 | 64 |
exec.Command("cat", "/proc/"+strings.TrimSpace(pid)+"/uid_map"),
|
| 69 | 65 |
exec.Command("grep", "-E", fmt.Sprintf("0[[:space:]]+%d[[:space:]]+", uid)))
|
| 70 |
- c.Assert(rc1, check.Equals, 0, check.Commentf("Didn't match uid_map: output: %s", out))
|
|
| 66 |
+ c.Assert(rc1, checker.Equals, 0, check.Commentf("Didn't match uid_map: output: %s", out))
|
|
| 71 | 67 |
|
| 72 | 68 |
out, rc2, err := runCommandPipelineWithOutput( |
| 73 | 69 |
exec.Command("cat", "/proc/"+strings.TrimSpace(pid)+"/gid_map"),
|
| 74 | 70 |
exec.Command("grep", "-E", fmt.Sprintf("0[[:space:]]+%d[[:space:]]+", gid)))
|
| 75 |
- c.Assert(rc2, check.Equals, 0, check.Commentf("Didn't match gid_map: output: %s", out))
|
|
| 71 |
+ c.Assert(rc2, checker.Equals, 0, check.Commentf("Didn't match gid_map: output: %s", out))
|
|
| 76 | 72 |
|
| 77 | 73 |
// check that the touched file is owned by remapped uid:gid |
| 78 | 74 |
stat, err := system.Stat(filepath.Join(tmpDir, "testfile")) |
| 79 |
- if err != nil {
|
|
| 80 |
- c.Fatal(err) |
|
| 81 |
- } |
|
| 82 |
- c.Assert(stat.UID(), check.Equals, uint32(uid), check.Commentf("Touched file not owned by remapped root UID"))
|
|
| 83 |
- c.Assert(stat.GID(), check.Equals, uint32(gid), check.Commentf("Touched file not owned by remapped root GID"))
|
|
| 75 |
+ c.Assert(err, checker.IsNil) |
|
| 76 |
+ c.Assert(stat.UID(), checker.Equals, uint32(uid), check.Commentf("Touched file not owned by remapped root UID"))
|
|
| 77 |
+ c.Assert(stat.GID(), checker.Equals, uint32(gid), check.Commentf("Touched file not owned by remapped root GID"))
|
|
| 84 | 78 |
} |