summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authoromnom62 <75066712+omnom62@users.noreply.github.com>2025-04-03 08:11:36 +1000
committerGitHub <noreply@github.com>2025-04-02 23:11:36 +0100
commit9a6bd2f99c91d81391fbff8a32b7b6f3ee3b5e57 (patch)
treed03053cf10dc14a514a708e57d10ec3a7b8e3826 /tests
parent41e4b0734ca961d18c0a016a50b3c6e598a10dff (diff)
downloadvyos.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')
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/tasks/post_tasks.yml2
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/tasks/pre_tasks.yml2
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/tests/cli/deleted.yaml1
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/tests/cli/merged.yaml6
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/tests/cli/overridden.yaml1
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/tests/cli/rendered.yaml5
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/tests/cli/replaced.yaml1
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/tests/cli/rtt.yaml6
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/vars/pre-v1_4.yaml5
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/vars/v1_4.yaml5
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_ospf_interfaces.py32
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_ospf_interfaces14.py61
12 files changed, 104 insertions, 23 deletions
diff --git a/tests/integration/targets/vyos_ospf_interfaces/tasks/post_tasks.yml b/tests/integration/targets/vyos_ospf_interfaces/tasks/post_tasks.yml
index 0883ef48..f6b009a8 100644
--- a/tests/integration/targets/vyos_ospf_interfaces/tasks/post_tasks.yml
+++ b/tests/integration/targets/vyos_ospf_interfaces/tasks/post_tasks.yml
@@ -3,5 +3,7 @@
vyos.vyos.vyos_config:
lines: |-
delete interfaces bonding bond2
+ delete interfaces ethernet eth2 vif 3
+ delete interfaces ethernet eth2 vif 18
vars:
ansible_connection: ansible.netcommon.network_cli
diff --git a/tests/integration/targets/vyos_ospf_interfaces/tasks/pre_tasks.yml b/tests/integration/targets/vyos_ospf_interfaces/tasks/pre_tasks.yml
index af74ff7a..fdb4981c 100644
--- a/tests/integration/targets/vyos_ospf_interfaces/tasks/pre_tasks.yml
+++ b/tests/integration/targets/vyos_ospf_interfaces/tasks/pre_tasks.yml
@@ -3,5 +3,7 @@
vyos.vyos.vyos_config:
lines: |-
set interfaces bonding bond2
+ set interfaces ethernet eth2 vif 3
+ set interfaces ethernet eth2 vif 18
vars:
ansible_connection: ansible.netcommon.network_cli
diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/deleted.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/deleted.yaml
index 59fe52ac..bd70d071 100644
--- a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/deleted.yaml
+++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/deleted.yaml
@@ -17,7 +17,6 @@
- assert:
that:
- - result.commands|length == 2
- result.changed == true
- result.commands|symmetric_difference(deleted.commands) == []
- result.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == []
diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/merged.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/merged.yaml
index 7b091dd7..ddff03c9 100644
--- a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/merged.yaml
+++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/merged.yaml
@@ -17,6 +17,11 @@
- afi: ipv6
mtu_ignore: true
instance: 33
+ - name: eth2.3
+ address_family:
+ - afi: ipv4
+ cost: 60
+ priority: 40
- name: bond2
address_family:
- afi: ipv4
@@ -30,7 +35,6 @@
- assert:
that:
- - result.commands|length == 6
- result.changed == true
- result.commands|symmetric_difference(merged.commands) == []
- result.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == []
diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/overridden.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/overridden.yaml
index 7e728069..252336fc 100644
--- a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/overridden.yaml
+++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/overridden.yaml
@@ -24,7 +24,6 @@
- assert:
that:
- - result.commands|length == 8
- result.changed == true
- result.commands|symmetric_difference(overridden.commands) == []
- result.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == []
diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rendered.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rendered.yaml
index 4cb5f4f9..5a07c95d 100644
--- a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rendered.yaml
+++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rendered.yaml
@@ -17,6 +17,11 @@
- afi: ipv6
mtu_ignore: true
instance: 33
+ - name: eth2.3
+ address_family:
+ - afi: ipv4
+ cost: 60
+ priority: 40
- name: bond2
address_family:
- afi: ipv4
diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/replaced.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/replaced.yaml
index 2bb8a02f..7a5b9fa8 100644
--- a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/replaced.yaml
+++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/replaced.yaml
@@ -35,7 +35,6 @@
- assert:
that:
- - result.commands|length == 8
- result.changed == true
- result.commands|symmetric_difference(replaced.commands) == []
- result.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == []
diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rtt.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rtt.yaml
index c74248e0..e2464457 100644
--- a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rtt.yaml
+++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rtt.yaml
@@ -19,6 +19,11 @@
- afi: ipv6
mtu_ignore: true
instance: 33
+ - name: eth2.3
+ address_family:
+ - afi: ipv4
+ cost: 60
+ priority: 40
- name: bond2
address_family:
- afi: ipv4
@@ -32,7 +37,6 @@
- assert:
that:
- - baseconfig.commands|length == 6
- baseconfig.changed == true
- baseconfig.commands|symmetric_difference(merged.commands) == []
- baseconfig.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == []
diff --git a/tests/integration/targets/vyos_ospf_interfaces/vars/pre-v1_4.yaml b/tests/integration/targets/vyos_ospf_interfaces/vars/pre-v1_4.yaml
index a9e03421..7f84e92e 100644
--- a/tests/integration/targets/vyos_ospf_interfaces/vars/pre-v1_4.yaml
+++ b/tests/integration/targets/vyos_ospf_interfaces/vars/pre-v1_4.yaml
@@ -4,6 +4,8 @@ merged_commands:
- set interfaces ethernet eth0 ip ospf priority 26
- set interfaces ethernet eth0 ipv6 ospfv3 mtu-ignore
- set interfaces ethernet eth0 ipv6 ospfv3 instance-id 33
+ - set interfaces ethernet eth2 vif 3 ip ospf cost 60
+ - set interfaces ethernet eth2 vif 3 ip ospf priority 40
- set interfaces bonding bond2 ip ospf transmit-delay 45
- set interfaces bonding bond2 ipv6 ospfv3 passive
@@ -12,6 +14,7 @@ populate_commands:
- set interfaces ethernet eth0 ip ospf priority 26
- set interfaces ethernet eth0 ipv6 ospfv3 mtu-ignore
- set interfaces ethernet eth0 ipv6 ospfv3 instance-id 33
+ - set interfaces ethernet eth2 vif 18 ip ospf cost 80
- set interfaces bonding bond2 ip ospf transmit-delay 45
- set interfaces bonding bond2 ipv6 ospfv3 passive
@@ -20,6 +23,7 @@ remove_commands:
- delete interfaces ethernet eth0 ipv6 ospfv3
- delete interfaces ethernet eth1 ip ospf
- delete interfaces ethernet eth1 ipv6 ospfv3
+ - delete interfaces ethernet eth2 vif 3 ip ospf
- delete interfaces bonding bond1 ip ospf
- delete interfaces bonding bond1 ipv6 ospfv3
- delete interfaces bonding bond2 ip ospf
@@ -41,6 +45,7 @@ replaced_commands:
overridden_commands:
- delete interfaces bonding bond2 ip ospf
- delete interfaces bonding bond2 ipv6 ospfv3
+ - delete interfaces ethernet eth2 vif 18 ip ospf
- set interfaces ethernet eth0 ip ospf transmit-delay 50
- set interfaces ethernet eth0 ip ospf network point-to-point
- set interfaces ethernet eth0 ipv6 ospfv3 dead-interval 39
diff --git a/tests/integration/targets/vyos_ospf_interfaces/vars/v1_4.yaml b/tests/integration/targets/vyos_ospf_interfaces/vars/v1_4.yaml
index 15b7f5a7..3864f33a 100644
--- a/tests/integration/targets/vyos_ospf_interfaces/vars/v1_4.yaml
+++ b/tests/integration/targets/vyos_ospf_interfaces/vars/v1_4.yaml
@@ -4,6 +4,8 @@ merged_commands:
- set protocols ospf interface eth0 priority 26
- set protocols ospfv3 interface eth0 mtu-ignore
- set protocols ospfv3 interface eth0 instance-id 33
+ - set protocols ospf interface eth2.3 cost 60
+ - set protocols ospf interface eth2.3 priority 40
- set protocols ospfv3 interface bond2 passive
- set protocols ospf interface bond2 transmit-delay 45
@@ -12,11 +14,13 @@ populate_commands:
- set protocols ospf interface eth0 priority 26
- set protocols ospfv3 interface eth0 mtu-ignore
- set protocols ospfv3 interface eth0 instance-id 33
+ - set protocols ospf interface eth2.18 cost 80
- set protocols ospfv3 interface bond2 passive
- set protocols ospf interface bond2 transmit-delay 45
remove_commands:
- delete protocols ospf interface eth0
+ - delete protocols ospf interface eth2.3
- delete protocols ospf interface bond2
- delete protocols ospfv3 interface bond2
- delete protocols ospfv3 interface eth0
@@ -36,6 +40,7 @@ replaced_commands:
overridden_commands:
- delete protocols ospf interface bond2
- delete protocols ospfv3 interface bond2
+ - delete protocols ospf interface eth2.18
- set protocols ospf interface eth0 transmit-delay 50
- set protocols ospf interface eth0 network point-to-point
- set protocols ospfv3 interface eth0 dead-interval 39
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,