diff --git a/Makefile b/Makefile index a29cf39c2..4343caf7e 100644 --- a/Makefile +++ b/Makefile @@ -184,6 +184,9 @@ test-e2e-upgrade: manifests test-e2e: test-e2e-operator test-e2e-handler +test-e2e-ocp: + ./hack/ocp-e2e-tests.sh + cluster-up: ./cluster/up.sh diff --git a/hack/ocp-e2e-tests.sh b/hack/ocp-e2e-tests.sh index b052ee849..9c0fb8848 100755 --- a/hack/ocp-e2e-tests.sh +++ b/hack/ocp-e2e-tests.sh @@ -19,6 +19,22 @@ export PRIMARY_NIC=enp2s0 export FIRST_SECONDARY_NIC=enp3s0 export SECOND_SECONDARY_NIC=enp4s0 +if oc get ns openshift-ovn-kubernetes &> /dev/null; then + # We are using OVNKubernetes -> use enp1s0 as primary nic + export PRIMARY_NIC=enp1s0 +fi + +# Apply machine configs and wait until machine config pools got updated +old_mcp_generation=$(oc get mcp master -o jsonpath={.metadata.generation}) +if oc create -f test/e2e/machineconfigs.yaml; then + # If MCs could be created, wait until the MCP are aware of new machine configs + while [ "$old_mcp_generation" -eq "$(oc get mcp master -o jsonpath={.metadata.generation})" ]; do + echo "waiting for MCP update to start..."; + sleep 1; + done +fi +while ! oc wait mcp --all --for=condition=Updated --timeout -1s; do sleep 1; done + make cluster-sync-operator # Will fail on subsequent runs, this is fine. oc create -f build/_output/manifests/scc.yaml || : diff --git a/test/e2e/machineconfigs.yaml b/test/e2e/machineconfigs.yaml new file mode 100644 index 000000000..5d14309d4 --- /dev/null +++ b/test/e2e/machineconfigs.yaml @@ -0,0 +1,52 @@ +apiVersion: machineconfiguration.openshift.io/v1 +kind: MachineConfig +metadata: + labels: + machineconfiguration.openshift.io/role: master + name: 10-nmstate-hack-master +spec: + config: + ignition: + version: 3.2.0 + systemd: + units: + - contents: | + [Unit] + Description=NMState e2e hack + Wants=crio.service + Before=kubelet.service + After=crio.service + [Service] + Type=oneshot + ExecStart=/bin/bash -c "for i in $(nmcli --fields NAME,UUID -t con show | grep 'Wired Connection' | awk -F : '{print $2}'); do nmcli con modify $i match.interface-name '!enp3s0, !enp4s0'; done" + [Install] + WantedBy=multi-user.target + enabled: true + name: nmstate-hack.service + +--- +apiVersion: machineconfiguration.openshift.io/v1 +kind: MachineConfig +metadata: + labels: + machineconfiguration.openshift.io/role: worker + name: 10-nmstate-hack-worker +spec: + config: + ignition: + version: 3.2.0 + systemd: + units: + - contents: | + [Unit] + Description=NMState e2e hack + Wants=crio.service + Before=kubelet.service + After=crio.service + [Service] + Type=oneshot + ExecStart=/bin/bash -c "for i in $(nmcli --fields NAME,UUID -t con show | grep 'Wired Connection' | awk -F : '{print $2}'); do nmcli con modify $i match.interface-name '!enp3s0, !enp4s0'; done" + [Install] + WantedBy=multi-user.target + enabled: true + name: nmstate-hack.service