зеркало из https://github.com/microsoft/docker.git
Set integration test OSType with environment variable
Signed-off-by: Christopher Crone <christopher.crone@docker.com>
This commit is contained in:
Родитель
7cbbbb9509
Коммит
f0e5b3d7d8
|
@ -30,7 +30,7 @@ func ensureHTTPServerImage(t testingT) {
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(tmp)
|
defer os.RemoveAll(tmp)
|
||||||
|
|
||||||
goos := testEnv.DaemonInfo.OSType
|
goos := testEnv.OSType
|
||||||
if goos == "" {
|
if goos == "" {
|
||||||
goos = "linux"
|
goos = "linux"
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ func Docker(cmd icmd.Cmd, cmdOperators ...CmdOperator) *icmd.Result {
|
||||||
// validateArgs is a checker to ensure tests are not running commands which are
|
// validateArgs is a checker to ensure tests are not running commands which are
|
||||||
// not supported on platforms. Specifically on Windows this is 'busybox top'.
|
// not supported on platforms. Specifically on Windows this is 'busybox top'.
|
||||||
func validateArgs(args ...string) error {
|
func validateArgs(args ...string) error {
|
||||||
if testEnv.DaemonInfo.OSType != "windows" {
|
if testEnv.OSType != "windows" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
foundBusybox := -1
|
foundBusybox := -1
|
||||||
|
|
|
@ -67,9 +67,9 @@ func (e *Execution) ExperimentalDaemon() bool {
|
||||||
// decisions on how to configure themselves according to the platform
|
// decisions on how to configure themselves according to the platform
|
||||||
// of the daemon. This is initialized in docker_utils by sending
|
// of the daemon. This is initialized in docker_utils by sending
|
||||||
// a version call to the daemon and examining the response header.
|
// a version call to the daemon and examining the response header.
|
||||||
// Deprecated: use Execution.DaemonInfo.OSType
|
// Deprecated: use Execution.OSType
|
||||||
func (e *Execution) DaemonPlatform() string {
|
func (e *Execution) DaemonPlatform() string {
|
||||||
return e.DaemonInfo.OSType
|
return e.OSType
|
||||||
}
|
}
|
||||||
|
|
||||||
// MinimalBaseImage is the image used for minimal builds (it depends on the platform)
|
// MinimalBaseImage is the image used for minimal builds (it depends on the platform)
|
||||||
|
|
|
@ -21,12 +21,12 @@ func ArchitectureIsNot(arch string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func DaemonIsWindows() bool {
|
func DaemonIsWindows() bool {
|
||||||
return testEnv.DaemonInfo.OSType == "windows"
|
return testEnv.OSType == "windows"
|
||||||
}
|
}
|
||||||
|
|
||||||
func DaemonIsWindowsAtLeastBuild(buildNumber int) func() bool {
|
func DaemonIsWindowsAtLeastBuild(buildNumber int) func() bool {
|
||||||
return func() bool {
|
return func() bool {
|
||||||
if testEnv.DaemonInfo.OSType != "windows" {
|
if testEnv.OSType != "windows" {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
version := testEnv.DaemonInfo.KernelVersion
|
version := testEnv.DaemonInfo.KernelVersion
|
||||||
|
@ -36,7 +36,7 @@ func DaemonIsWindowsAtLeastBuild(buildNumber int) func() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func DaemonIsLinux() bool {
|
func DaemonIsLinux() bool {
|
||||||
return testEnv.DaemonInfo.OSType == "linux"
|
return testEnv.OSType == "linux"
|
||||||
}
|
}
|
||||||
|
|
||||||
func OnlyDefaultNetworks() bool {
|
func OnlyDefaultNetworks() bool {
|
||||||
|
@ -178,21 +178,21 @@ func UserNamespaceInKernel() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsPausable() bool {
|
func IsPausable() bool {
|
||||||
if testEnv.DaemonInfo.OSType == "windows" {
|
if testEnv.OSType == "windows" {
|
||||||
return testEnv.DaemonInfo.Isolation == "hyperv"
|
return testEnv.DaemonInfo.Isolation == "hyperv"
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func NotPausable() bool {
|
func NotPausable() bool {
|
||||||
if testEnv.DaemonInfo.OSType == "windows" {
|
if testEnv.OSType == "windows" {
|
||||||
return testEnv.DaemonInfo.Isolation == "process"
|
return testEnv.DaemonInfo.Isolation == "process"
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsolationIs(expectedIsolation string) bool {
|
func IsolationIs(expectedIsolation string) bool {
|
||||||
return testEnv.DaemonInfo.OSType == "windows" && string(testEnv.DaemonInfo.Isolation) == expectedIsolation
|
return testEnv.OSType == "windows" && string(testEnv.DaemonInfo.Isolation) == expectedIsolation
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsolationIsHyperv() bool {
|
func IsolationIsHyperv() bool {
|
||||||
|
|
|
@ -20,5 +20,5 @@ func TestVersion(t *testing.T) {
|
||||||
assert.NotNil(t, version.Version)
|
assert.NotNil(t, version.Version)
|
||||||
assert.NotNil(t, version.MinAPIVersion)
|
assert.NotNil(t, version.MinAPIVersion)
|
||||||
assert.Equal(t, testEnv.DaemonInfo.ExperimentalBuild, version.Experimental)
|
assert.Equal(t, testEnv.DaemonInfo.ExperimentalBuild, version.Experimental)
|
||||||
assert.Equal(t, testEnv.DaemonInfo.OSType, version.Os)
|
assert.Equal(t, testEnv.OSType, version.Os)
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ type logT interface {
|
||||||
func (e *Execution) Clean(t testingT) {
|
func (e *Execution) Clean(t testingT) {
|
||||||
client := e.APIClient()
|
client := e.APIClient()
|
||||||
|
|
||||||
platform := e.DaemonInfo.OSType
|
platform := e.OSType
|
||||||
if (platform != "windows") || (platform == "windows" && e.DaemonInfo.Isolation == "hyperv") {
|
if (platform != "windows") || (platform == "windows" && e.DaemonInfo.Isolation == "hyperv") {
|
||||||
unpauseAllContainers(t, client)
|
unpauseAllContainers(t, client)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ import (
|
||||||
type Execution struct {
|
type Execution struct {
|
||||||
client client.APIClient
|
client client.APIClient
|
||||||
DaemonInfo types.Info
|
DaemonInfo types.Info
|
||||||
|
OSType string
|
||||||
PlatformDefaults PlatformDefaults
|
PlatformDefaults PlatformDefaults
|
||||||
protectedElements protectedElements
|
protectedElements protectedElements
|
||||||
}
|
}
|
||||||
|
@ -40,19 +41,31 @@ func New() (*Execution, error) {
|
||||||
return nil, errors.Wrapf(err, "failed to get info from daemon")
|
return nil, errors.Wrapf(err, "failed to get info from daemon")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
osType := getOSType(info)
|
||||||
|
|
||||||
return &Execution{
|
return &Execution{
|
||||||
client: client,
|
client: client,
|
||||||
DaemonInfo: info,
|
DaemonInfo: info,
|
||||||
PlatformDefaults: getPlatformDefaults(info),
|
OSType: osType,
|
||||||
|
PlatformDefaults: getPlatformDefaults(info, osType),
|
||||||
protectedElements: newProtectedElements(),
|
protectedElements: newProtectedElements(),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getPlatformDefaults(info types.Info) PlatformDefaults {
|
func getOSType(info types.Info) string {
|
||||||
|
// Docker EE does not set the OSType so allow the user to override this value.
|
||||||
|
userOsType := os.Getenv("TEST_OSTYPE")
|
||||||
|
if userOsType != "" {
|
||||||
|
return userOsType
|
||||||
|
}
|
||||||
|
return info.OSType
|
||||||
|
}
|
||||||
|
|
||||||
|
func getPlatformDefaults(info types.Info, osType string) PlatformDefaults {
|
||||||
volumesPath := filepath.Join(info.DockerRootDir, "volumes")
|
volumesPath := filepath.Join(info.DockerRootDir, "volumes")
|
||||||
containersPath := filepath.Join(info.DockerRootDir, "containers")
|
containersPath := filepath.Join(info.DockerRootDir, "containers")
|
||||||
|
|
||||||
switch info.OSType {
|
switch osType {
|
||||||
case "linux":
|
case "linux":
|
||||||
return PlatformDefaults{
|
return PlatformDefaults{
|
||||||
BaseImage: "scratch",
|
BaseImage: "scratch",
|
||||||
|
@ -71,7 +84,7 @@ func getPlatformDefaults(info types.Info) PlatformDefaults {
|
||||||
ContainerStoragePath: filepath.FromSlash(containersPath),
|
ContainerStoragePath: filepath.FromSlash(containersPath),
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("unknown info.OSType for daemon: %s", info.OSType))
|
panic(fmt.Sprintf("unknown OSType for daemon: %s", osType))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ func ProtectAll(t testingT, testEnv *Execution) {
|
||||||
ProtectImages(t, testEnv)
|
ProtectImages(t, testEnv)
|
||||||
ProtectNetworks(t, testEnv)
|
ProtectNetworks(t, testEnv)
|
||||||
ProtectVolumes(t, testEnv)
|
ProtectVolumes(t, testEnv)
|
||||||
if testEnv.DaemonInfo.OSType == "linux" {
|
if testEnv.OSType == "linux" {
|
||||||
ProtectPlugins(t, testEnv)
|
ProtectPlugins(t, testEnv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ func (e *Execution) ProtectImage(t testingT, images ...string) {
|
||||||
func ProtectImages(t testingT, testEnv *Execution) {
|
func ProtectImages(t testingT, testEnv *Execution) {
|
||||||
images := getExistingImages(t, testEnv)
|
images := getExistingImages(t, testEnv)
|
||||||
|
|
||||||
if testEnv.DaemonInfo.OSType == "linux" {
|
if testEnv.OSType == "linux" {
|
||||||
images = append(images, ensureFrozenImagesLinux(t, testEnv)...)
|
images = append(images, ensureFrozenImagesLinux(t, testEnv)...)
|
||||||
}
|
}
|
||||||
testEnv.ProtectImage(t, images...)
|
testEnv.ProtectImage(t, images...)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче