diff options
author | omnom62 <75066712+omnom62@users.noreply.github.com> | 2025-04-03 08:11:36 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-02 23:11:36 +0100 |
commit | 9a6bd2f99c91d81391fbff8a32b7b6f3ee3b5e57 (patch) | |
tree | d03053cf10dc14a514a708e57d10ec3a7b8e3826 /tests/unit | |
parent | 41e4b0734ca961d18c0a016a50b3c6e598a10dff (diff) | |
download | vyos.vyos-9a6bd2f99c91d81391fbff8a32b7b6f3ee3b5e57.tar.gz vyos.vyos-9a6bd2f99c91d81391fbff8a32b7b6f3ee3b5e57.zip |
T6831 OSPF VIF (#400)
* t6831_ospf_vif init
* ospf_vif 1.3 provisioning workflow
* changelog
* ospf-interface unit tests fix
* parser tests
* ospf vif parsers updated
* added vif unt test cases for ospf_interfaces
* ospf vif integration tests
* fixing eth names and utils func
* ospf vif prep/demolih updates
* added new vif test cases
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/modules/network/vyos/test_vyos_ospf_interfaces.py | 32 | ||||
-rw-r--r-- | tests/unit/modules/network/vyos/test_vyos_ospf_interfaces14.py | 61 |
2 files changed, 75 insertions, 18 deletions
diff --git a/tests/unit/modules/network/vyos/test_vyos_ospf_interfaces.py b/tests/unit/modules/network/vyos/test_vyos_ospf_interfaces.py index c7d69d0d..b0a0f0ff 100644 --- a/tests/unit/modules/network/vyos/test_vyos_ospf_interfaces.py +++ b/tests/unit/modules/network/vyos/test_vyos_ospf_interfaces.py @@ -44,13 +44,13 @@ class TestVyosOspfInterfacesModule(TestVyosModule): ) self.execute_show_command = self.mock_execute_show_command.start() self.mock_get_os_version = patch( - "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.config.ospf_interfaces.ospf_interfaces.get_os_version" + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.config.ospf_interfaces.ospf_interfaces.get_os_version", ) self.test_version = "1.2" self.get_os_version = self.mock_get_os_version.start() self.get_os_version.return_value = self.test_version self.mock_facts_get_os_version = patch( - "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ospf_interfaces.ospf_interfaces.get_os_version" + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ospf_interfaces.ospf_interfaces.get_os_version", ) self.get_facts_os_version = self.mock_facts_get_os_version.start() self.get_facts_os_version.return_value = self.test_version @@ -118,6 +118,34 @@ class TestVyosOspfInterfacesModule(TestVyosModule): ] self.execute_module(changed=True, commands=commands) + def test_vyos_ospf_interfaces_merged_vif_config(self): + set_module_args( + dict( + config=[ + dict( + name="eth0.3", + address_family=[ + dict( + afi="ipv4", + cost=100, + authentication=dict(plaintext_password="abcdefg!"), + priority=55, + ), + dict(afi="ipv6", mtu_ignore=True), + ], + ), + ], + state="merged", + ), + ) + commands = [ + "set interfaces ethernet eth0 vif 3 ip ospf cost 100", + "set interfaces ethernet eth0 vif 3 ip ospf priority 55", + "set interfaces ethernet eth0 vif 3 ip ospf authentication plaintext-password abcdefg!", + "set interfaces ethernet eth0 vif 3 ipv6 ospfv3 mtu-ignore", + ] + self.execute_module(changed=True, commands=commands) + def test_vyos_ospf_interfaces_merged_idempotent(self): set_module_args( dict( diff --git a/tests/unit/modules/network/vyos/test_vyos_ospf_interfaces14.py b/tests/unit/modules/network/vyos/test_vyos_ospf_interfaces14.py index ef27860a..d3f8bc38 100644 --- a/tests/unit/modules/network/vyos/test_vyos_ospf_interfaces14.py +++ b/tests/unit/modules/network/vyos/test_vyos_ospf_interfaces14.py @@ -18,6 +18,7 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type from unittest.mock import patch @@ -34,22 +35,22 @@ class TestVyosOspfInterfacesModule14(TestVyosModule): def setUp(self): super(TestVyosOspfInterfacesModule14, self).setUp() self.mock_get_resource_connection_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection", ) self.get_resource_connection_config = self.mock_get_resource_connection_config.start() self.mock_execute_show_command = patch( - "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ospf_interfaces.ospf_interfaces.Ospf_interfacesFacts.get_device_data" + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ospf_interfaces.ospf_interfaces.Ospf_interfacesFacts.get_device_data", ) self.execute_show_command = self.mock_execute_show_command.start() self.mock_get_os_version = patch( - "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.config.ospf_interfaces.ospf_interfaces.get_os_version" + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.config.ospf_interfaces.ospf_interfaces.get_os_version", ) self.test_version = "1.4" self.get_os_version = self.mock_get_os_version.start() self.get_os_version.return_value = self.test_version self.mock_facts_get_os_version = patch( - "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ospf_interfaces.ospf_interfaces.get_os_version" + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ospf_interfaces.ospf_interfaces.get_os_version", ) self.get_facts_os_version = self.mock_facts_get_os_version.start() self.get_facts_os_version.return_value = self.test_version @@ -104,7 +105,7 @@ class TestVyosOspfInterfacesModule14(TestVyosModule): ), ], state="merged", - ) + ), ) commands = [ "set protocols ospf interface bond2 transmit-delay 9", @@ -116,6 +117,34 @@ class TestVyosOspfInterfacesModule14(TestVyosModule): ] self.execute_module(changed=True, commands=commands) + def test_vyos_ospf_interfaces_merged_vif_config(self): + set_module_args( + dict( + config=[ + dict( + name="eth0.3", + address_family=[ + dict( + afi="ipv4", + cost=100, + authentication=dict(plaintext_password="abcdefg!"), + priority=55, + ), + dict(afi="ipv6", mtu_ignore=True), + ], + ), + ], + state="merged", + ), + ) + commands = [ + "set protocols ospf interface eth0.3 cost 100", + "set protocols ospf interface eth0.3 priority 55", + "set protocols ospf interface eth0.3 authentication plaintext-password abcdefg!", + "set protocols ospfv3 interface eth0.3 mtu-ignore", + ] + self.execute_module(changed=True, commands=commands) + def test_vyos_ospf_interfaces_merged_idempotent(self): set_module_args( dict( @@ -137,7 +166,7 @@ class TestVyosOspfInterfacesModule14(TestVyosModule): ], ), ], - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -162,7 +191,7 @@ class TestVyosOspfInterfacesModule14(TestVyosModule): ], ), ], - ) + ), ) commands = [ "set protocols ospfv3 interface eth0 cost 500", @@ -198,7 +227,7 @@ class TestVyosOspfInterfacesModule14(TestVyosModule): ), ], state="replaced", - ) + ), ) commands = [ "set protocols ospf interface bond2 transmit-delay 9", @@ -249,7 +278,7 @@ class TestVyosOspfInterfacesModule14(TestVyosModule): ), ], state="replaced", - ) + ), ) commands = [ "delete protocols ospf interface eth1 cost 100", @@ -287,7 +316,7 @@ class TestVyosOspfInterfacesModule14(TestVyosModule): ), ], state="replaced", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -318,7 +347,7 @@ class TestVyosOspfInterfacesModule14(TestVyosModule): ), ], state="overridden", - ) + ), ) commands = [ "set protocols ospf interface bond2 transmit-delay 9", @@ -355,7 +384,7 @@ class TestVyosOspfInterfacesModule14(TestVyosModule): ), ], state="overridden", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -368,7 +397,7 @@ class TestVyosOspfInterfacesModule14(TestVyosModule): ), ], state="deleted", - ) + ), ) commands = ["delete protocols ospfv3 interface eth0"] self.execute_module(changed=True, commands=commands) @@ -382,7 +411,7 @@ class TestVyosOspfInterfacesModule14(TestVyosModule): ), ], state="deleted", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -414,7 +443,7 @@ class TestVyosOspfInterfacesModule14(TestVyosModule): ), ], state="rendered", - ) + ), ) commands = [ "set protocols ospf interface eth0 cost 100", @@ -456,7 +485,7 @@ class TestVyosOspfInterfacesModule14(TestVyosModule): "md5_key": { "key": "1111111111232345", "key_id": 10, - } + }, }, "bandwidth": 70, "transmit_delay": 45, |