From 5eebe35d9a1f8750f611ce3c8f6833526e117ced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Quentin=20Th=C3=A9bault?= Date: Tue, 19 Nov 2024 21:26:05 +0900 Subject: [PATCH] update 0004_start_test.py - add loopback address test --- tests/functional_tests/0004_start_test.py | 28 ++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/functional_tests/0004_start_test.py b/tests/functional_tests/0004_start_test.py index 73f64e17..a0673368 100644 --- a/tests/functional_tests/0004_start_test.py +++ b/tests/functional_tests/0004_start_test.py @@ -57,8 +57,9 @@ def test_02_start_rc_jail(invoke_cli, resource_selector): for jail in resource_selector.rcjails: assert jail.running is True, f'{jail.name} not running' -# TODO: Let's also start jails in a single command to test that out +# Network-related tests belong here because the code is only executed at jail +# start time. @require_root @require_zpool def test_03_create_and_start_nobridge_vnet_jail(release, jail, invoke_cli): @@ -109,3 +110,28 @@ def test_03_create_and_start_nobridge_vnet_jail(release, jail, invoke_cli): finally: os.remove(path) + + +@require_root +@require_zpool +def test_04_vnet_jail_with_loopback_alias(release, jail, invoke_cli): + jail = jail('loopback_alias_jail') + + invoke_cli([ + 'create', '-r', release, '-n', jail.name, + 'boot=on', 'vnet=on', + f'ip4_addr=lo0|192.168.2.10' + ]) + + assert jail.exists is True + assert jail.running is True + + stdout, stderr = jail.run_command(['ifconfig', 'lo0']) + assert bool(stderr) is False, f'Ifconfig returned an error: {stderr}' + assert '192.168.2.10' in stdout, ( + 'Could not set address on loopback interface.' + ) + + invoke_cli([ + 'destroy', jail.name, '-f' + ])