Skip to content

Commit

Permalink
Support running integration tests on macOS
Browse files Browse the repository at this point in the history
Since `make docker-test-integration` runs the integration tests in a
Docker image, it is reasonnable to expect that one may be able to run
these tests on macOS (Docker Desktop). This required the following 2
changes:

 * OVS bridges should use the netdev datpath type, since the kernel
   datapath does not seem to be available in the KyperKit VM.
 * The HyperKit VM seems to enable ipip, which means that some extra
   tunnel interfaces are created in the network namepsaces that our
   tests create inside the Docker container. As a result our CNI
   integration tests need to be "relaxed" to accomodate for these.

Fixes #783
  • Loading branch information
antoninbas committed Jun 4, 2020
1 parent 97bac64 commit 1ee4992
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
16 changes: 15 additions & 1 deletion test/integration/agent/cniserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,21 @@ func (tester *cmdAddDelTester) cmdAddTest(tc testCase, dataDir string) (*current
return err
})
testRequire.Nil(err)
testRequire.Len(linkList, 2)
// when running the integration tests in a Docker image on macOS (Docker
// Desktop), we observe that the namespace includes 4 links, not 2
// (localhost and veth). It seems that the HyperKit Linux VM loads the
// ipip module, which means that the Linux Kernel creates 2 extra
// interfaces in each namespace (tunl0 and ip6tnl).
testRequire.GreaterOrEqual(len(linkList), 2)
// check that the list includes the eth0 veth
vethFound := false
for _, link := range linkList {
if link.Type() == "veth" && link.Attrs().Name == IFName {
vethFound = true
break
}
}
testRequire.Truef(vethFound, "Missing '%s' veth in target namespace", IFName)

// Find the veth peer in the container namespace and the default route.
tester.checkContainerNetworking(tc)
Expand Down
5 changes: 4 additions & 1 deletion test/integration/ovs/openflow_test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ import (
)

func PrepareOVSBridge(brName string) error {
cmdStr := fmt.Sprintf("ovs-vsctl --may-exist add-br %s -- set Bridge %s protocols='OpenFlow10,OpenFlow13'", brName, brName)
// using the netdev datapath type does not impact test coverage but
// ensures that the integration tests can be run with Docker Desktop on
// macOS.
cmdStr := fmt.Sprintf("ovs-vsctl --may-exist add-br %s -- set Bridge %s protocols='OpenFlow10,OpenFlow13' datapath_type=netdev", brName, brName)
err := exec.Command("/bin/sh", "-c", cmdStr).Run()
if err != nil {
return err
Expand Down
5 changes: 4 additions & 1 deletion test/integration/ovs/ovs_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ func (data *testData) setup(t *testing.T) {
t.Fatalf("Could not establish connection to %s after %s", UDSAddress, defaultConnectTimeout)
}

data.br = ovsconfig.NewOVSBridge(bridgeName, "system", data.ovsdb)
// using the netdev datapath type does not impact test coverage but
// ensures that the integration tests can be run with Docker Desktop on
// macOS.
data.br = ovsconfig.NewOVSBridge(bridgeName, "netdev", data.ovsdb)
err = data.br.Create()
require.Nil(t, err, "Failed to create bridge %s", bridgeName)
}
Expand Down

0 comments on commit 1ee4992

Please sign in to comment.