Skip to content

Commit 413f443

Browse files
committed
Testsuite: T3871: change testcase to use multiple NIC drivers
Extend testcase to use multiple differen virtual NIC drivers to also see if they are always placed in the same order - given my ascending MAC addresses.
1 parent 7633417 commit 413f443

1 file changed

Lines changed: 37 additions & 7 deletions

File tree

scripts/check-qemu-install

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ tpm_folder = '/tmp/vyos_tpm_test'
8282
tpm_sock = f'{tpm_folder}/swtpm-sock'
8383
qemu_name = 'VyOS-QEMU'
8484

85+
# RFC7042 section 2.1.2 MAC addresses used for documentation
86+
macbase = '00:00:5E:00:53'
87+
8588
test_timeout = 5 *3600 # 5 hours (in seconds) to complete individual testcases
8689

8790
op_mode_prompt = r'vyos@vyos:~\$'
@@ -268,9 +271,6 @@ def get_qemu_cmd(name, enable_uefi, disk_img, raid=None, iso_img=None, tpm=False
268271
else:
269272
nested_cdrom = f'{nested_cdrom} -device ide-cd,bus=achi0.1,{drive_settings}'
270273

271-
# RFC7042 section 2.1.2 MAC addresses used for documentation
272-
macbase = '00:00:5E:00:53'
273-
274274
# Set QEmu disk image format - this differs if VyOS was installed via smoketest
275275
# or we use an already ewxisting image
276276
disk_format = 'qcow2' if args.disk.endswith('.qcow2') else 'raw'
@@ -290,10 +290,10 @@ def get_qemu_cmd(name, enable_uefi, disk_img, raid=None, iso_img=None, tpm=False
290290
-netdev user,id=n1 -device virtio-net-pci,netdev=n1,mac={macbase}:01,romfile="",host_mtu=1500 \
291291
-netdev user,id=n2 -device virtio-net-pci,netdev=n2,mac={macbase}:02,romfile="",host_mtu=1500 \
292292
-netdev user,id=n3 -device virtio-net-pci,netdev=n3,mac={macbase}:03,romfile="",host_mtu=1500 \
293-
-netdev user,id=n4 -device virtio-net-pci,netdev=n4,mac={macbase}:04,romfile="" \
294-
-netdev user,id=n5 -device virtio-net-pci,netdev=n5,mac={macbase}:05,romfile="" \
295-
-netdev user,id=n6 -device virtio-net-pci,netdev=n6,mac={macbase}:06,romfile="" \
296-
-netdev user,id=n7 -device virtio-net-pci,netdev=n7,mac={macbase}:07,romfile="" \
293+
-netdev user,id=n4 -device e1000e,netdev=n4,mac={macbase}:04,romfile="" \
294+
-netdev user,id=n5 -device e1000e,netdev=n5,mac={macbase}:05,romfile="" \
295+
-netdev user,id=n6 -device vmxnet3,netdev=n6,mac={macbase}:06,romfile="" \
296+
-netdev user,id=n7 -device vmxnet3,netdev=n7,mac={macbase}:07,romfile="" \
297297
-device virtio-scsi-pci,id=scsi0 \
298298
{cdrom}{nested_cdrom} \
299299
-drive format={disk_format},file={disk_img},if=none,media=disk,id=drive-hd1,readonly=off \
@@ -687,6 +687,31 @@ def basic_cli_tests(c):
687687
c.expect(f'set console_type="{console_type}"')
688688
c.expect(op_mode_prompt)
689689

690+
def verify_eth_mac_mapping(c, log):
691+
""" NICs are attached with a mix of drivers (virtio/e1000e/vmxnet3, see
692+
get_qemu_cmd()) to cover different naming schemes. Regardless of
693+
driver, udev must always enumerate them in ascending order: eth0
694+
carries mac0, eth1 mac1, ... up to eth7 mac7 - never scrambled. """
695+
log.info('Verify eth0..eth7 are enumerated in ascending MAC order')
696+
c.sendline('ip -json link show | jq -r \'.[] | select(.ifname|test("^eth[0-9]+$")) | "\(.ifname) \(.address)"\'')
697+
c.expect(op_mode_prompt)
698+
lines = [l.strip() for l in c.before.decode(errors='replace').splitlines() if l.strip()]
699+
700+
macs = {}
701+
for line in lines:
702+
parts = line.split()
703+
if len(parts) == 2 and re.fullmatch(r'eth\d+', parts[0]):
704+
macs[parts[0]] = parts[1].lower()
705+
706+
for i in range(8):
707+
ifname = f'eth{i}'
708+
expected_mac = f'{macbase}:{i:02x}'.lower()
709+
if ifname not in macs:
710+
raise Exception(f'Interface {ifname} not found on installed system')
711+
if macs[ifname] != expected_mac:
712+
raise Exception(f'Interface {ifname} has MAC {macs[ifname]}, expected {expected_mac} - naming race?')
713+
log.info('eth0..eth7 MAC mapping verified')
714+
690715
def _image_update_cli_sequence(c, log, new_image_name, server_bind_host='127.0.0.1', use_vrf=False):
691716
"""One add-system-image/delete cycle for nested ISO over HTTP (optional Linux VRF + VyOS vrf arg)."""
692717
url = f'http://{server_bind_host}:{NESTED_HTTP_SERV_PORT}/{NESTED_INNER_ISO_NAME}'
@@ -1067,6 +1092,11 @@ try:
10671092
log.info('Basic CLI configuration mode test')
10681093
basic_cli_tests(c)
10691094

1095+
#################################################
1096+
# Verify NIC driver mix did not scramble interface naming
1097+
#################################################
1098+
verify_eth_mac_mapping(c, log)
1099+
10701100
#################################################
10711101
# Verify /etc/os-release via lsb_release
10721102
#################################################

0 commit comments

Comments
 (0)