mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 03:41:25 -07:00
nmcli: add runner_fast_rate option (#6148)
* add runner_fast_rate option * unset default value for runner_fast_rate parameter * add some commas * Remove default in copy of argspec. Co-authored-by: Sam Potekhin <eax24@ya.ru> --------- Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Sam Potekhin <eax24@ya.ru>
This commit is contained in:
parent
6fa833feed
commit
d4f272ba52
3 changed files with 153 additions and 1 deletions
|
@ -602,6 +602,7 @@ ipv6.method: auto
|
|||
ipv6.ignore-auto-dns: no
|
||||
ipv6.ignore-auto-routes: no
|
||||
team.runner: roundrobin
|
||||
team.runner-fast-rate: no
|
||||
"""
|
||||
|
||||
TESTCASE_TEAM_HWADDR_POLICY_FAILS = [
|
||||
|
@ -615,6 +616,71 @@ TESTCASE_TEAM_HWADDR_POLICY_FAILS = [
|
|||
}
|
||||
]
|
||||
|
||||
TESTCASE_TEAM_RUNNER_FAST_RATE = [
|
||||
{
|
||||
'type': 'team',
|
||||
'conn_name': 'non_existent_nw_device',
|
||||
'ifname': 'team0_non_existant',
|
||||
'runner': 'lacp',
|
||||
'runner_fast_rate': True,
|
||||
'state': 'present',
|
||||
'_ansible_check_mode': False,
|
||||
}
|
||||
]
|
||||
|
||||
TESTCASE_TEAM_RUNNER_FAST_RATE_FAILS = [
|
||||
{
|
||||
'type': 'team',
|
||||
'conn_name': 'non_existent_nw_device',
|
||||
'ifname': 'team0_non_existant',
|
||||
'runner_fast_rate': True,
|
||||
'state': 'present',
|
||||
'_ansible_check_mode': False,
|
||||
},
|
||||
{
|
||||
'type': 'team',
|
||||
'conn_name': 'non_existent_nw_device',
|
||||
'ifname': 'team0_non_existant',
|
||||
'state': 'present',
|
||||
'runner_fast_rate': False,
|
||||
'_ansible_check_mode': False,
|
||||
},
|
||||
{
|
||||
'type': 'team',
|
||||
'conn_name': 'non_existent_nw_device',
|
||||
'ifname': 'team0_non_existant',
|
||||
'state': 'present',
|
||||
'runner': 'activebackup',
|
||||
'runner_fast_rate': False,
|
||||
'_ansible_check_mode': False,
|
||||
},
|
||||
{
|
||||
'type': 'team',
|
||||
'conn_name': 'non_existent_nw_device',
|
||||
'ifname': 'team0_non_existant',
|
||||
'state': 'present',
|
||||
'runner': 'activebackup',
|
||||
'runner_fast_rate': True,
|
||||
'_ansible_check_mode': False,
|
||||
}
|
||||
]
|
||||
|
||||
TESTCASE_TEAM_RUNNER_FAST_RATE_SHOW_OUTPUT = """\
|
||||
connection.id: non_existent_nw_device
|
||||
connection.interface-name: team0_non_existant
|
||||
connection.autoconnect: yes
|
||||
connection.type: team
|
||||
ipv4.ignore-auto-dns: no
|
||||
ipv4.ignore-auto-routes: no
|
||||
ipv4.never-default: no
|
||||
ipv4.may-fail: yes
|
||||
ipv6.method: auto
|
||||
ipv6.ignore-auto-dns: no
|
||||
ipv6.ignore-auto-routes: no
|
||||
team.runner: lacp
|
||||
team.runner-fast-rate: yes
|
||||
"""
|
||||
|
||||
TESTCASE_TEAM_SLAVE = [
|
||||
{
|
||||
'type': 'team-slave',
|
||||
|
@ -1436,6 +1502,13 @@ def mocked_team_connection_unchanged(mocker):
|
|||
execute_return=(0, TESTCASE_TEAM_SHOW_OUTPUT, ""))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mocked_team_runner_fast_rate_connection_unchanged(mocker):
|
||||
mocker_set(mocker,
|
||||
connection_exists=True,
|
||||
execute_return=(0, TESTCASE_TEAM_RUNNER_FAST_RATE_SHOW_OUTPUT, ""))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mocked_team_slave_connection_unchanged(mocker):
|
||||
mocker_set(mocker,
|
||||
|
@ -2247,6 +2320,63 @@ def test_team_connection_create_hwaddr_policy_fails(mocked_generic_connection_cr
|
|||
assert results['msg'] == "Runner-hwaddr-policy is only allowed for runner activebackup"
|
||||
|
||||
|
||||
@pytest.mark.parametrize('patch_ansible_module', TESTCASE_TEAM_RUNNER_FAST_RATE, indirect=['patch_ansible_module'])
|
||||
def test_team_runner_fast_rate_connection_create(mocked_generic_connection_create, capfd):
|
||||
"""
|
||||
Test : Team connection created with runner_fast_rate parameter
|
||||
"""
|
||||
with pytest.raises(SystemExit):
|
||||
nmcli.main()
|
||||
|
||||
assert nmcli.Nmcli.execute_command.call_count == 1
|
||||
arg_list = nmcli.Nmcli.execute_command.call_args_list
|
||||
args, kwargs = arg_list[0]
|
||||
|
||||
assert args[0][0] == '/usr/bin/nmcli'
|
||||
assert args[0][1] == 'con'
|
||||
assert args[0][2] == 'add'
|
||||
assert args[0][3] == 'type'
|
||||
assert args[0][4] == 'team'
|
||||
assert args[0][5] == 'con-name'
|
||||
assert args[0][6] == 'non_existent_nw_device'
|
||||
|
||||
for param in ['connection.autoconnect', 'connection.interface-name', 'team0_non_existant', 'team.runner', 'lacp', 'team.runner-fast-rate', 'yes']:
|
||||
assert param in args[0]
|
||||
|
||||
out, err = capfd.readouterr()
|
||||
results = json.loads(out)
|
||||
assert not results.get('failed')
|
||||
assert results['changed']
|
||||
|
||||
|
||||
@pytest.mark.parametrize('patch_ansible_module', TESTCASE_TEAM_RUNNER_FAST_RATE, indirect=['patch_ansible_module'])
|
||||
def test_team_runner_fast_rate_connection_unchanged(mocked_team_runner_fast_rate_connection_unchanged, capfd):
|
||||
"""
|
||||
Test : Team connection unchanged with runner_fast_rate parameter
|
||||
"""
|
||||
with pytest.raises(SystemExit):
|
||||
nmcli.main()
|
||||
|
||||
out, err = capfd.readouterr()
|
||||
results = json.loads(out)
|
||||
assert not results.get('failed')
|
||||
assert not results['changed']
|
||||
|
||||
|
||||
@pytest.mark.parametrize('patch_ansible_module', TESTCASE_TEAM_RUNNER_FAST_RATE_FAILS, indirect=['patch_ansible_module'])
|
||||
def test_team_connection_create_runner_fast_rate_fails(mocked_generic_connection_create, capfd):
|
||||
"""
|
||||
Test : Team connection with runner_fast_rate enabled
|
||||
"""
|
||||
with pytest.raises(SystemExit):
|
||||
nmcli.main()
|
||||
|
||||
out, err = capfd.readouterr()
|
||||
results = json.loads(out)
|
||||
assert results.get('failed')
|
||||
assert results['msg'] == "runner-fast-rate is only allowed for runner lacp"
|
||||
|
||||
|
||||
@pytest.mark.parametrize('patch_ansible_module', TESTCASE_TEAM_SLAVE, indirect=['patch_ansible_module'])
|
||||
def test_create_team_slave(mocked_generic_connection_create, capfd):
|
||||
"""
|
||||
|
@ -3947,6 +4077,8 @@ def test_bond_connection_unchanged(mocked_generic_connection_diff_check, capfd):
|
|||
choices=['broadcast', 'roundrobin', 'activebackup', 'loadbalance', 'lacp']),
|
||||
# team active-backup runner specific options
|
||||
runner_hwaddr_policy=dict(type='str', choices=['same_all', 'by_active', 'only_active']),
|
||||
# team lacp runner specific options
|
||||
runner_fast_rate=dict(type='bool'),
|
||||
# vlan specific vars
|
||||
vlanid=dict(type='int'),
|
||||
vlandev=dict(type='str'),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue