Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions test/assets/multus-network.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<network>
<name>${VM_MULTUS_NETWORK}</name>
<forward mode='nat'/>
<ip address='192.168.112.1' netmask='255.255.255.0' localPtr='yes'>
<dhcp>
<range start='192.168.112.100' end='192.168.112.254'/>
</dhcp>
</ip>
</network>
20 changes: 20 additions & 0 deletions test/assets/multus/ipvlan-nad.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: "k8s.cni.cncf.io/v1"
kind: NetworkAttachmentDefinition
metadata:
name: ipvlan-conf
spec:
config: '{
"cniVersion": "0.4.0",
"name": "test",
"type": "ipvlan",
"master": "enp2s0",
"mode": "l2",
"ipam": {
"type": "static",
"addresses": [
{
"address": "192.168.112.2/24"
}
]
}
}'
28 changes: 28 additions & 0 deletions test/assets/multus/ipvlan-pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
kind: Pod
apiVersion: v1
metadata:
name: test-ipvlan
annotations:
k8s.v1.cni.cncf.io/networks: ipvlan-conf
labels:
app: test-ipvlan
spec:
terminationGracePeriodSeconds: 0
containers:
- name: hello-microshift
image: quay.io/microshift/busybox:1.36
command: ["/bin/sh"]
args: ["-c", "while true; do echo -ne \"HTTP/1.0 200 OK\r\nContent-Length: 16\r\n\r\nHello MicroShift\" | nc -l -p 8080 ; done"]
ports:
- containerPort: 8080
protocol: TCP
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
runAsNonRoot: true
runAsUser: 1001
runAsGroup: 1001
seccompProfile:
type: RuntimeDefault
4 changes: 4 additions & 0 deletions test/bin/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ VM_DISK_BASEDIR="${IMAGEDIR}/${VM_POOL_BASENAME}"
# shellcheck disable=SC2034 # used elsewhere
export VM_ISOLATED_NETWORK="isolated"

# Libvirt network for Multus tests
# shellcheck disable=SC2034 # used elsewhere
export VM_MULTUS_NETWORK="multus"

# Location of RPMs built from source
# shellcheck disable=SC2034 # used elsewhere
RPM_SOURCE="${OUTPUTDIR}/rpmbuild"
Expand Down
14 changes: 13 additions & 1 deletion test/bin/manage_hypervisor_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ firewall_settings() {

sudo firewall-cmd --permanent --zone=libvirt "--${action}-service=mdns"

for netname in default "${VM_ISOLATED_NETWORK}" ; do
for netname in default "${VM_ISOLATED_NETWORK}" "${VM_MULTUS_NETWORK}" ; do
if ! sudo virsh net-info "${netname}" &>/dev/null ; then
continue
fi
Expand Down Expand Up @@ -67,6 +67,18 @@ action_create() {
sudo virsh net-autostart "${VM_ISOLATED_NETWORK}"
fi

if ! sudo sudo virsh net-info "${VM_MULTUS_NETWORK}" &>/dev/null ; then
local -r multus_netconfig_tmpl="${SCRIPTDIR}/../assets/multus-network.xml"
local -r multus_netconfig_file="${IMAGEDIR}/infra/multus-network.xml"

mkdir -p "$(dirname "${multus_netconfig_file}")"
envsubst <"${multus_netconfig_tmpl}" >"${multus_netconfig_file}"

sudo virsh net-define "${multus_netconfig_file}"
sudo virsh net-start "${VM_MULTUS_NETWORK}"
sudo virsh net-autostart "${VM_MULTUS_NETWORK}"
fi

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we need to make this code more generic. Here's what I have on my machine as a range.

$ sudo virsh net-dumpxml default | grep -A4 'ip address'
  <ip address='192.168.100.1' netmask='255.255.255.0' localPtr='yes'>
    <dhcp>
      <range start='192.168.100.100' end='192.168.100.254'/>
    </dhcp>
  </ip>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have an isolated-network.xml, which we define for a special case.
I would add a special case new network for this test, rather than changing the default.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed according to the suggestion

# Firewall
firewall_settings "add"
}
Expand Down
8 changes: 7 additions & 1 deletion test/scenarios-periodics/el92-src@optional.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

# Sourced from scenario.sh and uses functions defined there.

# Redefine network-related settings to use the dedicated network bridge
VM_BRIDGE_IP="$(get_vm_bridge_ip "${VM_MULTUS_NETWORK}")"
# shellcheck disable=SC2034 # used elsewhere
WEB_SERVER_URL="http://${VM_BRIDGE_IP}:${WEB_SERVER_PORT}"

scenario_create_vms() {
prepare_kickstart host1 kickstart.ks.template rhel-9.2-microshift-source-optionals
launch_vm host1
# Two nics - one for macvlan, another for ipvlan (they cannot enslave the same interface)
launch_vm host1 "" "${VM_MULTUS_NETWORK}" "" "" "" 2
}

scenario_remove_vms() {
Expand Down
18 changes: 17 additions & 1 deletion test/suites/optional/multus.robot
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ ${MACVLAN_NAD_YAML} ./assets/multus/macvlan-nad.yaml
${MACVLAN_POD_YAML} ./assets/multus/macvlan-pod.yaml
${MACVLAN_POD_NAME} test-macvlan

${IPVLAN_NAD_YAML} ./assets/multus/ipvlan-nad.yaml
${IPVLAN_POD_YAML} ./assets/multus/ipvlan-pod.yaml
${IPVLAN_POD_NAME} test-ipvlan


*** Test Cases ***
Pre-Existing Bridge Interface
Expand Down Expand Up @@ -83,6 +87,18 @@ Macvlan

[Teardown] Remove NAD And Pod ${MACVLAN_NAD_YAML} ${MACVLAN_POD_YAML}

Ipvlan
[Documentation] Tests if Pod with ipvlan plugin interface is accessible
... from outside the MicroShift host.
[Setup] Run Keywords
... Create NAD And Pod ${IPVLAN_NAD_YAML} ${IPVLAN_POD_YAML}
... AND
... Named Pod Should Be Ready ${IPVLAN_POD_NAME} ${NAMESPACE}

Connect To Pod From The Hypervisor ${IPVLAN_POD_NAME} ${NAMESPACE} ${NAMESPACE}/ipvlan-conf

[Teardown] Remove NAD And Pod ${IPVLAN_NAD_YAML} ${IPVLAN_POD_YAML}


*** Keywords ***
Create NAD And Pod
Expand Down Expand Up @@ -122,7 +138,7 @@ Connect To Pod From The Hypervisor

${networks}= Get And Verify Pod Networks ${pod} ${ns} ${extra_cni_name}
${extra_ip}= Set Variable ${networks}[1][ips][0]
Should Contain ${extra_ip} 192.168.122
Should Contain ${extra_ip} 192.168.112

${result}= Process.Run Process curl -v ${extra_ip}:8080
Should Contain ${result.stdout} Hello MicroShift
Expand Down