diff options
| author | Christian Breunig <christian@breunig.cc> | 2026-08-04 19:22:11 +0000 |
|---|---|---|
| committer | Christian Breunig <christian@breunig.cc> | 2026-08-06 21:54:53 +0200 |
| commit | 90149ea720e6f7f9a73f1eb16f6704d4efb40a76 (patch) | |
| tree | 9d1795894f8b14149a18f7cecda08b7831229805 | |
| parent | 413f443bd989d667fd836a354506952e2de755d7 (diff) | |
| download | vyos-build-90149ea720e6f7f9a73f1eb16f6704d4efb40a76.tar.gz vyos-build-90149ea720e6f7f9a73f1eb16f6704d4efb40a76.zip | |
Testsuite: T3871: add testifname Makefile target
Testcase removes NIC definition entirely and on a second NIC drops only
the hw-id node. Testcase is there to verify proper ordering which simulates
a NIC replacement.
| -rw-r--r-- | Makefile | 7 | ||||
| -rwxr-xr-x | scripts/check-qemu-install | 50 |
2 files changed, 54 insertions, 3 deletions
@@ -8,7 +8,7 @@ ISO_PATH := $(build_dir)/live-image-$(ARCH).hybrid.iso # to their scripts via $(MAKECMDGOALS). Those extra words are also goals as # far as make is concerned, so without this they'd fall through to the `%:` # flavor rule below and run build-vyos-image with garbage arguments. -TEST_TARGETS := test test-no-interfaces test-no-interfaces-no-vpp test-interfaces test-vpp testc testcvpp testraid testsb testtpm test-ci-qcow2 test-image-update qemu-live +TEST_TARGETS := test test-no-interfaces test-no-interfaces-no-vpp test-interfaces test-vpp testc testcvpp testraid testsb testtpm testifname test-ci-qcow2 test-image-update qemu-live ifneq ($(filter $(TEST_TARGETS),$(firstword $(MAKECMDGOALS))),) $(eval $(filter-out $(firstword $(MAKECMDGOALS)),$(MAKECMDGOALS)):;@:) endif @@ -71,6 +71,11 @@ testsb: testtpm: scripts/check-qemu-install --debug --tpmtest --iso $(ISO_PATH) $(filter-out $@,$(MAKECMDGOALS)) +.PHONY: testifname +.ONESHELL: +testifname: + scripts/check-qemu-install --debug --ifnametest --iso $(ISO_PATH) $(filter-out $@,$(MAKECMDGOALS)) + .PHONY: test-ci-qcow2 .ONESHELL: test-ci-qcow2: diff --git a/scripts/check-qemu-install b/scripts/check-qemu-install index 8fff5783..a2993cf0 100755 --- a/scripts/check-qemu-install +++ b/scripts/check-qemu-install @@ -140,6 +140,8 @@ parser.add_argument('--configtest', help='Execute load/commit config tests', action='store_true', default=False) parser.add_argument('--tpmtest', help='Execute TPM encrypted config tests', action='store_true', default=False) +parser.add_argument('--ifnametest', help='Execute interface naming/hw-id persistence tests', + action='store_true', default=False) parser.add_argument('--sbtest', help='Execute Secure Boot tests', action='store_true', default=False) parser.add_argument('--cloud-init', help='Execute cloud-init tests', @@ -387,6 +389,8 @@ if args.test_image_update: _primary_modes.append('--test-image-update') if args.tpmtest: _primary_modes.append('--tpmtest') +if args.ifnametest: + _primary_modes.append('--ifnametest') if args.raid: _primary_modes.append('--raid') if args.smoketest: @@ -397,8 +401,8 @@ if args.sbtest: _primary_modes.append('--sbtest') if len(_primary_modes) > 1: log.error('Incompatible combination of testcase flags (%s): only one of ' - '--cloud-init, --test-image-update, --tpmtest, --raid, --smoketest, ' - '--configtest, --sbtest may be set.', ', '.join(_primary_modes)) + '--cloud-init, --test-image-update, --tpmtest, --ifnametest, --raid, ' + '--smoketest, --configtest, --sbtest may be set.', ', '.join(_primary_modes)) sys.exit(1) if args.no_interfaces and not args.smoketest: @@ -1304,6 +1308,48 @@ try: c.sendline('exit') c.expect(op_mode_prompt) + elif args.ifnametest: + # A missing/deleted hw-id binding, or a fully deleted interface + # config, must not change the eth0..eth7 <-> MAC mapping after + # the next reboot (regression check for the boot-time naming race). + log.info('Running interface naming/hw-id persistence tests') + del_idx, hwid_idx = random.sample(range(8), 2) + log.info(f'Deleting eth{del_idx} entirely, removing hw-id only on eth{hwid_idx}') + + c.sendline('configure') + c.expect(cfg_mode_prompt) + c.sendline(f'delete interfaces ethernet eth{del_idx}') + c.expect(cfg_mode_prompt) + c.sendline(f'delete interfaces ethernet eth{hwid_idx} hw-id') + c.expect(cfg_mode_prompt) + c.sendline('commit') + c.expect(cfg_mode_prompt) + c.sendline('save') + c.expect(cfg_mode_prompt) + c.sendline('exit') + c.expect(op_mode_prompt) + + log.info('Rebooting to verify interface naming survives across reboot') + c.sendline('reboot now') + waitForLogin(c, log) + loginVM(c, log) + + log.info('Collecting interface naming diagnostics') + c.sendline('show configuration commands | match "hw-id"') + c.expect(op_mode_prompt) + c.sendline('show interfaces ethernet') + c.expect(op_mode_prompt) + c.sendline('ip link show') + c.expect(op_mode_prompt) + c.sendline('show log | match "hw-id"') + c.expect(op_mode_prompt) + c.sendline('cat /run/vyos-net-name-resolve.json 2>/dev/null || true') + c.expect(op_mode_prompt) + c.sendline('show log kernel | match "eth"') + c.expect(op_mode_prompt) + + verify_eth_mac_mapping(c, log) + elif args.raid: # Verify RAID subsystem - by deleting a disk and re-create the array # from scratch |
