Skip to content

Commit

Permalink
update 0004_start_test.py - add loopback address test
Browse files Browse the repository at this point in the history
  • Loading branch information
Defenso-QTH committed Nov 19, 2024
1 parent d48f123 commit 5eebe35
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion tests/functional_tests/0004_start_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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([

Check failure on line 120 in tests/functional_tests/0004_start_test.py

View check run for this annotation

Cirrus CI / Use prebuilt packages

tests/functional_tests/0004_start_test.py#L120

tests.functional_tests.0004_start_test.test_04_vnet_jail_with_loopback_alias
Raw output
release = '14.1-RELEASE', jail = loopback_alias_jail
invoke_cli = <function invoke_cli.<locals>.invoke at 0x47739b3cf40>

    @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'
        ])

tests/functional_tests/0004_start_test.py:120: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cmd = ['iocage', 'create', '-r', '14.1-RELEASE', '-n', 'loopback_alias_jail', ...]
reason = 'No default gateway found for ipv6.\n  + Configuring VNET FAILED\n  add net default: gateway 10.128.0.1 fib 0: Invalid argument\n\nStopped loopback_alias_jail due to VNET failure\n'
assert_returncode = True

    def invoke(cmd, reason=None, assert_returncode=True):
        cmd.insert(0, 'iocage')
        cmd = [str(c) for c in cmd]
    
        result = subprocess.run(
            cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE
        )
        reason = f'{reason}: {result.stderr}' if reason else result.stderr
    
        if assert_returncode:
            # Empty or Template jails that should not be started/stopped but
            # sometimes make it in due to a race
            try:
                reason = reason.decode()
            except AttributeError:
                pass
    
            if 'execvp: /bin/sh: No such' not in reason:
>               assert result.returncode == 0, reason
E               AssertionError: No default gateway found for ipv6.
E                   + Configuring VNET FAILED
E                   add net default: gateway 10.128.0.1 fib 0: Invalid argument
E                 
E                 Stopped loopback_alias_jail due to VNET failure
E                 
E               assert 1 == 0
E                +  where 1 = CompletedProcess(args=['iocage', 'create', '-r', '14.1-RELEASE', '-n', 'loopback_alias_jail', 'boot=on', 'vnet=on', 'ip4_addr=lo0|192.168.2.10'], returncode=1, stdout=b'loopback_alias_jail successfully created!\n* Starting loopback_alias_jail\n  + Started OK\n  + Using devfs_ruleset: 1012 (iocage generated default)\n', stderr=b'No default gateway found for ipv6.\n  + Configuring VNET FAILED\n  add net default: gateway 10.128.0.1 fib 0: Invalid argument\n\nStopped loopback_alias_jail due to VNET failure\n').returncode

tests/conftest.py:279: AssertionError
'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'
])

0 comments on commit 5eebe35

Please sign in to comment.