1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #39358 from jim-docker/testForIpvlan

For ipvlan tests, check that the ipvlan module is there, rather than just testing the kernel version.
This commit is contained in:
Kirill Kolyshkin 2019-06-24 15:33:19 -07:00 committed by GitHub
commit 67be90dcec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,7 +4,10 @@ package ipvlan
import ( import (
"context" "context"
"os"
"os/exec"
"strings" "strings"
"sync"
"testing" "testing"
"time" "time"
@ -21,7 +24,7 @@ func TestDockerNetworkIpvlanPersistance(t *testing.T) {
// verify the driver automatically provisions the 802.1q link (di-dummy0.70) // verify the driver automatically provisions the 802.1q link (di-dummy0.70)
skip.If(t, testEnv.DaemonInfo.OSType == "windows") skip.If(t, testEnv.DaemonInfo.OSType == "windows")
skip.If(t, testEnv.IsRemoteDaemon) skip.If(t, testEnv.IsRemoteDaemon)
skip.If(t, !ipvlanKernelSupport(), "Kernel doesn't support ipvlan") skip.If(t, !ipvlanKernelSupport(t), "Kernel doesn't support ipvlan")
d := daemon.New(t, daemon.WithExperimental) d := daemon.New(t, daemon.WithExperimental)
d.StartWithBusybox(t) d.StartWithBusybox(t)
@ -49,7 +52,7 @@ func TestDockerNetworkIpvlanPersistance(t *testing.T) {
func TestDockerNetworkIpvlan(t *testing.T) { func TestDockerNetworkIpvlan(t *testing.T) {
skip.If(t, testEnv.DaemonInfo.OSType == "windows") skip.If(t, testEnv.DaemonInfo.OSType == "windows")
skip.If(t, testEnv.IsRemoteDaemon) skip.If(t, testEnv.IsRemoteDaemon)
skip.If(t, !ipvlanKernelSupport(), "Kernel doesn't support ipvlan") skip.If(t, !ipvlanKernelSupport(t), "Kernel doesn't support ipvlan")
for _, tc := range []struct { for _, tc := range []struct {
name string name string
@ -425,7 +428,23 @@ func testIpvlanAddressing(client dclient.APIClient) func(*testing.T) {
} }
} }
// ensure Kernel version is >= v4.2 for ipvlan support var (
func ipvlanKernelSupport() bool { once sync.Once
return n.CheckKernelMajorVersionGreaterOrEqualThen(4, 2) ipvlanSupported bool
)
// figure out if ipvlan is supported by the kernel
func ipvlanKernelSupport(t *testing.T) bool {
once.Do(func() {
// this may have the side effect of enabling the ipvlan module
exec.Command("modprobe", "ipvlan").Run()
_, err := os.Stat("/sys/module/ipvlan")
if err == nil {
ipvlanSupported = true
} else if !os.IsNotExist(err) {
t.Logf("WARNING: ipvlanKernelSupport: stat failed: %v\n", err)
}
})
return ipvlanSupported
} }