Browse code

Ensure test graphdriver plugin runs on test host

Sets a kernel requirement for for `TestGraphdriverPlugin` since the
graphdriver being used is overlay2.. and also makes sure to skip the
kernel check in the actual graphdriver since we may be able to detect
kernels with backported support for overlay2 style mounts a bit more
freely in the test code.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>

Brian Goff authored on 2016/12/20 00:59:54
Showing 3 changed files
... ...
@@ -236,7 +236,7 @@ func (s *DockerDaemonSuite) TestVolumePlugin(c *check.C) {
236 236
 }
237 237
 
238 238
 func (s *DockerDaemonSuite) TestGraphdriverPlugin(c *check.C) {
239
-	testRequires(c, Network, IsAmd64, DaemonIsLinux, overlaySupported)
239
+	testRequires(c, Network, IsAmd64, DaemonIsLinux, overlay2Supported)
240 240
 
241 241
 	s.d.Start(c)
242 242
 
... ...
@@ -246,7 +246,7 @@ func (s *DockerDaemonSuite) TestGraphdriverPlugin(c *check.C) {
246 246
 	c.Assert(err, checker.IsNil, check.Commentf(out))
247 247
 
248 248
 	// restart the daemon with the plugin set as the storage driver
249
-	s.d.Restart(c, "-s", plugin)
249
+	s.d.Restart(c, "-s", plugin, "--storage-opt", "overlay2.override_kernel_check=1")
250 250
 
251 251
 	// run a container
252 252
 	out, err = s.d.Cmd("run", "--rm", "busybox", "true") // this will pull busybox using the plugin
... ...
@@ -66,6 +66,8 @@ var (
66 66
 
67 67
 	// daemonPid is the pid of the main test daemon
68 68
 	daemonPid int
69
+
70
+	daemonKernelVersion string
69 71
 )
70 72
 
71 73
 func init() {
... ...
@@ -111,6 +113,7 @@ func init() {
111 111
 	type Info struct {
112 112
 		DockerRootDir     string
113 113
 		ExperimentalBuild bool
114
+		KernelVersion     string
114 115
 	}
115 116
 	var i Info
116 117
 	status, b, err := sockRequest("GET", "/info", nil)
... ...
@@ -118,6 +121,7 @@ func init() {
118 118
 		if err = json.Unmarshal(b, &i); err == nil {
119 119
 			dockerBasePath = i.DockerRootDir
120 120
 			experimentalDaemon = i.ExperimentalBuild
121
+			daemonKernelVersion = i.KernelVersion
121 122
 		}
122 123
 	}
123 124
 	volumesConfigPath = dockerBasePath + "/volumes"
... ...
@@ -8,6 +8,7 @@ import (
8 8
 	"os/exec"
9 9
 	"strings"
10 10
 
11
+	"github.com/docker/docker/pkg/parsers/kernel"
11 12
 	"github.com/docker/docker/pkg/sysinfo"
12 13
 )
13 14
 
... ...
@@ -124,7 +125,7 @@ var (
124 124
 		},
125 125
 		"Test cannot be run without a kernel (4.3+) supporting ambient capabilities",
126 126
 	}
127
-	overlaySupported = testRequirement{
127
+	overlayFSSupported = testRequirement{
128 128
 		func() bool {
129 129
 			cmd := exec.Command(dockerBinary, "run", "--rm", "busybox", "/bin/sh", "-c", "cat /proc/filesystems")
130 130
 			out, err := cmd.CombinedOutput()
... ...
@@ -133,7 +134,23 @@ var (
133 133
 			}
134 134
 			return bytes.Contains(out, []byte("overlay\n"))
135 135
 		},
136
-		"Test cannot be run wihtout suppport for ovelayfs",
136
+		"Test cannot be run without suppport for overlayfs",
137
+	}
138
+	overlay2Supported = testRequirement{
139
+		func() bool {
140
+			if !overlayFSSupported.Condition() {
141
+				return false
142
+			}
143
+
144
+			daemonV, err := kernel.ParseRelease(daemonKernelVersion)
145
+			if err != nil {
146
+				return false
147
+			}
148
+			requiredV := kernel.VersionInfo{Kernel: 4}
149
+			return kernel.CompareKernelVersion(*daemonV, requiredV) > -1
150
+
151
+		},
152
+		"Test cannot be run without overlay2 support (kernel 4.0+)",
137 153
 	}
138 154
 )
139 155