浏览代码

fix test requirement about devicemapper and not overlay

Signed-off-by: mYmNeo <thomassong@tencent.com>
mYmNeo 9 年之前
父节点
当前提交
90f512427f
共有 3 个文件被更改,包括 8 次插入10 次删除
  1. 5 0
      integration-cli/docker_test_vars.go
  2. 1 0
      integration-cli/docker_utils.go
  3. 2 10
      integration-cli/requirements.go

+ 5 - 0
integration-cli/docker_test_vars.go

@@ -54,6 +54,11 @@ var (
 	dockerBasePath       string
 	volumesConfigPath    string
 	containerStoragePath string
+
+	// daemonStorageDriver is held globally so that tests can know the storage
+	// driver of the daemon. This is initialized in docker_utils by sending
+	// a version call to the daemon and examining the response header.
+	daemonStorageDriver string
 )
 
 const (

+ 1 - 0
integration-cli/docker_utils.go

@@ -67,6 +67,7 @@ func init() {
 		panic(fmt.Errorf("Init failed to unmarshal docker info: %v", err))
 	}
 
+	daemonStorageDriver = info.Driver
 	dockerBasePath = info.DockerRootDir
 	volumesConfigPath = filepath.Join(dockerBasePath, "volumes")
 	containerStoragePath = filepath.Join(dockerBasePath, "containers")

+ 2 - 10
integration-cli/requirements.go

@@ -109,22 +109,14 @@ var (
 	}
 	NotOverlay = testRequirement{
 		func() bool {
-			cmd := exec.Command("grep", "^overlay / overlay", "/proc/mounts")
-			if err := cmd.Run(); err != nil {
-				return true
-			}
-			return false
+			return !strings.HasPrefix(daemonStorageDriver, "overlay")
 		},
 		"Test requires underlying root filesystem not be backed by overlay.",
 	}
 
 	Devicemapper = testRequirement{
 		func() bool {
-			cmd := exec.Command("grep", "^devicemapper / devicemapper", "/proc/mounts")
-			if err := cmd.Run(); err != nil {
-				return false
-			}
-			return true
+			return strings.HasPrefix(daemonStorageDriver, "devicemapper")
 		},
 		"Test requires underlying root filesystem to be backed by devicemapper.",
 	}