Skip to content

Commit

Permalink
ci, e2e tests: override the lower device name via env var
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
  • Loading branch information
maiqueb committed Nov 4, 2022
1 parent 146514e commit 5a51952
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/e2e-containerd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
- name: Run e2e tests
env:
KUBECONFIG: /home/runner/.kube/config
LOWER_DEVICE: eth1
run: make e2e/test

- name: Cleanup cluster
Expand Down
23 changes: 17 additions & 6 deletions e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ func TestDynamicNetworksControllerE2E(t *testing.T) {

var _ = Describe("Multus dynamic networks controller", func() {
const (
defaultLowerDeviceIfaceName = "eth0"
namespace = "ns1"
networkName = "tenant-network"
podName = "tiny-winy-pod"
namespace = "ns1"
networkName = "tenant-network"
podName = "tiny-winy-pod"
)
var clients *client.E2EClient

Expand All @@ -47,7 +46,7 @@ var _ = Describe("Multus dynamic networks controller", func() {
BeforeEach(func() {
_, err := clients.AddNamespace(namespace)
Expect(err).NotTo(HaveOccurred())
_, err = clients.AddNetAttachDef(macvlanNetworkWithoutIPAM(networkName, namespace, defaultLowerDeviceIfaceName))
_, err = clients.AddNetAttachDef(macvlanNetworkWithoutIPAM(networkName, namespace, lowerDeviceName()))
Expect(err).NotTo(HaveOccurred())
})

Expand Down Expand Up @@ -131,7 +130,7 @@ var _ = Describe("Multus dynamic networks controller", func() {
macAddress := "02:03:04:05:06:07"

BeforeEach(func() {
_, err := clients.AddNetAttachDef(macvlanNetworkWitStaticIPAM(ipamNetworkToAdd, namespace, defaultLowerDeviceIfaceName))
_, err := clients.AddNetAttachDef(macvlanNetworkWitStaticIPAM(ipamNetworkToAdd, namespace, lowerDeviceName()))
Expect(err).NotTo(HaveOccurred())
Expect(clients.AddNetworkToPod(pod, &nettypes.NetworkSelectionElement{
Name: ipamNetworkToAdd,
Expand Down Expand Up @@ -329,3 +328,15 @@ func namespacedName(namespace, name string) string {
func ipWithMask(ip string, netmaskLen int) string {
return fmt.Sprintf("%s/%d", ip, netmaskLen)
}

func lowerDeviceName() string {
const (
defaultLowerDeviceIfaceName = "eth0"
lowerDeviceEnvVarKeyName = "LOWER_DEVICE"
)

if lowerDeviceIfaceName, wasFound := os.LookupEnv(lowerDeviceEnvVarKeyName); wasFound {
return lowerDeviceIfaceName
}
return defaultLowerDeviceIfaceName
}

0 comments on commit 5a51952

Please sign in to comment.