Skip to content

Commit

Permalink
For ipvlan tests check that the ipvlan module is enabled (instead of …
Browse files Browse the repository at this point in the history
…just ensuring the kernel version is greater than 4.2)

Co-Authored-By: Jim Ehrismann <jim-docker@users.noreply.github.com>
Co-Authored-By: Sebastiaan van Stijn <thaJeztah@users.noreply.github.com>
Signed-off-by: Jim Ehrismann <jim.ehrismann@docker.com>
  • Loading branch information
3 people authored and Jim Ehrismann committed Jun 14, 2019
1 parent 71e0057 commit a77e147
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions integration/network/ipvlan/ipvlan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ package ipvlan

import (
"context"
"os"
"os/exec"
"strings"
"sync"
"testing"
"time"

Expand All @@ -21,7 +24,7 @@ func TestDockerNetworkIpvlanPersistance(t *testing.T) {
// verify the driver automatically provisions the 802.1q link (di-dummy0.70)
skip.If(t, testEnv.DaemonInfo.OSType == "windows")
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.StartWithBusybox(t)
Expand Down Expand Up @@ -49,7 +52,7 @@ func TestDockerNetworkIpvlanPersistance(t *testing.T) {
func TestDockerNetworkIpvlan(t *testing.T) {
skip.If(t, testEnv.DaemonInfo.OSType == "windows")
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 {
name string
Expand Down Expand Up @@ -425,7 +428,23 @@ func testIpvlanAddressing(client dclient.APIClient) func(*testing.T) {
}
}

// ensure Kernel version is >= v4.2 for ipvlan support
func ipvlanKernelSupport() bool {
return n.CheckKernelMajorVersionGreaterOrEqualThen(4, 2)
var (
once sync.Once
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
}

0 comments on commit a77e147

Please sign in to comment.