Skip to content

Commit 90149ea

Browse files
committed
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.
1 parent 413f443 commit 90149ea

2 files changed

Lines changed: 54 additions & 3 deletions

File tree

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ISO_PATH := $(build_dir)/live-image-$(ARCH).hybrid.iso
88
# to their scripts via $(MAKECMDGOALS). Those extra words are also goals as
99
# far as make is concerned, so without this they'd fall through to the `%:`
1010
# flavor rule below and run build-vyos-image with garbage arguments.
11-
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
11+
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
1212
ifneq ($(filter $(TEST_TARGETS),$(firstword $(MAKECMDGOALS))),)
1313
$(eval $(filter-out $(firstword $(MAKECMDGOALS)),$(MAKECMDGOALS)):;@:)
1414
endif
@@ -71,6 +71,11 @@ testsb:
7171
testtpm:
7272
scripts/check-qemu-install --debug --tpmtest --iso $(ISO_PATH) $(filter-out $@,$(MAKECMDGOALS))
7373

74+
.PHONY: testifname
75+
.ONESHELL:
76+
testifname:
77+
scripts/check-qemu-install --debug --ifnametest --iso $(ISO_PATH) $(filter-out $@,$(MAKECMDGOALS))
78+
7479
.PHONY: test-ci-qcow2
7580
.ONESHELL:
7681
test-ci-qcow2:

scripts/check-qemu-install

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ parser.add_argument('--configtest', help='Execute load/commit config tests',
140140
action='store_true', default=False)
141141
parser.add_argument('--tpmtest', help='Execute TPM encrypted config tests',
142142
action='store_true', default=False)
143+
parser.add_argument('--ifnametest', help='Execute interface naming/hw-id persistence tests',
144+
action='store_true', default=False)
143145
parser.add_argument('--sbtest', help='Execute Secure Boot tests',
144146
action='store_true', default=False)
145147
parser.add_argument('--cloud-init', help='Execute cloud-init tests',
@@ -387,6 +389,8 @@ if args.test_image_update:
387389
_primary_modes.append('--test-image-update')
388390
if args.tpmtest:
389391
_primary_modes.append('--tpmtest')
392+
if args.ifnametest:
393+
_primary_modes.append('--ifnametest')
390394
if args.raid:
391395
_primary_modes.append('--raid')
392396
if args.smoketest:
@@ -397,8 +401,8 @@ if args.sbtest:
397401
_primary_modes.append('--sbtest')
398402
if len(_primary_modes) > 1:
399403
log.error('Incompatible combination of testcase flags (%s): only one of '
400-
'--cloud-init, --test-image-update, --tpmtest, --raid, --smoketest, '
401-
'--configtest, --sbtest may be set.', ', '.join(_primary_modes))
404+
'--cloud-init, --test-image-update, --tpmtest, --ifnametest, --raid, '
405+
'--smoketest, --configtest, --sbtest may be set.', ', '.join(_primary_modes))
402406
sys.exit(1)
403407

404408
if args.no_interfaces and not args.smoketest:
@@ -1304,6 +1308,48 @@ try:
13041308
c.sendline('exit')
13051309
c.expect(op_mode_prompt)
13061310

1311+
elif args.ifnametest:
1312+
# A missing/deleted hw-id binding, or a fully deleted interface
1313+
# config, must not change the eth0..eth7 <-> MAC mapping after
1314+
# the next reboot (regression check for the boot-time naming race).
1315+
log.info('Running interface naming/hw-id persistence tests')
1316+
del_idx, hwid_idx = random.sample(range(8), 2)
1317+
log.info(f'Deleting eth{del_idx} entirely, removing hw-id only on eth{hwid_idx}')
1318+
1319+
c.sendline('configure')
1320+
c.expect(cfg_mode_prompt)
1321+
c.sendline(f'delete interfaces ethernet eth{del_idx}')
1322+
c.expect(cfg_mode_prompt)
1323+
c.sendline(f'delete interfaces ethernet eth{hwid_idx} hw-id')
1324+
c.expect(cfg_mode_prompt)
1325+
c.sendline('commit')
1326+
c.expect(cfg_mode_prompt)
1327+
c.sendline('save')
1328+
c.expect(cfg_mode_prompt)
1329+
c.sendline('exit')
1330+
c.expect(op_mode_prompt)
1331+
1332+
log.info('Rebooting to verify interface naming survives across reboot')
1333+
c.sendline('reboot now')
1334+
waitForLogin(c, log)
1335+
loginVM(c, log)
1336+
1337+
log.info('Collecting interface naming diagnostics')
1338+
c.sendline('show configuration commands | match "hw-id"')
1339+
c.expect(op_mode_prompt)
1340+
c.sendline('show interfaces ethernet')
1341+
c.expect(op_mode_prompt)
1342+
c.sendline('ip link show')
1343+
c.expect(op_mode_prompt)
1344+
c.sendline('show log | match "hw-id"')
1345+
c.expect(op_mode_prompt)
1346+
c.sendline('cat /run/vyos-net-name-resolve.json 2>/dev/null || true')
1347+
c.expect(op_mode_prompt)
1348+
c.sendline('show log kernel | match "eth"')
1349+
c.expect(op_mode_prompt)
1350+
1351+
verify_eth_mac_mapping(c, log)
1352+
13071353
elif args.raid:
13081354
# Verify RAID subsystem - by deleting a disk and re-create the array
13091355
# from scratch

0 commit comments

Comments
 (0)