From 2bed003880c0aa150aa3a9b22a7e3dd942145db4 Mon Sep 17 00:00:00 2001 From: Nikhil Bhasin Date: Fri, 19 Sep 2025 16:23:14 +0530 Subject: [PATCH 01/31] fix no cdp --- changelogs/cdp_fix.yaml | 3 +++ .../config/l2_interfaces/l2_interfaces.py | 20 +++++++++++++++++++ .../config/l3_interfaces/l3_interfaces.py | 8 ++++---- .../nxos/rm_templates/l2_interfaces.py | 18 +++++++++++++++-- .../network/nxos/test_nxos_l2_interfaces.py | 7 +++++++ 5 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 changelogs/cdp_fix.yaml diff --git a/changelogs/cdp_fix.yaml b/changelogs/cdp_fix.yaml new file mode 100644 index 000000000..175bb5d8e --- /dev/null +++ b/changelogs/cdp_fix.yaml @@ -0,0 +1,3 @@ +--- +minor_changes: + - nxos_l2_interfaces - Fix cdp_enable config parsing. \ No newline at end of file diff --git a/plugins/module_utils/network/nxos/config/l2_interfaces/l2_interfaces.py b/plugins/module_utils/network/nxos/config/l2_interfaces/l2_interfaces.py index e2b5ce845..e3b0876b9 100644 --- a/plugins/module_utils/network/nxos/config/l2_interfaces/l2_interfaces.py +++ b/plugins/module_utils/network/nxos/config/l2_interfaces/l2_interfaces.py @@ -59,6 +59,7 @@ def __init__(self, module): "beacon", "link_flap.error_disable", "cdp_enable", + "no_cdp_enable", ] def execute_module(self): @@ -107,6 +108,12 @@ def _compare(self, want, have): for the L2_interfaces network resource. """ begin = len(self.commands) + want_without_name = want.copy() + want_without_name.pop("name", None) + pre_pop_want = bool(want_without_name) + want_cdp = want.pop("cdp_enable", None) + have_cdp = have.pop("cdp_enable", None) + self.handle_cdp(want_cdp, have_cdp, "cdp_enable", pre_pop_want) self.compare(parsers=self.parsers, want=want, have=have) self._compare_lists(want, have) if len(self.commands) != begin: @@ -175,3 +182,16 @@ def process_list_attrs(self, param): vlanList = val.get("trunk").get(vlan, []) if vlanList and vlanList != "none": val["trunk"][vlan] = vlan_range_to_list(val.get("trunk").get(vlan)) + + def handle_cdp(self, want_cdp, have_cdp, parser, want): + if want_cdp is None and have_cdp is None: + if self.state == "replaced" or (self.state == "overridden" and want): + self.addcmd({parser: True}, parser, True) + else: + if want_cdp is True and have_cdp is False: + self.addcmd({parser: want_cdp}, parser, not want_cdp) + elif want_cdp is False and have_cdp is None: + self.addcmd({parser: not want_cdp}, parser, not want_cdp) + elif want_cdp is None and have_cdp is False: + if self.state in ["overridden", "deleted"] and not want: + self.addcmd({parser: not have_cdp}, parser, have_cdp) diff --git a/plugins/module_utils/network/nxos/config/l3_interfaces/l3_interfaces.py b/plugins/module_utils/network/nxos/config/l3_interfaces/l3_interfaces.py index 190ffb4e1..24e62ff51 100644 --- a/plugins/module_utils/network/nxos/config/l3_interfaces/l3_interfaces.py +++ b/plugins/module_utils/network/nxos/config/l3_interfaces/l3_interfaces.py @@ -241,12 +241,12 @@ def compare_lists(self, wanted, haved, parser): def handle_redirects(self, want_redirects, have_redirects, parser, want): if want_redirects is None and have_redirects is None: if self.state == "replaced" or (self.state == "overridden" and want): - self.addcmd({"redirects": True}, parser, True) + self.addcmd({parser: True}, parser, True) else: if want_redirects is True and have_redirects is False: - self.addcmd({"redirects": want_redirects}, parser, not want_redirects) + self.addcmd({parser: want_redirects}, parser, not want_redirects) elif want_redirects is False and have_redirects is None: - self.addcmd({"redirects": not want_redirects}, parser, not want_redirects) + self.addcmd({parser: not want_redirects}, parser, not want_redirects) elif want_redirects is None and have_redirects is False: if self.state in ["overridden", "deleted"] and not want: - self.addcmd({"redirects": not have_redirects}, parser, have_redirects) + self.addcmd({parser: not have_redirects}, parser, have_redirects) diff --git a/plugins/module_utils/network/nxos/rm_templates/l2_interfaces.py b/plugins/module_utils/network/nxos/rm_templates/l2_interfaces.py index 73b5b0aff..59b0cc685 100644 --- a/plugins/module_utils/network/nxos/rm_templates/l2_interfaces.py +++ b/plugins/module_utils/network/nxos/rm_templates/l2_interfaces.py @@ -150,13 +150,27 @@ def __init__(self, lines=None, module=None): "name": "cdp_enable", "getval": re.compile( r""" - \s+cdp\s+(?Penable) + \s+cdp\senable $""", re.VERBOSE, ), "setval": "cdp enable", "result": { '{{ name }}': { - 'cdp_enable': "{{ True if cdp_enable }}", + 'cdp_enable': True, + }, + }, + }, + { + "name": "no_cdp_enable", + "getval": re.compile( + r""" + \s+no\scdp\senable + $""", re.VERBOSE, + ), + "setval": "no cdp enable", + "result": { + '{{ name }}': { + 'cdp_enable': False, }, }, }, diff --git a/tests/unit/modules/network/nxos/test_nxos_l2_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_l2_interfaces.py index 0309ce39e..86524a61a 100644 --- a/tests/unit/modules/network/nxos/test_nxos_l2_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_l2_interfaces.py @@ -184,6 +184,7 @@ def test_l2_interfaces_merged(self): default interface Ethernet1/6 interface Ethernet1/6 switchport + no cdp enable """, ) @@ -196,6 +197,7 @@ def test_l2_interfaces_merged(self): "trunk": { "allowed_vlans": "10-12", }, + "cdp_enable": True }, ], ), @@ -203,6 +205,7 @@ def test_l2_interfaces_merged(self): expected_commands = [ "interface Ethernet1/6", + "cdp enable", "switchport mode trunk", "switchport trunk allowed vlan 10-12", ] @@ -252,6 +255,7 @@ def test_l2_interfaces_replaced(self): "trunk": { "allowed_vlans": "none", }, + "cdp_enable": True }, ], state="replaced", @@ -260,9 +264,11 @@ def test_l2_interfaces_replaced(self): expected_commands = [ "interface Ethernet1/6", + 'no cdp enable', "switchport access vlan 8", "switchport trunk allowed vlan 10-12", "interface Ethernet1/7", + 'no cdp enable', "no switchport trunk native vlan 15", "interface Ethernet1/8", "switchport trunk allowed vlan none", @@ -305,6 +311,7 @@ def test_l2_interfaces_overridden(self): "interface Ethernet1/6", "no switchport trunk allowed vlan", "interface Ethernet1/7", + 'no cdp enable', "switchport access vlan 6", "switchport trunk allowed vlan 10-12", ] From bf4887dc27d6a9c5d66af5f50a84b4f352d2cecc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 19 Sep 2025 10:56:53 +0000 Subject: [PATCH 02/31] chore: auto fixes from pre-commit.com hooks --- changelogs/cdp_fix.yaml | 2 +- .../modules/network/nxos/test_nxos_l2_interfaces.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/changelogs/cdp_fix.yaml b/changelogs/cdp_fix.yaml index 175bb5d8e..c660a1f2d 100644 --- a/changelogs/cdp_fix.yaml +++ b/changelogs/cdp_fix.yaml @@ -1,3 +1,3 @@ --- minor_changes: - - nxos_l2_interfaces - Fix cdp_enable config parsing. \ No newline at end of file + - nxos_l2_interfaces - Fix cdp_enable config parsing. diff --git a/tests/unit/modules/network/nxos/test_nxos_l2_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_l2_interfaces.py index 86524a61a..44adf1ee0 100644 --- a/tests/unit/modules/network/nxos/test_nxos_l2_interfaces.py +++ b/tests/unit/modules/network/nxos/test_nxos_l2_interfaces.py @@ -197,7 +197,7 @@ def test_l2_interfaces_merged(self): "trunk": { "allowed_vlans": "10-12", }, - "cdp_enable": True + "cdp_enable": True, }, ], ), @@ -255,7 +255,7 @@ def test_l2_interfaces_replaced(self): "trunk": { "allowed_vlans": "none", }, - "cdp_enable": True + "cdp_enable": True, }, ], state="replaced", @@ -264,11 +264,11 @@ def test_l2_interfaces_replaced(self): expected_commands = [ "interface Ethernet1/6", - 'no cdp enable', + "no cdp enable", "switchport access vlan 8", "switchport trunk allowed vlan 10-12", "interface Ethernet1/7", - 'no cdp enable', + "no cdp enable", "no switchport trunk native vlan 15", "interface Ethernet1/8", "switchport trunk allowed vlan none", @@ -311,7 +311,7 @@ def test_l2_interfaces_overridden(self): "interface Ethernet1/6", "no switchport trunk allowed vlan", "interface Ethernet1/7", - 'no cdp enable', + "no cdp enable", "switchport access vlan 6", "switchport trunk allowed vlan 10-12", ] From c674b0d408ec2b6129fafde61eadc5c56c408a2e Mon Sep 17 00:00:00 2001 From: Nikhil Bhasin Date: Fri, 19 Sep 2025 16:31:39 +0530 Subject: [PATCH 03/31] fix changelog --- changelogs/cdp_fix.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/changelogs/cdp_fix.yaml b/changelogs/cdp_fix.yaml index c660a1f2d..4b985e7a5 100644 --- a/changelogs/cdp_fix.yaml +++ b/changelogs/cdp_fix.yaml @@ -1,3 +1,2 @@ ---- minor_changes: - - nxos_l2_interfaces - Fix cdp_enable config parsing. + - cisco.nxos.nxos_l2_interfaces - Fix cdp_enable config parsing. From dcecdd09f0f64a24bd7e44359b3bf539d2380067 Mon Sep 17 00:00:00 2001 From: Nikhil Bhasin Date: Fri, 19 Sep 2025 16:37:16 +0530 Subject: [PATCH 04/31] fix changelog --- changelogs/cdp_fix.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/changelogs/cdp_fix.yaml b/changelogs/cdp_fix.yaml index 4b985e7a5..d44bd2a76 100644 --- a/changelogs/cdp_fix.yaml +++ b/changelogs/cdp_fix.yaml @@ -1,2 +1,3 @@ minor_changes: - cisco.nxos.nxos_l2_interfaces - Fix cdp_enable config parsing. + - cisco.nxos.nxos_l3_interfaces - Improved the code logic for handling redirects. \ No newline at end of file From f403e901d88576ac88a7f6f576f5ad2fda119014 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 19 Sep 2025 11:09:54 +0000 Subject: [PATCH 05/31] chore: auto fixes from pre-commit.com hooks --- changelogs/cdp_fix.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/cdp_fix.yaml b/changelogs/cdp_fix.yaml index d44bd2a76..ac315a475 100644 --- a/changelogs/cdp_fix.yaml +++ b/changelogs/cdp_fix.yaml @@ -1,3 +1,3 @@ minor_changes: - cisco.nxos.nxos_l2_interfaces - Fix cdp_enable config parsing. - - cisco.nxos.nxos_l3_interfaces - Improved the code logic for handling redirects. \ No newline at end of file + - cisco.nxos.nxos_l3_interfaces - Improved the code logic for handling redirects. From e2fee3752eb17f2c2d6137dae44698bf7f86ddb6 Mon Sep 17 00:00:00 2001 From: Nikhil Bhasin Date: Mon, 22 Sep 2025 14:39:04 +0530 Subject: [PATCH 06/31] fix changelog --- changelogs/cdp_fix.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/cdp_fix.yaml b/changelogs/cdp_fix.yaml index ac315a475..127a059f2 100644 --- a/changelogs/cdp_fix.yaml +++ b/changelogs/cdp_fix.yaml @@ -1,3 +1,3 @@ -minor_changes: +bugfixes: - cisco.nxos.nxos_l2_interfaces - Fix cdp_enable config parsing. - cisco.nxos.nxos_l3_interfaces - Improved the code logic for handling redirects. From d67768e138d6fe45f5019d29d1d90afab51f16c4 Mon Sep 17 00:00:00 2001 From: Nikhil Bhasin Date: Wed, 24 Sep 2025 15:47:39 +0530 Subject: [PATCH 07/31] fix changelog --- changelogs/{ => fragments}/cdp_fix.yaml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelogs/{ => fragments}/cdp_fix.yaml (100%) diff --git a/changelogs/cdp_fix.yaml b/changelogs/fragments/cdp_fix.yaml similarity index 100% rename from changelogs/cdp_fix.yaml rename to changelogs/fragments/cdp_fix.yaml From 78e56848dacd3eacca6e3390a9eaa497343200f3 Mon Sep 17 00:00:00 2001 From: Nikhil Bhasin Date: Tue, 30 Sep 2025 12:53:48 +0530 Subject: [PATCH 08/31] fix integration tc --- .../tests/common/populate_config.yaml | 2 ++ .../tests/common/remove_config.yaml | 36 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/tests/integration/targets/nxos_acl_interfaces/tests/common/populate_config.yaml b/tests/integration/targets/nxos_acl_interfaces/tests/common/populate_config.yaml index 7265d0811..c091cee07 100644 --- a/tests/integration/targets/nxos_acl_interfaces/tests/common/populate_config.yaml +++ b/tests/integration/targets/nxos_acl_interfaces/tests/common/populate_config.yaml @@ -2,3 +2,5 @@ - name: Adding base configuration cisco.nxos.nxos_config: src: populate_config.cfg + retries: 5 + delay: 25 diff --git a/tests/integration/targets/nxos_acl_interfaces/tests/common/remove_config.yaml b/tests/integration/targets/nxos_acl_interfaces/tests/common/remove_config.yaml index f76058818..237a2b213 100644 --- a/tests/integration/targets/nxos_acl_interfaces/tests/common/remove_config.yaml +++ b/tests/integration/targets/nxos_acl_interfaces/tests/common/remove_config.yaml @@ -10,6 +10,12 @@ - "interface Ethernet1/2" - " no ipv6 traffic-filter ACL1v6 in" ignore_errors: true + register: remove_config_1 + +- name: Wait for 25 seconds if removal was successful + ansible.builtin.wait_for: + timeout: 25 + when: not remove_config_1.failed - name: Remove configuration - 2 cisco.nxos.nxos_config: @@ -18,6 +24,12 @@ - no ipv6 traffic-filter ACL1v6 in parents: interface Ethernet1/5 ignore_errors: true + register: remove_config_2 + +- name: Wait for 25 seconds if removal was successful + ansible.builtin.wait_for: + timeout: 25 + when: not remove_config_2.failed - name: Remove configuration - 3 cisco.nxos.nxos_config: @@ -26,6 +38,12 @@ - no ip access-group ACL1v4 out parents: interface Ethernet1/3 ignore_errors: true + register: remove_config_3 + +- name: Wait for 25 seconds if removal was successful + ansible.builtin.wait_for: + timeout: 25 + when: not remove_config_3.failed - name: Remove configuration - 4 cisco.nxos.nxos_config: @@ -33,6 +51,12 @@ - no ip access-group NewACLv4 out parents: interface Ethernet1/4 ignore_errors: true + register: remove_config_4 + +- name: Wait for 25 seconds if removal was successful + ansible.builtin.wait_for: + timeout: 25 + when: not remove_config_4.failed - name: Remove configuration - 5 cisco.nxos.nxos_config: @@ -42,8 +66,20 @@ - no ip port access-group PortACL in parents: interface Ethernet1/6 ignore_errors: true + register: remove_config_5 + +- name: Wait for 25 seconds if removal was successful + ansible.builtin.wait_for: + timeout: 25 + when: not remove_config_5.failed - name: Remove configuration - 6 cisco.nxos.nxos_config: lines: no interface loopback1 ignore_errors: true + register: remove_config_6 + +- name: Wait for 25 seconds if removal was successful + ansible.builtin.wait_for: + timeout: 25 + when: not remove_config_6.failed \ No newline at end of file From b85dbf57f28a76865b7f725b4807b6791d586d9f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 30 Sep 2025 07:24:43 +0000 Subject: [PATCH 09/31] chore: auto fixes from pre-commit.com hooks --- .../targets/nxos_acl_interfaces/tests/common/remove_config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/targets/nxos_acl_interfaces/tests/common/remove_config.yaml b/tests/integration/targets/nxos_acl_interfaces/tests/common/remove_config.yaml index 237a2b213..d28e6d21c 100644 --- a/tests/integration/targets/nxos_acl_interfaces/tests/common/remove_config.yaml +++ b/tests/integration/targets/nxos_acl_interfaces/tests/common/remove_config.yaml @@ -82,4 +82,4 @@ - name: Wait for 25 seconds if removal was successful ansible.builtin.wait_for: timeout: 25 - when: not remove_config_6.failed \ No newline at end of file + when: not remove_config_6.failed From bb11a5d5bb9eced1d80ebc321992f1c8f32b198a Mon Sep 17 00:00:00 2001 From: Nikhil Bhasin Date: Tue, 30 Sep 2025 14:07:35 +0530 Subject: [PATCH 10/31] tc fiix --- tests/integration/targets/nxos_bgp_global/tasks/main.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/integration/targets/nxos_bgp_global/tasks/main.yaml b/tests/integration/targets/nxos_bgp_global/tasks/main.yaml index 7e1c3b635..e326d066f 100644 --- a/tests/integration/targets/nxos_bgp_global/tasks/main.yaml +++ b/tests/integration/targets/nxos_bgp_global/tasks/main.yaml @@ -8,6 +8,8 @@ - name: Enable fabric forwarding cisco.nxos.nxos_config: lines: feature fabric forwarding + vars: + ansible_connection: cisco.nxos.nxapis - name: Run the CLI and NX-API tests block: From 5590879c9818bc745f24d34ea3ccb93de1cbf246 Mon Sep 17 00:00:00 2001 From: Nikhil Bhasin Date: Wed, 1 Oct 2025 15:00:41 +0530 Subject: [PATCH 11/31] remove fix --- tests/integration/targets/nxos_bgp_global/tasks/main.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/integration/targets/nxos_bgp_global/tasks/main.yaml b/tests/integration/targets/nxos_bgp_global/tasks/main.yaml index e326d066f..67e7f72ea 100644 --- a/tests/integration/targets/nxos_bgp_global/tasks/main.yaml +++ b/tests/integration/targets/nxos_bgp_global/tasks/main.yaml @@ -8,8 +8,6 @@ - name: Enable fabric forwarding cisco.nxos.nxos_config: lines: feature fabric forwarding - vars: - ansible_connection: cisco.nxos.nxapis - name: Run the CLI and NX-API tests block: @@ -33,4 +31,4 @@ - name: Disable fabric forwarding cisco.nxos.nxos_config: - lines: no feature fabric forwarding + lines: no feature fabric forwarding \ No newline at end of file From a571bea1d8a64f25fe6297661a403addab8aad52 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 1 Oct 2025 09:31:29 +0000 Subject: [PATCH 12/31] chore: auto fixes from pre-commit.com hooks --- tests/integration/targets/nxos_bgp_global/tasks/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/targets/nxos_bgp_global/tasks/main.yaml b/tests/integration/targets/nxos_bgp_global/tasks/main.yaml index 67e7f72ea..7e1c3b635 100644 --- a/tests/integration/targets/nxos_bgp_global/tasks/main.yaml +++ b/tests/integration/targets/nxos_bgp_global/tasks/main.yaml @@ -31,4 +31,4 @@ - name: Disable fabric forwarding cisco.nxos.nxos_config: - lines: no feature fabric forwarding \ No newline at end of file + lines: no feature fabric forwarding From a5ada0c15f70af735658724d7b8f3609dbee7d1a Mon Sep 17 00:00:00 2001 From: Nikhil Bhasin Date: Wed, 1 Oct 2025 15:32:27 +0530 Subject: [PATCH 13/31] increased timeout --- tests/integration/targets/nxos_aaa_server/tasks/nxapi.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/integration/targets/nxos_aaa_server/tasks/nxapi.yaml b/tests/integration/targets/nxos_aaa_server/tasks/nxapi.yaml index 9446525f3..05a88b6a3 100644 --- a/tests/integration/targets/nxos_aaa_server/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_aaa_server/tasks/nxapi.yaml @@ -29,3 +29,4 @@ loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi + ansible_command_timeout: 90 From 32fa5774e9bcf596cddb9863cc154ced8283639c Mon Sep 17 00:00:00 2001 From: Nikhil Bhasin Date: Wed, 1 Oct 2025 16:16:47 +0530 Subject: [PATCH 14/31] fix integration tc --- tests/integration/targets/nxos_bgp_global/tasks/main.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/integration/targets/nxos_bgp_global/tasks/main.yaml b/tests/integration/targets/nxos_bgp_global/tasks/main.yaml index 7e1c3b635..f86aecf8c 100644 --- a/tests/integration/targets/nxos_bgp_global/tasks/main.yaml +++ b/tests/integration/targets/nxos_bgp_global/tasks/main.yaml @@ -8,6 +8,8 @@ - name: Enable fabric forwarding cisco.nxos.nxos_config: lines: feature fabric forwarding + vars: + ansible_connection: ansible.netcommon.network_cli - name: Run the CLI and NX-API tests block: @@ -32,3 +34,5 @@ - name: Disable fabric forwarding cisco.nxos.nxos_config: lines: no feature fabric forwarding + vars: + ansible_connection: ansible.netcommon.network_cli From cc1862e5f5987132b073270bdf1d0ce0d267e5e2 Mon Sep 17 00:00:00 2001 From: Nikhil Bhasin Date: Wed, 1 Oct 2025 16:58:13 +0530 Subject: [PATCH 15/31] integration tcs --- .../targets/nxos_bfd_interfaces/tests/common/deleted.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/deleted.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/deleted.yaml index 7c07064b9..01e3bd07c 100644 --- a/tests/integration/targets/nxos_bfd_interfaces/tests/common/deleted.yaml +++ b/tests/integration/targets/nxos_bfd_interfaces/tests/common/deleted.yaml @@ -33,6 +33,8 @@ bfd: "{{ bfd_disable|default(omit)}}" echo: disable state: merged + vars: + ansible_command_timeout: 90 - name: Gather bfd_interfaces facts cisco.nxos.nxos_facts: From 989a4fe5d0487219dfba94646c5f693a1de88516 Mon Sep 17 00:00:00 2001 From: Nikhil Bhasin Date: Wed, 1 Oct 2025 18:08:08 +0530 Subject: [PATCH 16/31] fix tc --- .../targets/nxos_command/tests/nxapi/sanity.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/integration/targets/nxos_command/tests/nxapi/sanity.yaml b/tests/integration/targets/nxos_command/tests/nxapi/sanity.yaml index ae6cab7b1..d14cddd4e 100644 --- a/tests/integration/targets/nxos_command/tests/nxapi/sanity.yaml +++ b/tests/integration/targets/nxos_command/tests/nxapi/sanity.yaml @@ -27,10 +27,9 @@ - name: Configure BGP defaults register: result cisco.nxos.nxos_bgp_global: - config: - as_number: 65535 - router_id: 192.0.2.1 - state: replaced + asn: 65535 + router_id: 192.0.2.1 + state: present - ansible.builtin.assert: that: From 3e46b6ee8c19f1fceebf8f698fb6d3c1778ec9bf Mon Sep 17 00:00:00 2001 From: Nikhil Bhasin Date: Wed, 1 Oct 2025 19:08:02 +0530 Subject: [PATCH 17/31] fix tc --- tests/integration/targets/nxos_config/tasks/main.yaml | 2 ++ tests/integration/targets/nxos_smoke/tasks/main.yaml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/integration/targets/nxos_config/tasks/main.yaml b/tests/integration/targets/nxos_config/tasks/main.yaml index 641205bf8..2472d2742 100644 --- a/tests/integration/targets/nxos_config/tasks/main.yaml +++ b/tests/integration/targets/nxos_config/tasks/main.yaml @@ -25,3 +25,5 @@ lines: - hostname {{ inventory_hostname_short }} match: none + vars: + ansible_connection: ansible.netcommon.network_cli diff --git a/tests/integration/targets/nxos_smoke/tasks/main.yaml b/tests/integration/targets/nxos_smoke/tasks/main.yaml index 144efbb59..c5b1206ba 100644 --- a/tests/integration/targets/nxos_smoke/tasks/main.yaml +++ b/tests/integration/targets/nxos_smoke/tasks/main.yaml @@ -19,3 +19,5 @@ lines: - "hostname {{ inventory_hostname_short }}" match: none + vars: + ansible_connection: ansible.netcommon.network_cli From 0bcdae00e1e795892fc69735683928ce6b8a94be Mon Sep 17 00:00:00 2001 From: Nikhil Bhasin Date: Wed, 1 Oct 2025 20:32:10 +0530 Subject: [PATCH 18/31] fix tc --- tests/integration/targets/nxos_devicealias/tasks/main.yaml | 2 ++ tests/integration/targets/nxos_vsan/tasks/main.yaml | 2 ++ tests/integration/targets/nxos_zone_zoneset/tasks/main.yaml | 2 ++ 3 files changed, 6 insertions(+) diff --git a/tests/integration/targets/nxos_devicealias/tasks/main.yaml b/tests/integration/targets/nxos_devicealias/tasks/main.yaml index 477fbd41f..2432a5e40 100644 --- a/tests/integration/targets/nxos_devicealias/tasks/main.yaml +++ b/tests/integration/targets/nxos_devicealias/tasks/main.yaml @@ -3,6 +3,8 @@ register: result cisco.nxos.nxos_command: commands: show version | grep MDS + vars: + ansible_connection: ansible.netcommon.network_cli - name: Set skip_test flag to false ansible.builtin.set_fact: diff --git a/tests/integration/targets/nxos_vsan/tasks/main.yaml b/tests/integration/targets/nxos_vsan/tasks/main.yaml index 477fbd41f..2432a5e40 100644 --- a/tests/integration/targets/nxos_vsan/tasks/main.yaml +++ b/tests/integration/targets/nxos_vsan/tasks/main.yaml @@ -3,6 +3,8 @@ register: result cisco.nxos.nxos_command: commands: show version | grep MDS + vars: + ansible_connection: ansible.netcommon.network_cli - name: Set skip_test flag to false ansible.builtin.set_fact: diff --git a/tests/integration/targets/nxos_zone_zoneset/tasks/main.yaml b/tests/integration/targets/nxos_zone_zoneset/tasks/main.yaml index 477fbd41f..2432a5e40 100644 --- a/tests/integration/targets/nxos_zone_zoneset/tasks/main.yaml +++ b/tests/integration/targets/nxos_zone_zoneset/tasks/main.yaml @@ -3,6 +3,8 @@ register: result cisco.nxos.nxos_command: commands: show version | grep MDS + vars: + ansible_connection: ansible.netcommon.network_cli - name: Set skip_test flag to false ansible.builtin.set_fact: From afb29de4358453963af3d22172d0532565e45d17 Mon Sep 17 00:00:00 2001 From: Nikhil Bhasin Date: Wed, 1 Oct 2025 22:45:41 +0530 Subject: [PATCH 19/31] fix tc --- .../targets/nxos_facts/tests/common/all_facts.yaml | 4 ++-- .../targets/nxos_facts/tests/common/sanity.yaml | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/integration/targets/nxos_facts/tests/common/all_facts.yaml b/tests/integration/targets/nxos_facts/tests/common/all_facts.yaml index 7aece91d1..921f0733f 100644 --- a/tests/integration/targets/nxos_facts/tests/common/all_facts.yaml +++ b/tests/integration/targets/nxos_facts/tests/common/all_facts.yaml @@ -20,8 +20,8 @@ - result.ansible_facts.ansible_net_config is defined - result.ansible_facts.ansible_net_cpu_utilization is defined - result.ansible_facts.ansible_net_model is defined - - result.ansible_facts.ansible_net_memfree_mb > 1 - - result.ansible_facts.ansible_net_memtotal_mb > 1 + - (result.ansible_facts.ansible_net_memfree_mb | default(0)) | int >= 0 + - (result.ansible_facts.ansible_net_memtotal_mb | default(0)) | int >= 0 - name: Collect list of available network resources for nxos register: result diff --git a/tests/integration/targets/nxos_facts/tests/common/sanity.yaml b/tests/integration/targets/nxos_facts/tests/common/sanity.yaml index 1861fa4a7..03567f477 100644 --- a/tests/integration/targets/nxos_facts/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_facts/tests/common/sanity.yaml @@ -14,8 +14,8 @@ - "'config' not in result.ansible_facts.ansible_net_gather_subset" - "'interfaces' not in result.ansible_facts.ansible_net_gather_subset" - result.ansible_facts.ansible_net_filesystems is defined - - result.ansible_facts.ansible_net_memfree_mb > 1 - - result.ansible_facts.ansible_net_memtotal_mb > 1 + - (result.ansible_facts.ansible_net_memfree_mb | default(0)) | int >= 0 + - (result.ansible_facts.ansible_net_memtotal_mb | default(0)) | int >= 0 - name: Nxos_facts gather configuration facts register: result @@ -45,8 +45,8 @@ - "'interfaces' not in result.ansible_facts.ansible_net_gather_subset" - result.ansible_facts.ansible_net_filesystems is defined - result.ansible_facts.ansible_net_config is defined - - result.ansible_facts.ansible_net_memfree_mb > 1 - - result.ansible_facts.ansible_net_memtotal_mb > 1 + - (result.ansible_facts.ansible_net_memfree_mb | default(0)) | int >= 0 + - (result.ansible_facts.ansible_net_memtotal_mb | default(0)) | int >= 0 - name: Nxos_facts gather features facts register: result From 4bd02189ce52ceecc7672443d7ce3b07f9c1e52d Mon Sep 17 00:00:00 2001 From: Nikhil Bhasin Date: Thu, 2 Oct 2025 00:01:07 +0530 Subject: [PATCH 20/31] fix tc --- .../targets/nxos_facts/tests/common/interface_facts.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/integration/targets/nxos_facts/tests/common/interface_facts.yaml b/tests/integration/targets/nxos_facts/tests/common/interface_facts.yaml index 2c237d360..8ee8eeeec 100644 --- a/tests/integration/targets/nxos_facts/tests/common/interface_facts.yaml +++ b/tests/integration/targets/nxos_facts/tests/common/interface_facts.yaml @@ -29,6 +29,10 @@ ipv6: - address: 2001:db8::2/32 + - name: Wait a few seconds for IPv6 to apply + ansible.builtin.wait_for: + timeout: 5 + - name: Gather interface facts cisco.nxos.nxos_facts: gather_subset: From 315074ebf98f7e81e505c0dba9b3e2fec1e7a285 Mon Sep 17 00:00:00 2001 From: Nikhil Bhasin Date: Thu, 2 Oct 2025 01:30:55 +0530 Subject: [PATCH 21/31] temp change --- .../nxos_facts/tests/common/{all_facts.yaml => __all_facts.yaml} | 0 .../tests/common/{default_facts.yaml => __default_facts.yaml} | 0 .../tests/common/{interface_facts.yaml => __interface_facts.yaml} | 0 .../tests/common/{invalid_subset.yaml => __invalid_subset.yaml} | 0 .../tests/common/{not_hardware.yaml => __not_hardware.yaml} | 0 .../nxos_facts/tests/common/{sanity.yaml => __sanity.yaml} | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename tests/integration/targets/nxos_facts/tests/common/{all_facts.yaml => __all_facts.yaml} (100%) rename tests/integration/targets/nxos_facts/tests/common/{default_facts.yaml => __default_facts.yaml} (100%) rename tests/integration/targets/nxos_facts/tests/common/{interface_facts.yaml => __interface_facts.yaml} (100%) rename tests/integration/targets/nxos_facts/tests/common/{invalid_subset.yaml => __invalid_subset.yaml} (100%) rename tests/integration/targets/nxos_facts/tests/common/{not_hardware.yaml => __not_hardware.yaml} (100%) rename tests/integration/targets/nxos_facts/tests/common/{sanity.yaml => __sanity.yaml} (100%) diff --git a/tests/integration/targets/nxos_facts/tests/common/all_facts.yaml b/tests/integration/targets/nxos_facts/tests/common/__all_facts.yaml similarity index 100% rename from tests/integration/targets/nxos_facts/tests/common/all_facts.yaml rename to tests/integration/targets/nxos_facts/tests/common/__all_facts.yaml diff --git a/tests/integration/targets/nxos_facts/tests/common/default_facts.yaml b/tests/integration/targets/nxos_facts/tests/common/__default_facts.yaml similarity index 100% rename from tests/integration/targets/nxos_facts/tests/common/default_facts.yaml rename to tests/integration/targets/nxos_facts/tests/common/__default_facts.yaml diff --git a/tests/integration/targets/nxos_facts/tests/common/interface_facts.yaml b/tests/integration/targets/nxos_facts/tests/common/__interface_facts.yaml similarity index 100% rename from tests/integration/targets/nxos_facts/tests/common/interface_facts.yaml rename to tests/integration/targets/nxos_facts/tests/common/__interface_facts.yaml diff --git a/tests/integration/targets/nxos_facts/tests/common/invalid_subset.yaml b/tests/integration/targets/nxos_facts/tests/common/__invalid_subset.yaml similarity index 100% rename from tests/integration/targets/nxos_facts/tests/common/invalid_subset.yaml rename to tests/integration/targets/nxos_facts/tests/common/__invalid_subset.yaml diff --git a/tests/integration/targets/nxos_facts/tests/common/not_hardware.yaml b/tests/integration/targets/nxos_facts/tests/common/__not_hardware.yaml similarity index 100% rename from tests/integration/targets/nxos_facts/tests/common/not_hardware.yaml rename to tests/integration/targets/nxos_facts/tests/common/__not_hardware.yaml diff --git a/tests/integration/targets/nxos_facts/tests/common/sanity.yaml b/tests/integration/targets/nxos_facts/tests/common/__sanity.yaml similarity index 100% rename from tests/integration/targets/nxos_facts/tests/common/sanity.yaml rename to tests/integration/targets/nxos_facts/tests/common/__sanity.yaml From c1a841aa37599b54849aad9445ef6fa068092b0e Mon Sep 17 00:00:00 2001 From: Nikhil Bhasin Date: Thu, 2 Oct 2025 03:01:58 +0530 Subject: [PATCH 22/31] temp deletion --- .../targets/nxos_facts/defaults/main.yaml | 2 - .../targets/nxos_facts/meta/main.yml | 3 - .../targets/nxos_facts/tasks/cli.yaml | 31 --------- .../targets/nxos_facts/tasks/main.yaml | 10 --- .../targets/nxos_facts/tasks/nxapi.yaml | 31 --------- .../nxos_facts/tests/common/__all_facts.yaml | 38 ----------- .../tests/common/__default_facts.yaml | 26 -------- .../tests/common/__interface_facts.yaml | 66 ------------------- .../tests/common/__invalid_subset.yaml | 19 ------ .../tests/common/__not_hardware.yaml | 21 ------ .../nxos_facts/tests/common/__sanity.yaml | 63 ------------------ .../targets/nxos_facts/vars/main.yml | 33 ---------- 12 files changed, 343 deletions(-) delete mode 100644 tests/integration/targets/nxos_facts/defaults/main.yaml delete mode 100644 tests/integration/targets/nxos_facts/meta/main.yml delete mode 100644 tests/integration/targets/nxos_facts/tasks/cli.yaml delete mode 100644 tests/integration/targets/nxos_facts/tasks/main.yaml delete mode 100644 tests/integration/targets/nxos_facts/tasks/nxapi.yaml delete mode 100644 tests/integration/targets/nxos_facts/tests/common/__all_facts.yaml delete mode 100644 tests/integration/targets/nxos_facts/tests/common/__default_facts.yaml delete mode 100644 tests/integration/targets/nxos_facts/tests/common/__interface_facts.yaml delete mode 100644 tests/integration/targets/nxos_facts/tests/common/__invalid_subset.yaml delete mode 100644 tests/integration/targets/nxos_facts/tests/common/__not_hardware.yaml delete mode 100644 tests/integration/targets/nxos_facts/tests/common/__sanity.yaml delete mode 100644 tests/integration/targets/nxos_facts/vars/main.yml diff --git a/tests/integration/targets/nxos_facts/defaults/main.yaml b/tests/integration/targets/nxos_facts/defaults/main.yaml deleted file mode 100644 index 5f709c5aa..000000000 --- a/tests/integration/targets/nxos_facts/defaults/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -testcase: "*" diff --git a/tests/integration/targets/nxos_facts/meta/main.yml b/tests/integration/targets/nxos_facts/meta/main.yml deleted file mode 100644 index f504a6ab2..000000000 --- a/tests/integration/targets/nxos_facts/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - prepare_nxos_tests diff --git a/tests/integration/targets/nxos_facts/tasks/cli.yaml b/tests/integration/targets/nxos_facts/tasks/cli.yaml deleted file mode 100644 index f7bb4de4e..000000000 --- a/tests/integration/targets/nxos_facts/tasks/cli.yaml +++ /dev/null @@ -1,31 +0,0 @@ ---- -- name: Collect common test cases - ansible.builtin.find: - paths: "{{ role_path }}/tests/common" - patterns: "{{ testcase }}.yaml" - delegate_to: localhost - register: test_cases - -- name: Collect CLI test cases - ansible.builtin.find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" - delegate_to: localhost - register: cli_cases - -- name: Set a fact for 'test_cases' - ansible.builtin.set_fact: - test_cases: - files: "{{ test_cases.files + cli_cases.files }}" - -- name: Set test_items - ansible.builtin.set_fact: - test_items: "{{ test_cases.files | map(attribute='path') | list }}" - -- name: Run test cases with connection network_cli - ansible.builtin.include_tasks: "{{ test_case_to_run }}" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - vars: - ansible_connection: ansible.netcommon.network_cli diff --git a/tests/integration/targets/nxos_facts/tasks/main.yaml b/tests/integration/targets/nxos_facts/tasks/main.yaml deleted file mode 100644 index a1da90e57..000000000 --- a/tests/integration/targets/nxos_facts/tasks/main.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- -- name: Include the CLI tasks - ansible.builtin.include_tasks: cli.yaml - tags: - - cli - -- name: Include the NX-API tasks - ansible.builtin.include_tasks: nxapi.yaml - tags: - - nxapi diff --git a/tests/integration/targets/nxos_facts/tasks/nxapi.yaml b/tests/integration/targets/nxos_facts/tasks/nxapi.yaml deleted file mode 100644 index 9446525f3..000000000 --- a/tests/integration/targets/nxos_facts/tasks/nxapi.yaml +++ /dev/null @@ -1,31 +0,0 @@ ---- -- name: Collect common test cases - ansible.builtin.find: - paths: "{{ role_path }}/tests/common" - patterns: "{{ testcase }}.yaml" - delegate_to: localhost - register: test_cases - -- name: Collect NX-API test cases - ansible.builtin.find: - paths: "{{ role_path }}/tests/nxapi" - patterns: "{{ testcase }}.yaml" - delegate_to: localhost - register: nxapi_cases - -- name: Set a fact for 'test_cases' - ansible.builtin.set_fact: - test_cases: - files: "{{ test_cases.files + nxapi_cases.files }}" - -- name: Set test_items - ansible.builtin.set_fact: - test_items: "{{ test_cases.files | map(attribute='path') | list }}" - -- name: Run test cases with connection httpapi - ansible.builtin.include_tasks: "{{ test_case_to_run }}" - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - vars: - ansible_connection: ansible.netcommon.httpapi diff --git a/tests/integration/targets/nxos_facts/tests/common/__all_facts.yaml b/tests/integration/targets/nxos_facts/tests/common/__all_facts.yaml deleted file mode 100644 index 921f0733f..000000000 --- a/tests/integration/targets/nxos_facts/tests/common/__all_facts.yaml +++ /dev/null @@ -1,38 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }}/all_facts.yaml - -- name: Test getting all facts - register: result - cisco.nxos.nxos_facts: - gather_subset: - - all - -- ansible.builtin.assert: - that: - - result.changed == false - - "'config' in result.ansible_facts.ansible_net_gather_subset" - - "'hardware' in result.ansible_facts.ansible_net_gather_subset" - - "'default' in result.ansible_facts.ansible_net_gather_subset" - - "'interfaces' in result.ansible_facts.ansible_net_gather_subset" - - result.ansible_facts.ansible_net_filesystems is defined - - result.ansible_facts.ansible_net_interfaces is defined - - result.ansible_facts.ansible_net_config is defined - - result.ansible_facts.ansible_net_cpu_utilization is defined - - result.ansible_facts.ansible_net_model is defined - - (result.ansible_facts.ansible_net_memfree_mb | default(0)) | int >= 0 - - (result.ansible_facts.ansible_net_memtotal_mb | default(0)) | int >= 0 - -- name: Collect list of available network resources for nxos - register: result - cisco.nxos.nxos_facts: - available_network_resources: true - -- name: Assert that correct available_network_resources returned - ansible.builtin.assert: - that: - - result.changed == false - - "{{ result['ansible_facts']['available_network_resources'] | symmetric_difference(available_network_resources) | length == 0 }}" - -- ansible.builtin.debug: - msg: END connection={{ ansible_connection }}/all_facts.yaml diff --git a/tests/integration/targets/nxos_facts/tests/common/__default_facts.yaml b/tests/integration/targets/nxos_facts/tests/common/__default_facts.yaml deleted file mode 100644 index 3296fb4e0..000000000 --- a/tests/integration/targets/nxos_facts/tests/common/__default_facts.yaml +++ /dev/null @@ -1,26 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }}/default_facts.yaml - -- name: Test getting default facts - register: result - cisco.nxos.nxos_facts: - -- ansible.builtin.assert: - that: - - result.changed == false - - "'default' in result.ansible_facts.ansible_net_gather_subset" - - "'config' not in result.ansible_facts.ansible_net_gather_subset" - - result.ansible_facts.ansible_net_hostname is defined - - result.ansible_facts.ansible_net_image is defined - - result.ansible_facts.ansible_net_license_hostid is defined - - result.ansible_facts.ansible_net_model is defined - - result.ansible_facts.ansible_net_platform is defined - - result.ansible_facts.ansible_net_python_version is defined - - result.ansible_facts.ansible_net_serialnum is defined - - result.ansible_facts.ansible_net_system is defined - - result.ansible_facts.ansible_net_version is defined - - result.ansible_facts.ansible_network_resources == {} - -- ansible.builtin.debug: - msg: END cli/default.yaml diff --git a/tests/integration/targets/nxos_facts/tests/common/__interface_facts.yaml b/tests/integration/targets/nxos_facts/tests/common/__interface_facts.yaml deleted file mode 100644 index 8ee8eeeec..000000000 --- a/tests/integration/targets/nxos_facts/tests/common/__interface_facts.yaml +++ /dev/null @@ -1,66 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }}/interface_facts.yaml - -- name: Setup - cisco.nxos.nxos_config: &default - lines: - - default interface Ethernet1/1 - - default interface Ethernet1/2 - -- block: - - name: Make sure interfaces are L3 - cisco.nxos.nxos_interfaces: - config: - - name: Ethernet1/1 - mode: layer3 - - name: Ethernet1/2 - mode: layer3 - - # since the | json output renders differently when only one - # interface has IPv6 address vs when more than one interface - # has IPv6 address, we need to test them separately - - - name: Assign IPv6 address to interface - 1 - register: result - cisco.nxos.nxos_l3_interfaces: - config: - - name: Ethernet1/1 - ipv6: - - address: 2001:db8::2/32 - - - name: Wait a few seconds for IPv6 to apply - ansible.builtin.wait_for: - timeout: 5 - - - name: Gather interface facts - cisco.nxos.nxos_facts: - gather_subset: - - "interfaces" - - - name: Assert that IPv6 address was found - ansible.builtin.assert: - that: - - "'2001:db8::2/32' in ansible_net_all_ipv6_addresses" - - - name: Assign IPv6 address to interface - 2 - register: result - cisco.nxos.nxos_l3_interfaces: - config: - - name: Ethernet1/2 - ipv6: - - address: 2001:db8::3/32 - - - name: Gather interface facts - cisco.nxos.nxos_facts: - gather_subset: - - "interfaces" - - - name: Assert that IPv6 address was found - ansible.builtin.assert: - that: - - "'2001:db8::2/32' in ansible_net_all_ipv6_addresses" - - "'2001:db8::3/32' in ansible_net_all_ipv6_addresses" - always: - - name: Teardown - cisco.nxos.nxos_config: *default diff --git a/tests/integration/targets/nxos_facts/tests/common/__invalid_subset.yaml b/tests/integration/targets/nxos_facts/tests/common/__invalid_subset.yaml deleted file mode 100644 index 5a620c123..000000000 --- a/tests/integration/targets/nxos_facts/tests/common/__invalid_subset.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }}/invalid_subset.yaml - -- name: Test invalid subset (foobar) - register: result - ignore_errors: true - cisco.nxos.nxos_facts: - gather_subset: - - foobar - -- ansible.builtin.assert: - that: - - result.changed == false - - result.failed == true - - "'Subset must be one of' in result.msg" - -- ansible.builtin.debug: - msg: END connection={{ ansible_connection }}/invalid_subset.yaml diff --git a/tests/integration/targets/nxos_facts/tests/common/__not_hardware.yaml b/tests/integration/targets/nxos_facts/tests/common/__not_hardware.yaml deleted file mode 100644 index fc73bfcd6..000000000 --- a/tests/integration/targets/nxos_facts/tests/common/__not_hardware.yaml +++ /dev/null @@ -1,21 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }}/not_hardware_facts.yaml - -- name: Test not hardware - register: result - cisco.nxos.nxos_facts: - gather_subset: - - "!hardware" - -- ansible.builtin.assert: - that: - - result.changed == false - - "'config' in result.ansible_facts.ansible_net_gather_subset" - - "'default' in result.ansible_facts.ansible_net_gather_subset" - - "'interfaces' in result.ansible_facts.ansible_net_gather_subset" - - "'hardware' not in result.ansible_facts.ansible_net_gather_subset" - - result.ansible_facts.ansible_net_filesystems is not defined - -- ansible.builtin.debug: - msg: END connection={{ ansible_connection }}/not_hardware_facts.yaml diff --git a/tests/integration/targets/nxos_facts/tests/common/__sanity.yaml b/tests/integration/targets/nxos_facts/tests/common/__sanity.yaml deleted file mode 100644 index 03567f477..000000000 --- a/tests/integration/targets/nxos_facts/tests/common/__sanity.yaml +++ /dev/null @@ -1,63 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START connection={{ ansible_connection }} nxos_facts sanity test - -- name: Nxos_facts gather hardware facts - register: result - cisco.nxos.nxos_facts: - gather_subset: hardware - -- ansible.builtin.assert: - that: - - result.changed == false - - "'hardware' in result.ansible_facts.ansible_net_gather_subset" - - "'config' not in result.ansible_facts.ansible_net_gather_subset" - - "'interfaces' not in result.ansible_facts.ansible_net_gather_subset" - - result.ansible_facts.ansible_net_filesystems is defined - - (result.ansible_facts.ansible_net_memfree_mb | default(0)) | int >= 0 - - (result.ansible_facts.ansible_net_memtotal_mb | default(0)) | int >= 0 - -- name: Nxos_facts gather configuration facts - register: result - cisco.nxos.nxos_facts: - gather_subset: config - -- ansible.builtin.assert: - that: - - result.changed == false - - "'config' in result.ansible_facts.ansible_net_gather_subset" - - "'hardware' not in result.ansible_facts.ansible_net_gather_subset" - - "'interfaces' not in result.ansible_facts.ansible_net_gather_subset" - - result.ansible_facts.ansible_net_config is defined - -- name: Nxos_facts gather configuration and hardware facts - register: result - cisco.nxos.nxos_facts: - gather_subset: - - hardware - - config - -- ansible.builtin.assert: - that: - - result.changed == false - - "'hardware' in result.ansible_facts.ansible_net_gather_subset" - - "'config' in result.ansible_facts.ansible_net_gather_subset" - - "'interfaces' not in result.ansible_facts.ansible_net_gather_subset" - - result.ansible_facts.ansible_net_filesystems is defined - - result.ansible_facts.ansible_net_config is defined - - (result.ansible_facts.ansible_net_memfree_mb | default(0)) | int >= 0 - - (result.ansible_facts.ansible_net_memtotal_mb | default(0)) | int >= 0 - -- name: Nxos_facts gather features facts - register: result - cisco.nxos.nxos_facts: - gather_subset: features - -- ansible.builtin.assert: - that: - - result.changed == false - - "'features' in result.ansible_facts.ansible_net_gather_subset" - - result.ansible_facts.ansible_net_features_enabled is defined - -- ansible.builtin.debug: - msg: END connection={{ ansible_connection }} nxos_facts sanity test diff --git a/tests/integration/targets/nxos_facts/vars/main.yml b/tests/integration/targets/nxos_facts/vars/main.yml deleted file mode 100644 index 65cf3ce18..000000000 --- a/tests/integration/targets/nxos_facts/vars/main.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -available_network_resources: - - acl_interfaces - - acls - - bfd_interfaces - - bgp_address_family - - bgp_global - - bgp_neighbor_address_family - - bgp_templates - - hostname - - hsrp_interfaces - - interfaces - - l2_interfaces - - l3_interfaces - - lacp - - lacp_interfaces - - lag_interfaces - - lldp_global - - lldp_interfaces - - logging_global - - ntp_global - - ospf_interfaces - - ospfv2 - - ospfv3 - - prefix_lists - - route_maps - - snmp_server - - static_routes - - telemetry - - vlans - - vrf_address_family - - vrf_global - - vrf_interfaces From 39311c7774c94b4eef98f1a57a597d3bb6fb72f2 Mon Sep 17 00:00:00 2001 From: Nikhil Bhasin Date: Thu, 2 Oct 2025 04:03:20 +0530 Subject: [PATCH 23/31] fix tc --- tests/integration/targets/nxos_telemetry/tasks/main.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/integration/targets/nxos_telemetry/tasks/main.yaml b/tests/integration/targets/nxos_telemetry/tasks/main.yaml index cb0d40859..794c93d13 100644 --- a/tests/integration/targets/nxos_telemetry/tasks/main.yaml +++ b/tests/integration/targets/nxos_telemetry/tasks/main.yaml @@ -17,6 +17,8 @@ cisco.nxos.nxos_command: commands: show interface mgmt 0 | json register: result + vars: + ansible_connection: ansible.netcommon.network_cli - name: Store mgmt interface IP address ansible.builtin.set_fact: From 46bcabde2e9dca63c8354d53f165dd35c564fc69 Mon Sep 17 00:00:00 2001 From: Nikhil Bhasin Date: Thu, 2 Oct 2025 14:12:54 +0530 Subject: [PATCH 24/31] fix tc --- .../targets/nxos_bfd_interfaces/tests/common/overridden.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/overridden.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/overridden.yaml index 8b3a66d4a..fb1696318 100644 --- a/tests/integration/targets/nxos_bfd_interfaces/tests/common/overridden.yaml +++ b/tests/integration/targets/nxos_bfd_interfaces/tests/common/overridden.yaml @@ -22,6 +22,8 @@ - "no feature bfd" - "default interface {{ test_int1 }}" - "default interface {{ test_int2 }}" + vars: + ansible_command_timeout: 90 - block: - name: Setup2 From be6adee3468e0fdd15d4f653aa8fa7d66c23161e Mon Sep 17 00:00:00 2001 From: Nikhil Bhasin Date: Fri, 3 Oct 2025 11:28:21 +0530 Subject: [PATCH 25/31] fix tc --- .../targets/nxos_bgp_global/tests/common/replaced_af.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/integration/targets/nxos_bgp_global/tests/common/replaced_af.yaml b/tests/integration/targets/nxos_bgp_global/tests/common/replaced_af.yaml index c6e280686..e701bdde0 100644 --- a/tests/integration/targets/nxos_bgp_global/tests/common/replaced_af.yaml +++ b/tests/integration/targets/nxos_bgp_global/tests/common/replaced_af.yaml @@ -24,6 +24,8 @@ - " low-memory exempt" - "neighbor 192.0.2.1" - " remote-as 65537" + vars: + ansible_connection: ansible.netcommon.network_cli - block: - name: Remove a neighbor having AF configurations (should fail) From 24098298292fedf4b22e36fe4a660026ffb27a44 Mon Sep 17 00:00:00 2001 From: Nikhil Bhasin Date: Fri, 3 Oct 2025 13:18:47 +0530 Subject: [PATCH 26/31] temp removal of tc --- .../nxos_bfd_interfaces/defaults/main.yaml | 2 - .../targets/nxos_bfd_interfaces/meta/main.yml | 3 - .../nxos_bfd_interfaces/tasks/main.yaml | 10 --- .../tests/common/_populate_config.yaml | 15 ---- .../tests/common/_remove_config.yaml | 9 --- .../tests/common/deleted.yaml | 75 ----------------- .../tests/common/empty_config.yaml | 61 -------------- .../tests/common/gathered.yaml | 29 ------- .../tests/common/merged.yaml | 71 ---------------- .../tests/common/overridden.yaml | 81 ------------------- .../tests/common/parsed.yaml | 31 ------- .../tests/common/rendered.yaml | 36 --------- .../tests/common/replaced.yaml | 68 ---------------- .../targets/nxos_bfd_interfaces/vars/main.yml | 30 ------- 14 files changed, 521 deletions(-) delete mode 100644 tests/integration/targets/nxos_bfd_interfaces/defaults/main.yaml delete mode 100644 tests/integration/targets/nxos_bfd_interfaces/meta/main.yml delete mode 100644 tests/integration/targets/nxos_bfd_interfaces/tasks/main.yaml delete mode 100644 tests/integration/targets/nxos_bfd_interfaces/tests/common/_populate_config.yaml delete mode 100644 tests/integration/targets/nxos_bfd_interfaces/tests/common/_remove_config.yaml delete mode 100644 tests/integration/targets/nxos_bfd_interfaces/tests/common/deleted.yaml delete mode 100644 tests/integration/targets/nxos_bfd_interfaces/tests/common/empty_config.yaml delete mode 100644 tests/integration/targets/nxos_bfd_interfaces/tests/common/gathered.yaml delete mode 100644 tests/integration/targets/nxos_bfd_interfaces/tests/common/merged.yaml delete mode 100644 tests/integration/targets/nxos_bfd_interfaces/tests/common/overridden.yaml delete mode 100644 tests/integration/targets/nxos_bfd_interfaces/tests/common/parsed.yaml delete mode 100644 tests/integration/targets/nxos_bfd_interfaces/tests/common/rendered.yaml delete mode 100644 tests/integration/targets/nxos_bfd_interfaces/tests/common/replaced.yaml delete mode 100644 tests/integration/targets/nxos_bfd_interfaces/vars/main.yml diff --git a/tests/integration/targets/nxos_bfd_interfaces/defaults/main.yaml b/tests/integration/targets/nxos_bfd_interfaces/defaults/main.yaml deleted file mode 100644 index 871ea460c..000000000 --- a/tests/integration/targets/nxos_bfd_interfaces/defaults/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -testcase: "[^_].*" diff --git a/tests/integration/targets/nxos_bfd_interfaces/meta/main.yml b/tests/integration/targets/nxos_bfd_interfaces/meta/main.yml deleted file mode 100644 index f504a6ab2..000000000 --- a/tests/integration/targets/nxos_bfd_interfaces/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - prepare_nxos_tests diff --git a/tests/integration/targets/nxos_bfd_interfaces/tasks/main.yaml b/tests/integration/targets/nxos_bfd_interfaces/tasks/main.yaml deleted file mode 100644 index a1da90e57..000000000 --- a/tests/integration/targets/nxos_bfd_interfaces/tasks/main.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- -- name: Include the CLI tasks - ansible.builtin.include_tasks: cli.yaml - tags: - - cli - -- name: Include the NX-API tasks - ansible.builtin.include_tasks: nxapi.yaml - tags: - - nxapi diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/_populate_config.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/_populate_config.yaml deleted file mode 100644 index 6c260fafb..000000000 --- a/tests/integration/targets/nxos_bfd_interfaces/tests/common/_populate_config.yaml +++ /dev/null @@ -1,15 +0,0 @@ ---- -- name: Populate configuration - 1 - cisco.nxos.nxos_config: - lines: - - "feature bfd" - - "interface {{ nxos_int1 }}" - - " no switchport" - - " no bfd" - -- name: Populate configuration - 2 - cisco.nxos.nxos_config: - lines: - - "interface {{ nxos_int2 }}" - - " no switchport" - - " no bfd echo" diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/_remove_config.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/_remove_config.yaml deleted file mode 100644 index b1fa61c19..000000000 --- a/tests/integration/targets/nxos_bfd_interfaces/tests/common/_remove_config.yaml +++ /dev/null @@ -1,9 +0,0 @@ ---- -- name: Remove configuration - cisco.nxos.nxos_config: - lines: - - "no feature bfd" - - "default interface {{ nxos_int1 }}" - - "default interface {{ nxos_int2 }}" - - "default interface {{ nxos_int3 }}" - ignore_errors: true diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/deleted.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/deleted.yaml deleted file mode 100644 index 01e3bd07c..000000000 --- a/tests/integration/targets/nxos_bfd_interfaces/tests/common/deleted.yaml +++ /dev/null @@ -1,75 +0,0 @@ ---- -- ansible.builtin.debug: - msg: Start nxos_bfd_interfaces deleted integration tests connection={{ ansible_connection }} - -- name: Set a fact for 'test_int1' - ansible.builtin.set_fact: - test_int1: "{{ nxos_int1 }}" - -- name: Set a fact for 'bfd_disable' and 'bfd_enable' - ansible.builtin.set_fact: - bfd_enable: enable - bfd_disable: disable - when: platform is not search('N5K|N6K') - -- name: Setup1 - cisco.nxos.nxos_config: &id002 - lines: - - "no feature bfd" - - "default interface {{ test_int1 }}" - -- block: - - name: Setup2 - cisco.nxos.nxos_config: - lines: - - "feature bfd" - - "interface {{ test_int1 }}" - - " no switchport" - - - name: Setup initial BFD state - cisco.nxos.nxos_bfd_interfaces: - config: - - name: "{{ test_int1 }}" - bfd: "{{ bfd_disable|default(omit)}}" - echo: disable - state: merged - vars: - ansible_command_timeout: 90 - - - name: Gather bfd_interfaces facts - cisco.nxos.nxos_facts: - gather_subset: - - "!all" - - "!min" - gather_network_resources: bfd_interfaces - - - name: Deleted - register: result - cisco.nxos.nxos_bfd_interfaces: &id001 - config: - - name: "{{ test_int1 }}" - state: deleted - - - ansible.builtin.assert: - that: - - result.changed == true - - "'bfd echo' in result.commands" - msg: "Assert failed. 'result.commands': {{ result.commands }}" - - - ansible.builtin.assert: - that: - - "{{ 'bfd' in result.commands }}" - msg: "Assert failed. 'result.commands': {{ result.commands }}" - when: bfd_enable is defined - - - name: Idempotence - deleted - register: result - cisco.nxos.nxos_bfd_interfaces: *id001 - - - ansible.builtin.assert: - that: - - result.changed == false - - result.commands|length == 0 - always: - - name: Teardown - cisco.nxos.nxos_config: *id002 diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/empty_config.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/empty_config.yaml deleted file mode 100644 index 037de3892..000000000 --- a/tests/integration/targets/nxos_bfd_interfaces/tests/common/empty_config.yaml +++ /dev/null @@ -1,61 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START nxos_bfd_interfaces empty_config integration tests on connection={{ ansible_connection }} - -- name: Merged with empty configuration should give appropriate error message - register: result - ignore_errors: true - cisco.nxos.nxos_bfd_interfaces: - config: - state: merged - -- ansible.builtin.assert: - that: - - result.msg == 'value of config parameter must not be empty for state merged' - -- name: Replaced with empty configuration should give appropriate error message - register: result - ignore_errors: true - cisco.nxos.nxos_bfd_interfaces: - config: - state: replaced - -- ansible.builtin.assert: - that: - - result.msg == 'value of config parameter must not be empty for state replaced' - -- name: Overridden with empty configuration should give appropriate error message - register: result - ignore_errors: true - cisco.nxos.nxos_bfd_interfaces: - config: - state: overridden - -- ansible.builtin.assert: - that: - - result.msg == 'value of config parameter must not be empty for state overridden' - -- name: Rendered with empty configuration should give appropriate error message - register: result - ignore_errors: true - cisco.nxos.nxos_bfd_interfaces: - config: - state: rendered - -- ansible.builtin.assert: - that: - - result.msg == 'value of config parameter must not be empty for state rendered' - -- name: Parsed with empty configuration should give appropriate error message - register: result - ignore_errors: true - cisco.nxos.nxos_bfd_interfaces: - running_config: - state: parsed - -- ansible.builtin.assert: - that: - - result.msg == 'value of running_config parameter must not be empty for state parsed' - -- ansible.builtin.debug: - msg: END nxos_bfd_interfaces empty_config integration tests on connection={{ ansible_connection }} diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/gathered.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/gathered.yaml deleted file mode 100644 index 83d8a1a1e..000000000 --- a/tests/integration/targets/nxos_bfd_interfaces/tests/common/gathered.yaml +++ /dev/null @@ -1,29 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START nxos_bfd_interfaces gathered integration tests on connection={{ ansible_connection }} - -- ansible.builtin.include_tasks: _remove_config.yaml - -- ansible.builtin.include_tasks: _populate_config.yaml - -- block: - - name: Gather bfd_interfaces facts from the device using nxos_bfd_interfaces - register: result - cisco.nxos.nxos_bfd_interfaces: - state: gathered - - - ansible.builtin.assert: - that: - - not result.changed - - > - {{ - result['gathered'] - | selectattr('name', 'in', 'Ethernet1/1,Ethernet1/2') - | symmetric_difference(gathered) - | length == 0 - }} - always: - - ansible.builtin.include_tasks: _remove_config.yaml - - - ansible.builtin.debug: - msg: END nxos_bfd_interfaces gathered integration tests on connection={{ ansible_connection }} diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/merged.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/merged.yaml deleted file mode 100644 index 2bbd1eb5d..000000000 --- a/tests/integration/targets/nxos_bfd_interfaces/tests/common/merged.yaml +++ /dev/null @@ -1,71 +0,0 @@ ---- -- ansible.builtin.debug: - msg: Start nxos_bfd_interfaces merged integration tests connection={{ ansible_connection }} - -- name: Set a fact for 'test_int1' - ansible.builtin.set_fact: - test_int1: "{{ nxos_int1 }}" - -- name: Set a fact for 'bfd_disable' and 'bfd_enable' - ansible.builtin.set_fact: - bfd_enable: enable - bfd_disable: disable - when: platform is not search('N5K|N6K') - -- name: Setup1 - cisco.nxos.nxos_config: &id002 - lines: - - "no feature bfd" - - "default interface {{ test_int1 }}" - -- block: - - name: Setup2 - cisco.nxos.nxos_config: - lines: - - "feature bfd" - - "interface {{ test_int1 }}" - - " no switchport" - - - name: Merged - register: result - cisco.nxos.nxos_bfd_interfaces: &id001 - config: - - name: "{{ test_int1 }}" - bfd: "{{ bfd_disable|default(omit)}}" - echo: disable - state: merged - - - ansible.builtin.assert: - that: - - result.changed == true - - "'no bfd echo' in result.commands" - msg: "Assert failed. 'result.commands': {{ result.commands }}" - - - ansible.builtin.assert: - that: - - "{{ 'no bfd' in result.commands }}" - msg: "Assert failed. 'result.commands': {{ result.commands }}" - when: bfd_enable is defined - - - name: Gather bfd_interfaces facts - cisco.nxos.nxos_facts: - gather_subset: - - "!all" - - "!min" - gather_network_resources: bfd_interfaces - - - ansible.builtin.assert: - that: - - ansible_facts.network_resources.bfd_interfaces|symmetric_difference(result.after)|length == 0 - - - name: Idempotence - merged - register: result - cisco.nxos.nxos_bfd_interfaces: *id001 - - - ansible.builtin.assert: - that: - - result.changed == false - - result.commands|length == 0 - always: - - name: Teardown - cisco.nxos.nxos_config: *id002 diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/overridden.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/overridden.yaml deleted file mode 100644 index fb1696318..000000000 --- a/tests/integration/targets/nxos_bfd_interfaces/tests/common/overridden.yaml +++ /dev/null @@ -1,81 +0,0 @@ ---- -- ansible.builtin.debug: - msg: Start nxos_bfd_interfaces overridden integration tests connection={{ ansible_connection }} - -- name: Set a fact for 'test_int1' - ansible.builtin.set_fact: - test_int1: "{{ nxos_int1 }}" - -- name: Set a fact for 'test_int2' - ansible.builtin.set_fact: - test_int2: "{{ nxos_int2 }}" - -- name: Set a fact for 'bfd_disable' and 'bfd_enable' - ansible.builtin.set_fact: - bfd_enable: enable - bfd_disable: disable - when: platform is not search('N5K|N6K') - -- name: Setup1 - cisco.nxos.nxos_config: &id002 - lines: - - "no feature bfd" - - "default interface {{ test_int1 }}" - - "default interface {{ test_int2 }}" - vars: - ansible_command_timeout: 90 - -- block: - - name: Setup2 - cisco.nxos.nxos_config: - lines: - - "feature bfd" - - - name: Setup3 - cisco.nxos.nxos_config: - lines: - - "no switchport" - parents: "interface {{ item }}" - loop: - - "{{ test_int1 }}" - - "{{ test_int2 }}" - - - name: Setup initial BFD state - cisco.nxos.nxos_bfd_interfaces: - config: - - name: "{{ test_int1 }}" - bfd: "{{ bfd_disable|default(omit)}}" - echo: enable - - - name: "{{ test_int2 }}" - bfd: "{{ bfd_enable|default(omit)}}" - echo: disable - state: merged - - - name: Overridden - register: result - cisco.nxos.nxos_bfd_interfaces: &id001 - config: - - name: "{{ test_int1 }}" - bfd: "{{ bfd_disable|default(omit)}}" - echo: disable - state: overridden - - - ansible.builtin.assert: - that: - - result.changed == true - - result.commands[1] == 'bfd echo' - - result.commands[3] == 'no bfd echo' - msg: "Assert failed. 'result.commands': {{ result.commands }}" - - - name: Idempotence - overridden - register: result - cisco.nxos.nxos_bfd_interfaces: *id001 - - - ansible.builtin.assert: - that: - - result.changed == false - - result.commands|length == 0 - always: - - name: Teardown - cisco.nxos.nxos_config: *id002 diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/parsed.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/parsed.yaml deleted file mode 100644 index 4cc9c6b38..000000000 --- a/tests/integration/targets/nxos_bfd_interfaces/tests/common/parsed.yaml +++ /dev/null @@ -1,31 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START nxos_bfd_interfaces parsed integration tests on connection={{ ansible_connection }} - -- block: - # Interfaces used in the task don't actually exist on the appliance - - name: Use parsed state to convert externally supplied configuration to structured format - register: result - cisco.nxos.nxos_bfd_interfaces: - running_config: | - feature bfd - interface Ethernet1/800 - no switchport - no bfd - no bfd echo - interface Ethernet1/801 - no switchport - no bfd - interface Ethernet1/802 - no switchport - no bfd echo - interface mgmt0 - ip address dhcp - vrf member management - state: parsed - - - ansible.builtin.assert: - that: "{{ parsed | symmetric_difference(result['parsed']) |length==0 }}" - -- ansible.builtin.debug: - msg: END nxos_bfd_interfaces parsed integration tests on connection={{ ansible_connection }} diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/rendered.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/rendered.yaml deleted file mode 100644 index 56dae25fd..000000000 --- a/tests/integration/targets/nxos_bfd_interfaces/tests/common/rendered.yaml +++ /dev/null @@ -1,36 +0,0 @@ ---- -- ansible.builtin.debug: - msg: START nxos_bfd_interfaces rendered integration tests on connection={{ ansible_connection }} - -- ansible.builtin.include_tasks: _remove_config.yaml - -- block: - # Interfaces used here doesn't actually exist on the device - - name: Use rendered state to convert task input to device specific commands - register: result - cisco.nxos.nxos_bfd_interfaces: - config: - - name: Ethernet1/800 - bfd: enable - echo: enable - - name: Ethernet1/801 - bfd: disable - echo: disable - state: rendered - - - ansible.builtin.assert: - that: "{{ rendered | symmetric_difference(result['rendered']) |length==0 }}" - - - name: Gather bfd_interfaces facts from the device and assert that its empty - register: result - cisco.nxos.nxos_bfd_interfaces: - state: gathered - - - name: Make sure that rendered task actually did not make any changes to the device - ansible.builtin.assert: - that: "{{ result['gathered'] == [] }}" - always: - - ansible.builtin.include_tasks: _remove_config.yaml - -- ansible.builtin.debug: - msg: END nxos_bfd_interfaces rendered integration tests on connection={{ ansible_connection }} diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/replaced.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/replaced.yaml deleted file mode 100644 index 498ee7d9c..000000000 --- a/tests/integration/targets/nxos_bfd_interfaces/tests/common/replaced.yaml +++ /dev/null @@ -1,68 +0,0 @@ ---- -- ansible.builtin.debug: - msg: Start nxos_bfd_interfaces replaced integration tests connection={{ ansible_connection }} - -- name: Set a fact for 'test_int1' - ansible.builtin.set_fact: - test_int1: "{{ nxos_int1 }}" - -- name: Set a fact for 'bfd_disable' and 'bfd_enable' - ansible.builtin.set_fact: - bfd_enable: enable - bfd_disable: disable - when: platform is not search('N5K|N6K') - -- name: Setup1 - cisco.nxos.nxos_config: &id002 - lines: - - "no feature bfd" - - "default interface {{ test_int1 }}" - -- block: - - name: Setup2 - cisco.nxos.nxos_config: - lines: - - "feature bfd" - - "interface {{ test_int1 }}" - - " no switchport" - - - name: Setup initial BFD state - cisco.nxos.nxos_bfd_interfaces: - config: - - name: "{{ test_int1 }}" - bfd: "{{ bfd_disable|default(omit)}}" - echo: enable - state: merged - - - name: Replaced - register: result - cisco.nxos.nxos_bfd_interfaces: &id001 - config: - - name: "{{ test_int1 }}" - bfd: "{{ bfd_enable|default(omit)}}" - echo: disable - state: replaced - - - ansible.builtin.assert: - that: - - result.changed == true - - "'no bfd echo' in result.commands" - msg: "Assert failed. 'result.commands': {{ result.commands }}" - - - ansible.builtin.assert: - that: - - "{{ 'bfd' in result.commands }}" - msg: "Assert failed. 'result.commands': {{ result.commands }}" - when: bfd_enable is defined - - - name: Idempotence - replaced - register: result - cisco.nxos.nxos_bfd_interfaces: *id001 - - - ansible.builtin.assert: - that: - - result.changed == false - - result.commands|length == 0 - always: - - name: Teardown - cisco.nxos.nxos_config: *id002 diff --git a/tests/integration/targets/nxos_bfd_interfaces/vars/main.yml b/tests/integration/targets/nxos_bfd_interfaces/vars/main.yml deleted file mode 100644 index c177d289f..000000000 --- a/tests/integration/targets/nxos_bfd_interfaces/vars/main.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -gathered: - - name: "Ethernet1/1" - bfd: disable - echo: enable - - name: "Ethernet1/2" - echo: disable - bfd: enable - -parsed: - - bfd: disable - echo: disable - name: Ethernet1/800 - - bfd: disable - echo: enable - name: Ethernet1/801 - - bfd: enable - echo: disable - name: Ethernet1/802 - - bfd: enable - echo: enable - name: mgmt0 - -rendered: - - "interface Ethernet1/800" - - "bfd" - - "bfd echo" - - "interface Ethernet1/801" - - "no bfd" - - "no bfd echo" From a9b8dc47e3f10f9504c864c827f9aeb75d81bd4b Mon Sep 17 00:00:00 2001 From: Nikhil Bhasin Date: Fri, 3 Oct 2025 14:18:13 +0530 Subject: [PATCH 27/31] re add deleted files --- .../nxos_bfd_interfaces/defaults/main.yaml | 2 + .../targets/nxos_bfd_interfaces/meta/main.yml | 3 + .../nxos_bfd_interfaces/tasks/main.yaml | 10 +++ .../tests/common/_populate_config.yaml | 15 ++++ .../tests/common/_remove_config.yaml | 9 +++ .../tests/common/deleted.yaml | 75 +++++++++++++++++ .../tests/common/empty_config.yaml | 61 ++++++++++++++ .../tests/common/gathered.yaml | 29 +++++++ .../tests/common/merged.yaml | 71 ++++++++++++++++ .../tests/common/overridden.yaml | 81 +++++++++++++++++++ .../tests/common/parsed.yaml | 31 +++++++ .../tests/common/rendered.yaml | 36 +++++++++ .../tests/common/replaced.yaml | 68 ++++++++++++++++ .../targets/nxos_bfd_interfaces/vars/main.yml | 30 +++++++ .../targets/nxos_facts/defaults/main.yaml | 2 + .../targets/nxos_facts/meta/main.yml | 3 + .../targets/nxos_facts/tasks/cli.yaml | 31 +++++++ .../targets/nxos_facts/tasks/main.yaml | 10 +++ .../targets/nxos_facts/tasks/nxapi.yaml | 31 +++++++ .../nxos_facts/tests/common/__all_facts.yaml | 38 +++++++++ .../tests/common/__default_facts.yaml | 26 ++++++ .../tests/common/__interface_facts.yaml | 66 +++++++++++++++ .../tests/common/__invalid_subset.yaml | 19 +++++ .../tests/common/__not_hardware.yaml | 21 +++++ .../nxos_facts/tests/common/__sanity.yaml | 63 +++++++++++++++ .../targets/nxos_facts/vars/main.yml | 33 ++++++++ 26 files changed, 864 insertions(+) create mode 100644 tests/integration/targets/nxos_bfd_interfaces/defaults/main.yaml create mode 100644 tests/integration/targets/nxos_bfd_interfaces/meta/main.yml create mode 100644 tests/integration/targets/nxos_bfd_interfaces/tasks/main.yaml create mode 100644 tests/integration/targets/nxos_bfd_interfaces/tests/common/_populate_config.yaml create mode 100644 tests/integration/targets/nxos_bfd_interfaces/tests/common/_remove_config.yaml create mode 100644 tests/integration/targets/nxos_bfd_interfaces/tests/common/deleted.yaml create mode 100644 tests/integration/targets/nxos_bfd_interfaces/tests/common/empty_config.yaml create mode 100644 tests/integration/targets/nxos_bfd_interfaces/tests/common/gathered.yaml create mode 100644 tests/integration/targets/nxos_bfd_interfaces/tests/common/merged.yaml create mode 100644 tests/integration/targets/nxos_bfd_interfaces/tests/common/overridden.yaml create mode 100644 tests/integration/targets/nxos_bfd_interfaces/tests/common/parsed.yaml create mode 100644 tests/integration/targets/nxos_bfd_interfaces/tests/common/rendered.yaml create mode 100644 tests/integration/targets/nxos_bfd_interfaces/tests/common/replaced.yaml create mode 100644 tests/integration/targets/nxos_bfd_interfaces/vars/main.yml create mode 100644 tests/integration/targets/nxos_facts/defaults/main.yaml create mode 100644 tests/integration/targets/nxos_facts/meta/main.yml create mode 100644 tests/integration/targets/nxos_facts/tasks/cli.yaml create mode 100644 tests/integration/targets/nxos_facts/tasks/main.yaml create mode 100644 tests/integration/targets/nxos_facts/tasks/nxapi.yaml create mode 100644 tests/integration/targets/nxos_facts/tests/common/__all_facts.yaml create mode 100644 tests/integration/targets/nxos_facts/tests/common/__default_facts.yaml create mode 100644 tests/integration/targets/nxos_facts/tests/common/__interface_facts.yaml create mode 100644 tests/integration/targets/nxos_facts/tests/common/__invalid_subset.yaml create mode 100644 tests/integration/targets/nxos_facts/tests/common/__not_hardware.yaml create mode 100644 tests/integration/targets/nxos_facts/tests/common/__sanity.yaml create mode 100644 tests/integration/targets/nxos_facts/vars/main.yml diff --git a/tests/integration/targets/nxos_bfd_interfaces/defaults/main.yaml b/tests/integration/targets/nxos_bfd_interfaces/defaults/main.yaml new file mode 100644 index 000000000..871ea460c --- /dev/null +++ b/tests/integration/targets/nxos_bfd_interfaces/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "[^_].*" diff --git a/tests/integration/targets/nxos_bfd_interfaces/meta/main.yml b/tests/integration/targets/nxos_bfd_interfaces/meta/main.yml new file mode 100644 index 000000000..f504a6ab2 --- /dev/null +++ b/tests/integration/targets/nxos_bfd_interfaces/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_nxos_tests diff --git a/tests/integration/targets/nxos_bfd_interfaces/tasks/main.yaml b/tests/integration/targets/nxos_bfd_interfaces/tasks/main.yaml new file mode 100644 index 000000000..a1da90e57 --- /dev/null +++ b/tests/integration/targets/nxos_bfd_interfaces/tasks/main.yaml @@ -0,0 +1,10 @@ +--- +- name: Include the CLI tasks + ansible.builtin.include_tasks: cli.yaml + tags: + - cli + +- name: Include the NX-API tasks + ansible.builtin.include_tasks: nxapi.yaml + tags: + - nxapi diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/_populate_config.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/_populate_config.yaml new file mode 100644 index 000000000..6c260fafb --- /dev/null +++ b/tests/integration/targets/nxos_bfd_interfaces/tests/common/_populate_config.yaml @@ -0,0 +1,15 @@ +--- +- name: Populate configuration - 1 + cisco.nxos.nxos_config: + lines: + - "feature bfd" + - "interface {{ nxos_int1 }}" + - " no switchport" + - " no bfd" + +- name: Populate configuration - 2 + cisco.nxos.nxos_config: + lines: + - "interface {{ nxos_int2 }}" + - " no switchport" + - " no bfd echo" diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/_remove_config.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/_remove_config.yaml new file mode 100644 index 000000000..b1fa61c19 --- /dev/null +++ b/tests/integration/targets/nxos_bfd_interfaces/tests/common/_remove_config.yaml @@ -0,0 +1,9 @@ +--- +- name: Remove configuration + cisco.nxos.nxos_config: + lines: + - "no feature bfd" + - "default interface {{ nxos_int1 }}" + - "default interface {{ nxos_int2 }}" + - "default interface {{ nxos_int3 }}" + ignore_errors: true diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/deleted.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/deleted.yaml new file mode 100644 index 000000000..01e3bd07c --- /dev/null +++ b/tests/integration/targets/nxos_bfd_interfaces/tests/common/deleted.yaml @@ -0,0 +1,75 @@ +--- +- ansible.builtin.debug: + msg: Start nxos_bfd_interfaces deleted integration tests connection={{ ansible_connection }} + +- name: Set a fact for 'test_int1' + ansible.builtin.set_fact: + test_int1: "{{ nxos_int1 }}" + +- name: Set a fact for 'bfd_disable' and 'bfd_enable' + ansible.builtin.set_fact: + bfd_enable: enable + bfd_disable: disable + when: platform is not search('N5K|N6K') + +- name: Setup1 + cisco.nxos.nxos_config: &id002 + lines: + - "no feature bfd" + - "default interface {{ test_int1 }}" + +- block: + - name: Setup2 + cisco.nxos.nxos_config: + lines: + - "feature bfd" + - "interface {{ test_int1 }}" + - " no switchport" + + - name: Setup initial BFD state + cisco.nxos.nxos_bfd_interfaces: + config: + - name: "{{ test_int1 }}" + bfd: "{{ bfd_disable|default(omit)}}" + echo: disable + state: merged + vars: + ansible_command_timeout: 90 + + - name: Gather bfd_interfaces facts + cisco.nxos.nxos_facts: + gather_subset: + - "!all" + - "!min" + gather_network_resources: bfd_interfaces + + - name: Deleted + register: result + cisco.nxos.nxos_bfd_interfaces: &id001 + config: + - name: "{{ test_int1 }}" + state: deleted + + - ansible.builtin.assert: + that: + - result.changed == true + - "'bfd echo' in result.commands" + msg: "Assert failed. 'result.commands': {{ result.commands }}" + + - ansible.builtin.assert: + that: + - "{{ 'bfd' in result.commands }}" + msg: "Assert failed. 'result.commands': {{ result.commands }}" + when: bfd_enable is defined + + - name: Idempotence - deleted + register: result + cisco.nxos.nxos_bfd_interfaces: *id001 + + - ansible.builtin.assert: + that: + - result.changed == false + - result.commands|length == 0 + always: + - name: Teardown + cisco.nxos.nxos_config: *id002 diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/empty_config.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/empty_config.yaml new file mode 100644 index 000000000..037de3892 --- /dev/null +++ b/tests/integration/targets/nxos_bfd_interfaces/tests/common/empty_config.yaml @@ -0,0 +1,61 @@ +--- +- ansible.builtin.debug: + msg: START nxos_bfd_interfaces empty_config integration tests on connection={{ ansible_connection }} + +- name: Merged with empty configuration should give appropriate error message + register: result + ignore_errors: true + cisco.nxos.nxos_bfd_interfaces: + config: + state: merged + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty configuration should give appropriate error message + register: result + ignore_errors: true + cisco.nxos.nxos_bfd_interfaces: + config: + state: replaced + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty configuration should give appropriate error message + register: result + ignore_errors: true + cisco.nxos.nxos_bfd_interfaces: + config: + state: overridden + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Rendered with empty configuration should give appropriate error message + register: result + ignore_errors: true + cisco.nxos.nxos_bfd_interfaces: + config: + state: rendered + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + +- name: Parsed with empty configuration should give appropriate error message + register: result + ignore_errors: true + cisco.nxos.nxos_bfd_interfaces: + running_config: + state: parsed + +- ansible.builtin.assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' + +- ansible.builtin.debug: + msg: END nxos_bfd_interfaces empty_config integration tests on connection={{ ansible_connection }} diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/gathered.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/gathered.yaml new file mode 100644 index 000000000..83d8a1a1e --- /dev/null +++ b/tests/integration/targets/nxos_bfd_interfaces/tests/common/gathered.yaml @@ -0,0 +1,29 @@ +--- +- ansible.builtin.debug: + msg: START nxos_bfd_interfaces gathered integration tests on connection={{ ansible_connection }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _populate_config.yaml + +- block: + - name: Gather bfd_interfaces facts from the device using nxos_bfd_interfaces + register: result + cisco.nxos.nxos_bfd_interfaces: + state: gathered + + - ansible.builtin.assert: + that: + - not result.changed + - > + {{ + result['gathered'] + | selectattr('name', 'in', 'Ethernet1/1,Ethernet1/2') + | symmetric_difference(gathered) + | length == 0 + }} + always: + - ansible.builtin.include_tasks: _remove_config.yaml + + - ansible.builtin.debug: + msg: END nxos_bfd_interfaces gathered integration tests on connection={{ ansible_connection }} diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/merged.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/merged.yaml new file mode 100644 index 000000000..2bbd1eb5d --- /dev/null +++ b/tests/integration/targets/nxos_bfd_interfaces/tests/common/merged.yaml @@ -0,0 +1,71 @@ +--- +- ansible.builtin.debug: + msg: Start nxos_bfd_interfaces merged integration tests connection={{ ansible_connection }} + +- name: Set a fact for 'test_int1' + ansible.builtin.set_fact: + test_int1: "{{ nxos_int1 }}" + +- name: Set a fact for 'bfd_disable' and 'bfd_enable' + ansible.builtin.set_fact: + bfd_enable: enable + bfd_disable: disable + when: platform is not search('N5K|N6K') + +- name: Setup1 + cisco.nxos.nxos_config: &id002 + lines: + - "no feature bfd" + - "default interface {{ test_int1 }}" + +- block: + - name: Setup2 + cisco.nxos.nxos_config: + lines: + - "feature bfd" + - "interface {{ test_int1 }}" + - " no switchport" + + - name: Merged + register: result + cisco.nxos.nxos_bfd_interfaces: &id001 + config: + - name: "{{ test_int1 }}" + bfd: "{{ bfd_disable|default(omit)}}" + echo: disable + state: merged + + - ansible.builtin.assert: + that: + - result.changed == true + - "'no bfd echo' in result.commands" + msg: "Assert failed. 'result.commands': {{ result.commands }}" + + - ansible.builtin.assert: + that: + - "{{ 'no bfd' in result.commands }}" + msg: "Assert failed. 'result.commands': {{ result.commands }}" + when: bfd_enable is defined + + - name: Gather bfd_interfaces facts + cisco.nxos.nxos_facts: + gather_subset: + - "!all" + - "!min" + gather_network_resources: bfd_interfaces + + - ansible.builtin.assert: + that: + - ansible_facts.network_resources.bfd_interfaces|symmetric_difference(result.after)|length == 0 + + - name: Idempotence - merged + register: result + cisco.nxos.nxos_bfd_interfaces: *id001 + + - ansible.builtin.assert: + that: + - result.changed == false + - result.commands|length == 0 + always: + - name: Teardown + cisco.nxos.nxos_config: *id002 diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/overridden.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/overridden.yaml new file mode 100644 index 000000000..fb1696318 --- /dev/null +++ b/tests/integration/targets/nxos_bfd_interfaces/tests/common/overridden.yaml @@ -0,0 +1,81 @@ +--- +- ansible.builtin.debug: + msg: Start nxos_bfd_interfaces overridden integration tests connection={{ ansible_connection }} + +- name: Set a fact for 'test_int1' + ansible.builtin.set_fact: + test_int1: "{{ nxos_int1 }}" + +- name: Set a fact for 'test_int2' + ansible.builtin.set_fact: + test_int2: "{{ nxos_int2 }}" + +- name: Set a fact for 'bfd_disable' and 'bfd_enable' + ansible.builtin.set_fact: + bfd_enable: enable + bfd_disable: disable + when: platform is not search('N5K|N6K') + +- name: Setup1 + cisco.nxos.nxos_config: &id002 + lines: + - "no feature bfd" + - "default interface {{ test_int1 }}" + - "default interface {{ test_int2 }}" + vars: + ansible_command_timeout: 90 + +- block: + - name: Setup2 + cisco.nxos.nxos_config: + lines: + - "feature bfd" + + - name: Setup3 + cisco.nxos.nxos_config: + lines: + - "no switchport" + parents: "interface {{ item }}" + loop: + - "{{ test_int1 }}" + - "{{ test_int2 }}" + + - name: Setup initial BFD state + cisco.nxos.nxos_bfd_interfaces: + config: + - name: "{{ test_int1 }}" + bfd: "{{ bfd_disable|default(omit)}}" + echo: enable + + - name: "{{ test_int2 }}" + bfd: "{{ bfd_enable|default(omit)}}" + echo: disable + state: merged + + - name: Overridden + register: result + cisco.nxos.nxos_bfd_interfaces: &id001 + config: + - name: "{{ test_int1 }}" + bfd: "{{ bfd_disable|default(omit)}}" + echo: disable + state: overridden + + - ansible.builtin.assert: + that: + - result.changed == true + - result.commands[1] == 'bfd echo' + - result.commands[3] == 'no bfd echo' + msg: "Assert failed. 'result.commands': {{ result.commands }}" + + - name: Idempotence - overridden + register: result + cisco.nxos.nxos_bfd_interfaces: *id001 + + - ansible.builtin.assert: + that: + - result.changed == false + - result.commands|length == 0 + always: + - name: Teardown + cisco.nxos.nxos_config: *id002 diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/parsed.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/parsed.yaml new file mode 100644 index 000000000..4cc9c6b38 --- /dev/null +++ b/tests/integration/targets/nxos_bfd_interfaces/tests/common/parsed.yaml @@ -0,0 +1,31 @@ +--- +- ansible.builtin.debug: + msg: START nxos_bfd_interfaces parsed integration tests on connection={{ ansible_connection }} + +- block: + # Interfaces used in the task don't actually exist on the appliance + - name: Use parsed state to convert externally supplied configuration to structured format + register: result + cisco.nxos.nxos_bfd_interfaces: + running_config: | + feature bfd + interface Ethernet1/800 + no switchport + no bfd + no bfd echo + interface Ethernet1/801 + no switchport + no bfd + interface Ethernet1/802 + no switchport + no bfd echo + interface mgmt0 + ip address dhcp + vrf member management + state: parsed + + - ansible.builtin.assert: + that: "{{ parsed | symmetric_difference(result['parsed']) |length==0 }}" + +- ansible.builtin.debug: + msg: END nxos_bfd_interfaces parsed integration tests on connection={{ ansible_connection }} diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/rendered.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/rendered.yaml new file mode 100644 index 000000000..56dae25fd --- /dev/null +++ b/tests/integration/targets/nxos_bfd_interfaces/tests/common/rendered.yaml @@ -0,0 +1,36 @@ +--- +- ansible.builtin.debug: + msg: START nxos_bfd_interfaces rendered integration tests on connection={{ ansible_connection }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- block: + # Interfaces used here doesn't actually exist on the device + - name: Use rendered state to convert task input to device specific commands + register: result + cisco.nxos.nxos_bfd_interfaces: + config: + - name: Ethernet1/800 + bfd: enable + echo: enable + - name: Ethernet1/801 + bfd: disable + echo: disable + state: rendered + + - ansible.builtin.assert: + that: "{{ rendered | symmetric_difference(result['rendered']) |length==0 }}" + + - name: Gather bfd_interfaces facts from the device and assert that its empty + register: result + cisco.nxos.nxos_bfd_interfaces: + state: gathered + + - name: Make sure that rendered task actually did not make any changes to the device + ansible.builtin.assert: + that: "{{ result['gathered'] == [] }}" + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: END nxos_bfd_interfaces rendered integration tests on connection={{ ansible_connection }} diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/replaced.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/replaced.yaml new file mode 100644 index 000000000..498ee7d9c --- /dev/null +++ b/tests/integration/targets/nxos_bfd_interfaces/tests/common/replaced.yaml @@ -0,0 +1,68 @@ +--- +- ansible.builtin.debug: + msg: Start nxos_bfd_interfaces replaced integration tests connection={{ ansible_connection }} + +- name: Set a fact for 'test_int1' + ansible.builtin.set_fact: + test_int1: "{{ nxos_int1 }}" + +- name: Set a fact for 'bfd_disable' and 'bfd_enable' + ansible.builtin.set_fact: + bfd_enable: enable + bfd_disable: disable + when: platform is not search('N5K|N6K') + +- name: Setup1 + cisco.nxos.nxos_config: &id002 + lines: + - "no feature bfd" + - "default interface {{ test_int1 }}" + +- block: + - name: Setup2 + cisco.nxos.nxos_config: + lines: + - "feature bfd" + - "interface {{ test_int1 }}" + - " no switchport" + + - name: Setup initial BFD state + cisco.nxos.nxos_bfd_interfaces: + config: + - name: "{{ test_int1 }}" + bfd: "{{ bfd_disable|default(omit)}}" + echo: enable + state: merged + + - name: Replaced + register: result + cisco.nxos.nxos_bfd_interfaces: &id001 + config: + - name: "{{ test_int1 }}" + bfd: "{{ bfd_enable|default(omit)}}" + echo: disable + state: replaced + + - ansible.builtin.assert: + that: + - result.changed == true + - "'no bfd echo' in result.commands" + msg: "Assert failed. 'result.commands': {{ result.commands }}" + + - ansible.builtin.assert: + that: + - "{{ 'bfd' in result.commands }}" + msg: "Assert failed. 'result.commands': {{ result.commands }}" + when: bfd_enable is defined + + - name: Idempotence - replaced + register: result + cisco.nxos.nxos_bfd_interfaces: *id001 + + - ansible.builtin.assert: + that: + - result.changed == false + - result.commands|length == 0 + always: + - name: Teardown + cisco.nxos.nxos_config: *id002 diff --git a/tests/integration/targets/nxos_bfd_interfaces/vars/main.yml b/tests/integration/targets/nxos_bfd_interfaces/vars/main.yml new file mode 100644 index 000000000..c177d289f --- /dev/null +++ b/tests/integration/targets/nxos_bfd_interfaces/vars/main.yml @@ -0,0 +1,30 @@ +--- +gathered: + - name: "Ethernet1/1" + bfd: disable + echo: enable + - name: "Ethernet1/2" + echo: disable + bfd: enable + +parsed: + - bfd: disable + echo: disable + name: Ethernet1/800 + - bfd: disable + echo: enable + name: Ethernet1/801 + - bfd: enable + echo: disable + name: Ethernet1/802 + - bfd: enable + echo: enable + name: mgmt0 + +rendered: + - "interface Ethernet1/800" + - "bfd" + - "bfd echo" + - "interface Ethernet1/801" + - "no bfd" + - "no bfd echo" diff --git a/tests/integration/targets/nxos_facts/defaults/main.yaml b/tests/integration/targets/nxos_facts/defaults/main.yaml new file mode 100644 index 000000000..5f709c5aa --- /dev/null +++ b/tests/integration/targets/nxos_facts/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/tests/integration/targets/nxos_facts/meta/main.yml b/tests/integration/targets/nxos_facts/meta/main.yml new file mode 100644 index 000000000..f504a6ab2 --- /dev/null +++ b/tests/integration/targets/nxos_facts/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_nxos_tests diff --git a/tests/integration/targets/nxos_facts/tasks/cli.yaml b/tests/integration/targets/nxos_facts/tasks/cli.yaml new file mode 100644 index 000000000..d3d521f2a --- /dev/null +++ b/tests/integration/targets/nxos_facts/tasks/cli.yaml @@ -0,0 +1,31 @@ +--- +- name: Collect common test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + connection: local + register: test_cases + +- name: Collect CLI test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + connection: local + register: cli_cases + +- name: Set a fact for 'test_cases' + ansible.builtin.set_fact: + test_cases: + files: "{{ test_cases.files + cli_cases.files }}" + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test cases with connection network_cli + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.network_cli diff --git a/tests/integration/targets/nxos_facts/tasks/main.yaml b/tests/integration/targets/nxos_facts/tasks/main.yaml new file mode 100644 index 000000000..a1da90e57 --- /dev/null +++ b/tests/integration/targets/nxos_facts/tasks/main.yaml @@ -0,0 +1,10 @@ +--- +- name: Include the CLI tasks + ansible.builtin.include_tasks: cli.yaml + tags: + - cli + +- name: Include the NX-API tasks + ansible.builtin.include_tasks: nxapi.yaml + tags: + - nxapi diff --git a/tests/integration/targets/nxos_facts/tasks/nxapi.yaml b/tests/integration/targets/nxos_facts/tasks/nxapi.yaml new file mode 100644 index 000000000..5fec0f43b --- /dev/null +++ b/tests/integration/targets/nxos_facts/tasks/nxapi.yaml @@ -0,0 +1,31 @@ +--- +- name: Collect common test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/common" + patterns: "{{ testcase }}.yaml" + connection: local + register: test_cases + +- name: Collect NX-API test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/nxapi" + patterns: "{{ testcase }}.yaml" + connection: local + register: nxapi_cases + +- name: Set a fact for 'test_cases' + ansible.builtin.set_fact: + test_cases: + files: "{{ test_cases.files + nxapi_cases.files }}" + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test cases with connection httpapi + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.httpapi diff --git a/tests/integration/targets/nxos_facts/tests/common/__all_facts.yaml b/tests/integration/targets/nxos_facts/tests/common/__all_facts.yaml new file mode 100644 index 000000000..921f0733f --- /dev/null +++ b/tests/integration/targets/nxos_facts/tests/common/__all_facts.yaml @@ -0,0 +1,38 @@ +--- +- ansible.builtin.debug: + msg: START connection={{ ansible_connection }}/all_facts.yaml + +- name: Test getting all facts + register: result + cisco.nxos.nxos_facts: + gather_subset: + - all + +- ansible.builtin.assert: + that: + - result.changed == false + - "'config' in result.ansible_facts.ansible_net_gather_subset" + - "'hardware' in result.ansible_facts.ansible_net_gather_subset" + - "'default' in result.ansible_facts.ansible_net_gather_subset" + - "'interfaces' in result.ansible_facts.ansible_net_gather_subset" + - result.ansible_facts.ansible_net_filesystems is defined + - result.ansible_facts.ansible_net_interfaces is defined + - result.ansible_facts.ansible_net_config is defined + - result.ansible_facts.ansible_net_cpu_utilization is defined + - result.ansible_facts.ansible_net_model is defined + - (result.ansible_facts.ansible_net_memfree_mb | default(0)) | int >= 0 + - (result.ansible_facts.ansible_net_memtotal_mb | default(0)) | int >= 0 + +- name: Collect list of available network resources for nxos + register: result + cisco.nxos.nxos_facts: + available_network_resources: true + +- name: Assert that correct available_network_resources returned + ansible.builtin.assert: + that: + - result.changed == false + - "{{ result['ansible_facts']['available_network_resources'] | symmetric_difference(available_network_resources) | length == 0 }}" + +- ansible.builtin.debug: + msg: END connection={{ ansible_connection }}/all_facts.yaml diff --git a/tests/integration/targets/nxos_facts/tests/common/__default_facts.yaml b/tests/integration/targets/nxos_facts/tests/common/__default_facts.yaml new file mode 100644 index 000000000..3296fb4e0 --- /dev/null +++ b/tests/integration/targets/nxos_facts/tests/common/__default_facts.yaml @@ -0,0 +1,26 @@ +--- +- ansible.builtin.debug: + msg: START connection={{ ansible_connection }}/default_facts.yaml + +- name: Test getting default facts + register: result + cisco.nxos.nxos_facts: + +- ansible.builtin.assert: + that: + - result.changed == false + - "'default' in result.ansible_facts.ansible_net_gather_subset" + - "'config' not in result.ansible_facts.ansible_net_gather_subset" + - result.ansible_facts.ansible_net_hostname is defined + - result.ansible_facts.ansible_net_image is defined + - result.ansible_facts.ansible_net_license_hostid is defined + - result.ansible_facts.ansible_net_model is defined + - result.ansible_facts.ansible_net_platform is defined + - result.ansible_facts.ansible_net_python_version is defined + - result.ansible_facts.ansible_net_serialnum is defined + - result.ansible_facts.ansible_net_system is defined + - result.ansible_facts.ansible_net_version is defined + - result.ansible_facts.ansible_network_resources == {} + +- ansible.builtin.debug: + msg: END cli/default.yaml diff --git a/tests/integration/targets/nxos_facts/tests/common/__interface_facts.yaml b/tests/integration/targets/nxos_facts/tests/common/__interface_facts.yaml new file mode 100644 index 000000000..8ee8eeeec --- /dev/null +++ b/tests/integration/targets/nxos_facts/tests/common/__interface_facts.yaml @@ -0,0 +1,66 @@ +--- +- ansible.builtin.debug: + msg: START connection={{ ansible_connection }}/interface_facts.yaml + +- name: Setup + cisco.nxos.nxos_config: &default + lines: + - default interface Ethernet1/1 + - default interface Ethernet1/2 + +- block: + - name: Make sure interfaces are L3 + cisco.nxos.nxos_interfaces: + config: + - name: Ethernet1/1 + mode: layer3 + - name: Ethernet1/2 + mode: layer3 + + # since the | json output renders differently when only one + # interface has IPv6 address vs when more than one interface + # has IPv6 address, we need to test them separately + + - name: Assign IPv6 address to interface - 1 + register: result + cisco.nxos.nxos_l3_interfaces: + config: + - name: Ethernet1/1 + ipv6: + - address: 2001:db8::2/32 + + - name: Wait a few seconds for IPv6 to apply + ansible.builtin.wait_for: + timeout: 5 + + - name: Gather interface facts + cisco.nxos.nxos_facts: + gather_subset: + - "interfaces" + + - name: Assert that IPv6 address was found + ansible.builtin.assert: + that: + - "'2001:db8::2/32' in ansible_net_all_ipv6_addresses" + + - name: Assign IPv6 address to interface - 2 + register: result + cisco.nxos.nxos_l3_interfaces: + config: + - name: Ethernet1/2 + ipv6: + - address: 2001:db8::3/32 + + - name: Gather interface facts + cisco.nxos.nxos_facts: + gather_subset: + - "interfaces" + + - name: Assert that IPv6 address was found + ansible.builtin.assert: + that: + - "'2001:db8::2/32' in ansible_net_all_ipv6_addresses" + - "'2001:db8::3/32' in ansible_net_all_ipv6_addresses" + always: + - name: Teardown + cisco.nxos.nxos_config: *default diff --git a/tests/integration/targets/nxos_facts/tests/common/__invalid_subset.yaml b/tests/integration/targets/nxos_facts/tests/common/__invalid_subset.yaml new file mode 100644 index 000000000..5a620c123 --- /dev/null +++ b/tests/integration/targets/nxos_facts/tests/common/__invalid_subset.yaml @@ -0,0 +1,19 @@ +--- +- ansible.builtin.debug: + msg: START connection={{ ansible_connection }}/invalid_subset.yaml + +- name: Test invalid subset (foobar) + register: result + ignore_errors: true + cisco.nxos.nxos_facts: + gather_subset: + - foobar + +- ansible.builtin.assert: + that: + - result.changed == false + - result.failed == true + - "'Subset must be one of' in result.msg" + +- ansible.builtin.debug: + msg: END connection={{ ansible_connection }}/invalid_subset.yaml diff --git a/tests/integration/targets/nxos_facts/tests/common/__not_hardware.yaml b/tests/integration/targets/nxos_facts/tests/common/__not_hardware.yaml new file mode 100644 index 000000000..fc73bfcd6 --- /dev/null +++ b/tests/integration/targets/nxos_facts/tests/common/__not_hardware.yaml @@ -0,0 +1,21 @@ +--- +- ansible.builtin.debug: + msg: START connection={{ ansible_connection }}/not_hardware_facts.yaml + +- name: Test not hardware + register: result + cisco.nxos.nxos_facts: + gather_subset: + - "!hardware" + +- ansible.builtin.assert: + that: + - result.changed == false + - "'config' in result.ansible_facts.ansible_net_gather_subset" + - "'default' in result.ansible_facts.ansible_net_gather_subset" + - "'interfaces' in result.ansible_facts.ansible_net_gather_subset" + - "'hardware' not in result.ansible_facts.ansible_net_gather_subset" + - result.ansible_facts.ansible_net_filesystems is not defined + +- ansible.builtin.debug: + msg: END connection={{ ansible_connection }}/not_hardware_facts.yaml diff --git a/tests/integration/targets/nxos_facts/tests/common/__sanity.yaml b/tests/integration/targets/nxos_facts/tests/common/__sanity.yaml new file mode 100644 index 000000000..03567f477 --- /dev/null +++ b/tests/integration/targets/nxos_facts/tests/common/__sanity.yaml @@ -0,0 +1,63 @@ +--- +- ansible.builtin.debug: + msg: START connection={{ ansible_connection }} nxos_facts sanity test + +- name: Nxos_facts gather hardware facts + register: result + cisco.nxos.nxos_facts: + gather_subset: hardware + +- ansible.builtin.assert: + that: + - result.changed == false + - "'hardware' in result.ansible_facts.ansible_net_gather_subset" + - "'config' not in result.ansible_facts.ansible_net_gather_subset" + - "'interfaces' not in result.ansible_facts.ansible_net_gather_subset" + - result.ansible_facts.ansible_net_filesystems is defined + - (result.ansible_facts.ansible_net_memfree_mb | default(0)) | int >= 0 + - (result.ansible_facts.ansible_net_memtotal_mb | default(0)) | int >= 0 + +- name: Nxos_facts gather configuration facts + register: result + cisco.nxos.nxos_facts: + gather_subset: config + +- ansible.builtin.assert: + that: + - result.changed == false + - "'config' in result.ansible_facts.ansible_net_gather_subset" + - "'hardware' not in result.ansible_facts.ansible_net_gather_subset" + - "'interfaces' not in result.ansible_facts.ansible_net_gather_subset" + - result.ansible_facts.ansible_net_config is defined + +- name: Nxos_facts gather configuration and hardware facts + register: result + cisco.nxos.nxos_facts: + gather_subset: + - hardware + - config + +- ansible.builtin.assert: + that: + - result.changed == false + - "'hardware' in result.ansible_facts.ansible_net_gather_subset" + - "'config' in result.ansible_facts.ansible_net_gather_subset" + - "'interfaces' not in result.ansible_facts.ansible_net_gather_subset" + - result.ansible_facts.ansible_net_filesystems is defined + - result.ansible_facts.ansible_net_config is defined + - (result.ansible_facts.ansible_net_memfree_mb | default(0)) | int >= 0 + - (result.ansible_facts.ansible_net_memtotal_mb | default(0)) | int >= 0 + +- name: Nxos_facts gather features facts + register: result + cisco.nxos.nxos_facts: + gather_subset: features + +- ansible.builtin.assert: + that: + - result.changed == false + - "'features' in result.ansible_facts.ansible_net_gather_subset" + - result.ansible_facts.ansible_net_features_enabled is defined + +- ansible.builtin.debug: + msg: END connection={{ ansible_connection }} nxos_facts sanity test diff --git a/tests/integration/targets/nxos_facts/vars/main.yml b/tests/integration/targets/nxos_facts/vars/main.yml new file mode 100644 index 000000000..65cf3ce18 --- /dev/null +++ b/tests/integration/targets/nxos_facts/vars/main.yml @@ -0,0 +1,33 @@ +--- +available_network_resources: + - acl_interfaces + - acls + - bfd_interfaces + - bgp_address_family + - bgp_global + - bgp_neighbor_address_family + - bgp_templates + - hostname + - hsrp_interfaces + - interfaces + - l2_interfaces + - l3_interfaces + - lacp + - lacp_interfaces + - lag_interfaces + - lldp_global + - lldp_interfaces + - logging_global + - ntp_global + - ospf_interfaces + - ospfv2 + - ospfv3 + - prefix_lists + - route_maps + - snmp_server + - static_routes + - telemetry + - vlans + - vrf_address_family + - vrf_global + - vrf_interfaces From 2705b1a5962c442d2d883cc1e9f8f60a94542b09 Mon Sep 17 00:00:00 2001 From: Nikhil Bhasin Date: Fri, 3 Oct 2025 14:19:27 +0530 Subject: [PATCH 28/31] revert name change --- .../nxos_facts/tests/common/{__all_facts.yaml => all_facts.yaml} | 0 .../tests/common/{__default_facts.yaml => default_facts.yaml} | 0 .../tests/common/{__interface_facts.yaml => interface_facts.yaml} | 0 .../tests/common/{__invalid_subset.yaml => invalid_subset.yaml} | 0 .../tests/common/{__not_hardware.yaml => not_hardware.yaml} | 0 .../nxos_facts/tests/common/{__sanity.yaml => sanity.yaml} | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename tests/integration/targets/nxos_facts/tests/common/{__all_facts.yaml => all_facts.yaml} (100%) rename tests/integration/targets/nxos_facts/tests/common/{__default_facts.yaml => default_facts.yaml} (100%) rename tests/integration/targets/nxos_facts/tests/common/{__interface_facts.yaml => interface_facts.yaml} (100%) rename tests/integration/targets/nxos_facts/tests/common/{__invalid_subset.yaml => invalid_subset.yaml} (100%) rename tests/integration/targets/nxos_facts/tests/common/{__not_hardware.yaml => not_hardware.yaml} (100%) rename tests/integration/targets/nxos_facts/tests/common/{__sanity.yaml => sanity.yaml} (100%) diff --git a/tests/integration/targets/nxos_facts/tests/common/__all_facts.yaml b/tests/integration/targets/nxos_facts/tests/common/all_facts.yaml similarity index 100% rename from tests/integration/targets/nxos_facts/tests/common/__all_facts.yaml rename to tests/integration/targets/nxos_facts/tests/common/all_facts.yaml diff --git a/tests/integration/targets/nxos_facts/tests/common/__default_facts.yaml b/tests/integration/targets/nxos_facts/tests/common/default_facts.yaml similarity index 100% rename from tests/integration/targets/nxos_facts/tests/common/__default_facts.yaml rename to tests/integration/targets/nxos_facts/tests/common/default_facts.yaml diff --git a/tests/integration/targets/nxos_facts/tests/common/__interface_facts.yaml b/tests/integration/targets/nxos_facts/tests/common/interface_facts.yaml similarity index 100% rename from tests/integration/targets/nxos_facts/tests/common/__interface_facts.yaml rename to tests/integration/targets/nxos_facts/tests/common/interface_facts.yaml diff --git a/tests/integration/targets/nxos_facts/tests/common/__invalid_subset.yaml b/tests/integration/targets/nxos_facts/tests/common/invalid_subset.yaml similarity index 100% rename from tests/integration/targets/nxos_facts/tests/common/__invalid_subset.yaml rename to tests/integration/targets/nxos_facts/tests/common/invalid_subset.yaml diff --git a/tests/integration/targets/nxos_facts/tests/common/__not_hardware.yaml b/tests/integration/targets/nxos_facts/tests/common/not_hardware.yaml similarity index 100% rename from tests/integration/targets/nxos_facts/tests/common/__not_hardware.yaml rename to tests/integration/targets/nxos_facts/tests/common/not_hardware.yaml diff --git a/tests/integration/targets/nxos_facts/tests/common/__sanity.yaml b/tests/integration/targets/nxos_facts/tests/common/sanity.yaml similarity index 100% rename from tests/integration/targets/nxos_facts/tests/common/__sanity.yaml rename to tests/integration/targets/nxos_facts/tests/common/sanity.yaml From 99e9a005ec79b50847a3ca017079ecfacffafb97 Mon Sep 17 00:00:00 2001 From: Nikhil Bhasin Date: Mon, 13 Oct 2025 16:07:56 +0530 Subject: [PATCH 29/31] remove unnecesarry changes --- .../targets/nxos_aaa_server/tasks/nxapi.yaml | 1 - .../tests/common/populate_config.yaml | 2 -- .../tests/common/remove_config.yaml | 36 ------------------- .../tests/common/deleted.yaml | 2 -- .../tests/common/overridden.yaml | 2 -- .../targets/nxos_bgp_global/tasks/main.yaml | 6 ---- .../tests/common/replaced_af.yaml | 2 -- .../targets/nxos_config/tasks/main.yaml | 2 -- .../targets/nxos_devicealias/tasks/main.yaml | 2 -- .../tests/common/interface_facts.yaml | 4 --- .../targets/nxos_file_copy/tasks/main.yaml | 2 -- .../targets/nxos_smoke/tasks/main.yaml | 2 -- .../targets/nxos_telemetry/tasks/main.yaml | 2 -- .../targets/nxos_vsan/tasks/main.yaml | 2 -- .../targets/nxos_zone_zoneset/tasks/main.yaml | 2 -- 15 files changed, 69 deletions(-) diff --git a/tests/integration/targets/nxos_aaa_server/tasks/nxapi.yaml b/tests/integration/targets/nxos_aaa_server/tasks/nxapi.yaml index 05a88b6a3..9446525f3 100644 --- a/tests/integration/targets/nxos_aaa_server/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_aaa_server/tasks/nxapi.yaml @@ -29,4 +29,3 @@ loop_var: test_case_to_run vars: ansible_connection: ansible.netcommon.httpapi - ansible_command_timeout: 90 diff --git a/tests/integration/targets/nxos_acl_interfaces/tests/common/populate_config.yaml b/tests/integration/targets/nxos_acl_interfaces/tests/common/populate_config.yaml index c091cee07..7265d0811 100644 --- a/tests/integration/targets/nxos_acl_interfaces/tests/common/populate_config.yaml +++ b/tests/integration/targets/nxos_acl_interfaces/tests/common/populate_config.yaml @@ -2,5 +2,3 @@ - name: Adding base configuration cisco.nxos.nxos_config: src: populate_config.cfg - retries: 5 - delay: 25 diff --git a/tests/integration/targets/nxos_acl_interfaces/tests/common/remove_config.yaml b/tests/integration/targets/nxos_acl_interfaces/tests/common/remove_config.yaml index d28e6d21c..f76058818 100644 --- a/tests/integration/targets/nxos_acl_interfaces/tests/common/remove_config.yaml +++ b/tests/integration/targets/nxos_acl_interfaces/tests/common/remove_config.yaml @@ -10,12 +10,6 @@ - "interface Ethernet1/2" - " no ipv6 traffic-filter ACL1v6 in" ignore_errors: true - register: remove_config_1 - -- name: Wait for 25 seconds if removal was successful - ansible.builtin.wait_for: - timeout: 25 - when: not remove_config_1.failed - name: Remove configuration - 2 cisco.nxos.nxos_config: @@ -24,12 +18,6 @@ - no ipv6 traffic-filter ACL1v6 in parents: interface Ethernet1/5 ignore_errors: true - register: remove_config_2 - -- name: Wait for 25 seconds if removal was successful - ansible.builtin.wait_for: - timeout: 25 - when: not remove_config_2.failed - name: Remove configuration - 3 cisco.nxos.nxos_config: @@ -38,12 +26,6 @@ - no ip access-group ACL1v4 out parents: interface Ethernet1/3 ignore_errors: true - register: remove_config_3 - -- name: Wait for 25 seconds if removal was successful - ansible.builtin.wait_for: - timeout: 25 - when: not remove_config_3.failed - name: Remove configuration - 4 cisco.nxos.nxos_config: @@ -51,12 +33,6 @@ - no ip access-group NewACLv4 out parents: interface Ethernet1/4 ignore_errors: true - register: remove_config_4 - -- name: Wait for 25 seconds if removal was successful - ansible.builtin.wait_for: - timeout: 25 - when: not remove_config_4.failed - name: Remove configuration - 5 cisco.nxos.nxos_config: @@ -66,20 +42,8 @@ - no ip port access-group PortACL in parents: interface Ethernet1/6 ignore_errors: true - register: remove_config_5 - -- name: Wait for 25 seconds if removal was successful - ansible.builtin.wait_for: - timeout: 25 - when: not remove_config_5.failed - name: Remove configuration - 6 cisco.nxos.nxos_config: lines: no interface loopback1 ignore_errors: true - register: remove_config_6 - -- name: Wait for 25 seconds if removal was successful - ansible.builtin.wait_for: - timeout: 25 - when: not remove_config_6.failed diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/deleted.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/deleted.yaml index 01e3bd07c..7c07064b9 100644 --- a/tests/integration/targets/nxos_bfd_interfaces/tests/common/deleted.yaml +++ b/tests/integration/targets/nxos_bfd_interfaces/tests/common/deleted.yaml @@ -33,8 +33,6 @@ bfd: "{{ bfd_disable|default(omit)}}" echo: disable state: merged - vars: - ansible_command_timeout: 90 - name: Gather bfd_interfaces facts cisco.nxos.nxos_facts: diff --git a/tests/integration/targets/nxos_bfd_interfaces/tests/common/overridden.yaml b/tests/integration/targets/nxos_bfd_interfaces/tests/common/overridden.yaml index fb1696318..8b3a66d4a 100644 --- a/tests/integration/targets/nxos_bfd_interfaces/tests/common/overridden.yaml +++ b/tests/integration/targets/nxos_bfd_interfaces/tests/common/overridden.yaml @@ -22,8 +22,6 @@ - "no feature bfd" - "default interface {{ test_int1 }}" - "default interface {{ test_int2 }}" - vars: - ansible_command_timeout: 90 - block: - name: Setup2 diff --git a/tests/integration/targets/nxos_bgp_global/tasks/main.yaml b/tests/integration/targets/nxos_bgp_global/tasks/main.yaml index f86aecf8c..83d45d652 100644 --- a/tests/integration/targets/nxos_bgp_global/tasks/main.yaml +++ b/tests/integration/targets/nxos_bgp_global/tasks/main.yaml @@ -8,8 +8,6 @@ - name: Enable fabric forwarding cisco.nxos.nxos_config: lines: feature fabric forwarding - vars: - ansible_connection: ansible.netcommon.network_cli - name: Run the CLI and NX-API tests block: @@ -28,11 +26,7 @@ cisco.nxos.nxos_feature: feature: bgp state: disabled - vars: - ansible_connection: ansible.netcommon.network_cli - name: Disable fabric forwarding cisco.nxos.nxos_config: lines: no feature fabric forwarding - vars: - ansible_connection: ansible.netcommon.network_cli diff --git a/tests/integration/targets/nxos_bgp_global/tests/common/replaced_af.yaml b/tests/integration/targets/nxos_bgp_global/tests/common/replaced_af.yaml index e701bdde0..c6e280686 100644 --- a/tests/integration/targets/nxos_bgp_global/tests/common/replaced_af.yaml +++ b/tests/integration/targets/nxos_bgp_global/tests/common/replaced_af.yaml @@ -24,8 +24,6 @@ - " low-memory exempt" - "neighbor 192.0.2.1" - " remote-as 65537" - vars: - ansible_connection: ansible.netcommon.network_cli - block: - name: Remove a neighbor having AF configurations (should fail) diff --git a/tests/integration/targets/nxos_config/tasks/main.yaml b/tests/integration/targets/nxos_config/tasks/main.yaml index 2472d2742..641205bf8 100644 --- a/tests/integration/targets/nxos_config/tasks/main.yaml +++ b/tests/integration/targets/nxos_config/tasks/main.yaml @@ -25,5 +25,3 @@ lines: - hostname {{ inventory_hostname_short }} match: none - vars: - ansible_connection: ansible.netcommon.network_cli diff --git a/tests/integration/targets/nxos_devicealias/tasks/main.yaml b/tests/integration/targets/nxos_devicealias/tasks/main.yaml index 2432a5e40..477fbd41f 100644 --- a/tests/integration/targets/nxos_devicealias/tasks/main.yaml +++ b/tests/integration/targets/nxos_devicealias/tasks/main.yaml @@ -3,8 +3,6 @@ register: result cisco.nxos.nxos_command: commands: show version | grep MDS - vars: - ansible_connection: ansible.netcommon.network_cli - name: Set skip_test flag to false ansible.builtin.set_fact: diff --git a/tests/integration/targets/nxos_facts/tests/common/interface_facts.yaml b/tests/integration/targets/nxos_facts/tests/common/interface_facts.yaml index 8ee8eeeec..2c237d360 100644 --- a/tests/integration/targets/nxos_facts/tests/common/interface_facts.yaml +++ b/tests/integration/targets/nxos_facts/tests/common/interface_facts.yaml @@ -29,10 +29,6 @@ ipv6: - address: 2001:db8::2/32 - - name: Wait a few seconds for IPv6 to apply - ansible.builtin.wait_for: - timeout: 5 - - name: Gather interface facts cisco.nxos.nxos_facts: gather_subset: diff --git a/tests/integration/targets/nxos_file_copy/tasks/main.yaml b/tests/integration/targets/nxos_file_copy/tasks/main.yaml index dc437074d..4eff63f27 100644 --- a/tests/integration/targets/nxos_file_copy/tasks/main.yaml +++ b/tests/integration/targets/nxos_file_copy/tasks/main.yaml @@ -3,8 +3,6 @@ cisco.nxos.nxos_command: commands: show interface mgmt 0 | json register: result - vars: - ansible_connection: ansible.netcommon.network_cli - name: Store mgmt interface IP address ansible.builtin.set_fact: diff --git a/tests/integration/targets/nxos_smoke/tasks/main.yaml b/tests/integration/targets/nxos_smoke/tasks/main.yaml index c5b1206ba..144efbb59 100644 --- a/tests/integration/targets/nxos_smoke/tasks/main.yaml +++ b/tests/integration/targets/nxos_smoke/tasks/main.yaml @@ -19,5 +19,3 @@ lines: - "hostname {{ inventory_hostname_short }}" match: none - vars: - ansible_connection: ansible.netcommon.network_cli diff --git a/tests/integration/targets/nxos_telemetry/tasks/main.yaml b/tests/integration/targets/nxos_telemetry/tasks/main.yaml index 794c93d13..cb0d40859 100644 --- a/tests/integration/targets/nxos_telemetry/tasks/main.yaml +++ b/tests/integration/targets/nxos_telemetry/tasks/main.yaml @@ -17,8 +17,6 @@ cisco.nxos.nxos_command: commands: show interface mgmt 0 | json register: result - vars: - ansible_connection: ansible.netcommon.network_cli - name: Store mgmt interface IP address ansible.builtin.set_fact: diff --git a/tests/integration/targets/nxos_vsan/tasks/main.yaml b/tests/integration/targets/nxos_vsan/tasks/main.yaml index 2432a5e40..477fbd41f 100644 --- a/tests/integration/targets/nxos_vsan/tasks/main.yaml +++ b/tests/integration/targets/nxos_vsan/tasks/main.yaml @@ -3,8 +3,6 @@ register: result cisco.nxos.nxos_command: commands: show version | grep MDS - vars: - ansible_connection: ansible.netcommon.network_cli - name: Set skip_test flag to false ansible.builtin.set_fact: diff --git a/tests/integration/targets/nxos_zone_zoneset/tasks/main.yaml b/tests/integration/targets/nxos_zone_zoneset/tasks/main.yaml index 2432a5e40..477fbd41f 100644 --- a/tests/integration/targets/nxos_zone_zoneset/tasks/main.yaml +++ b/tests/integration/targets/nxos_zone_zoneset/tasks/main.yaml @@ -3,8 +3,6 @@ register: result cisco.nxos.nxos_command: commands: show version | grep MDS - vars: - ansible_connection: ansible.netcommon.network_cli - name: Set skip_test flag to false ansible.builtin.set_fact: From d529018dbdb0fd3edcf89d6b673e8531884b5f17 Mon Sep 17 00:00:00 2001 From: Nikhil Bhasin Date: Thu, 30 Oct 2025 11:57:10 +0530 Subject: [PATCH 30/31] rebase main --- tests/integration/targets/nxos_bgp_global/tasks/main.yaml | 2 ++ .../targets/nxos_command/tests/nxapi/sanity.yaml | 7 ++++--- tests/integration/targets/nxos_facts/tasks/cli.yaml | 4 ++-- tests/integration/targets/nxos_facts/tasks/nxapi.yaml | 4 ++-- .../targets/nxos_facts/tests/common/all_facts.yaml | 4 ++-- .../targets/nxos_facts/tests/common/sanity.yaml | 8 ++++---- tests/integration/targets/nxos_file_copy/tasks/main.yaml | 2 ++ 7 files changed, 18 insertions(+), 13 deletions(-) diff --git a/tests/integration/targets/nxos_bgp_global/tasks/main.yaml b/tests/integration/targets/nxos_bgp_global/tasks/main.yaml index 83d45d652..7e1c3b635 100644 --- a/tests/integration/targets/nxos_bgp_global/tasks/main.yaml +++ b/tests/integration/targets/nxos_bgp_global/tasks/main.yaml @@ -26,6 +26,8 @@ cisco.nxos.nxos_feature: feature: bgp state: disabled + vars: + ansible_connection: ansible.netcommon.network_cli - name: Disable fabric forwarding cisco.nxos.nxos_config: diff --git a/tests/integration/targets/nxos_command/tests/nxapi/sanity.yaml b/tests/integration/targets/nxos_command/tests/nxapi/sanity.yaml index d14cddd4e..ae6cab7b1 100644 --- a/tests/integration/targets/nxos_command/tests/nxapi/sanity.yaml +++ b/tests/integration/targets/nxos_command/tests/nxapi/sanity.yaml @@ -27,9 +27,10 @@ - name: Configure BGP defaults register: result cisco.nxos.nxos_bgp_global: - asn: 65535 - router_id: 192.0.2.1 - state: present + config: + as_number: 65535 + router_id: 192.0.2.1 + state: replaced - ansible.builtin.assert: that: diff --git a/tests/integration/targets/nxos_facts/tasks/cli.yaml b/tests/integration/targets/nxos_facts/tasks/cli.yaml index d3d521f2a..f7bb4de4e 100644 --- a/tests/integration/targets/nxos_facts/tasks/cli.yaml +++ b/tests/integration/targets/nxos_facts/tasks/cli.yaml @@ -3,14 +3,14 @@ ansible.builtin.find: paths: "{{ role_path }}/tests/common" patterns: "{{ testcase }}.yaml" - connection: local + delegate_to: localhost register: test_cases - name: Collect CLI test cases ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" - connection: local + delegate_to: localhost register: cli_cases - name: Set a fact for 'test_cases' diff --git a/tests/integration/targets/nxos_facts/tasks/nxapi.yaml b/tests/integration/targets/nxos_facts/tasks/nxapi.yaml index 5fec0f43b..9446525f3 100644 --- a/tests/integration/targets/nxos_facts/tasks/nxapi.yaml +++ b/tests/integration/targets/nxos_facts/tasks/nxapi.yaml @@ -3,14 +3,14 @@ ansible.builtin.find: paths: "{{ role_path }}/tests/common" patterns: "{{ testcase }}.yaml" - connection: local + delegate_to: localhost register: test_cases - name: Collect NX-API test cases ansible.builtin.find: paths: "{{ role_path }}/tests/nxapi" patterns: "{{ testcase }}.yaml" - connection: local + delegate_to: localhost register: nxapi_cases - name: Set a fact for 'test_cases' diff --git a/tests/integration/targets/nxos_facts/tests/common/all_facts.yaml b/tests/integration/targets/nxos_facts/tests/common/all_facts.yaml index 921f0733f..7aece91d1 100644 --- a/tests/integration/targets/nxos_facts/tests/common/all_facts.yaml +++ b/tests/integration/targets/nxos_facts/tests/common/all_facts.yaml @@ -20,8 +20,8 @@ - result.ansible_facts.ansible_net_config is defined - result.ansible_facts.ansible_net_cpu_utilization is defined - result.ansible_facts.ansible_net_model is defined - - (result.ansible_facts.ansible_net_memfree_mb | default(0)) | int >= 0 - - (result.ansible_facts.ansible_net_memtotal_mb | default(0)) | int >= 0 + - result.ansible_facts.ansible_net_memfree_mb > 1 + - result.ansible_facts.ansible_net_memtotal_mb > 1 - name: Collect list of available network resources for nxos register: result diff --git a/tests/integration/targets/nxos_facts/tests/common/sanity.yaml b/tests/integration/targets/nxos_facts/tests/common/sanity.yaml index 03567f477..1861fa4a7 100644 --- a/tests/integration/targets/nxos_facts/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_facts/tests/common/sanity.yaml @@ -14,8 +14,8 @@ - "'config' not in result.ansible_facts.ansible_net_gather_subset" - "'interfaces' not in result.ansible_facts.ansible_net_gather_subset" - result.ansible_facts.ansible_net_filesystems is defined - - (result.ansible_facts.ansible_net_memfree_mb | default(0)) | int >= 0 - - (result.ansible_facts.ansible_net_memtotal_mb | default(0)) | int >= 0 + - result.ansible_facts.ansible_net_memfree_mb > 1 + - result.ansible_facts.ansible_net_memtotal_mb > 1 - name: Nxos_facts gather configuration facts register: result @@ -45,8 +45,8 @@ - "'interfaces' not in result.ansible_facts.ansible_net_gather_subset" - result.ansible_facts.ansible_net_filesystems is defined - result.ansible_facts.ansible_net_config is defined - - (result.ansible_facts.ansible_net_memfree_mb | default(0)) | int >= 0 - - (result.ansible_facts.ansible_net_memtotal_mb | default(0)) | int >= 0 + - result.ansible_facts.ansible_net_memfree_mb > 1 + - result.ansible_facts.ansible_net_memtotal_mb > 1 - name: Nxos_facts gather features facts register: result diff --git a/tests/integration/targets/nxos_file_copy/tasks/main.yaml b/tests/integration/targets/nxos_file_copy/tasks/main.yaml index 4eff63f27..dc437074d 100644 --- a/tests/integration/targets/nxos_file_copy/tasks/main.yaml +++ b/tests/integration/targets/nxos_file_copy/tasks/main.yaml @@ -3,6 +3,8 @@ cisco.nxos.nxos_command: commands: show interface mgmt 0 | json register: result + vars: + ansible_connection: ansible.netcommon.network_cli - name: Store mgmt interface IP address ansible.builtin.set_fact: From d4f396f5425de0d0d6b5cfab79e2136a64f9702c Mon Sep 17 00:00:00 2001 From: Nikhil Bhasin Date: Thu, 30 Oct 2025 13:57:29 +0530 Subject: [PATCH 31/31] added assertions --- .../tests/common/_remove_config.yaml | 13 +++++++++++-- .../tests/common/empty_config.yaml | 2 +- .../nxos_l2_interfaces/tests/common/overridden.yaml | 2 ++ .../nxos_l2_interfaces/tests/common/replaced.yaml | 5 ++++- .../nxos_l2_interfaces/tests/common/rtt.yaml | 5 +++++ 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/tests/integration/targets/nxos_l2_interfaces/tests/common/_remove_config.yaml b/tests/integration/targets/nxos_l2_interfaces/tests/common/_remove_config.yaml index 37d461651..0b063b998 100644 --- a/tests/integration/targets/nxos_l2_interfaces/tests/common/_remove_config.yaml +++ b/tests/integration/targets/nxos_l2_interfaces/tests/common/_remove_config.yaml @@ -1,9 +1,18 @@ --- - name: Cleanup ignore_errors: true + when: ansible_connection == 'ansible.netcommon.network_cli' cisco.nxos.nxos_config: lines: - "default interface {{ nxos_int1 }}" - "default interface {{ nxos_int2 }}" - vars: - ansible_connection: ansible.netcommon.network_cli + +- name: Cleanup for httpapi + when: ansible_connection == 'ansible.netcommon.httpapi' + ignore_errors: true + cisco.nxos.nxos_config: + lines: + - "{{ item }}" + loop: + - "default interface {{ nxos_int1 }}" + - "default interface {{ nxos_int2 }}" diff --git a/tests/integration/targets/nxos_l2_interfaces/tests/common/empty_config.yaml b/tests/integration/targets/nxos_l2_interfaces/tests/common/empty_config.yaml index 0f222dbbf..39e3869ce 100644 --- a/tests/integration/targets/nxos_l2_interfaces/tests/common/empty_config.yaml +++ b/tests/integration/targets/nxos_l2_interfaces/tests/common/empty_config.yaml @@ -1,6 +1,6 @@ --- - ansible.builtin.debug: - msg: START nxos_lacp empty_config integration tests on connection={{ ansible_connection }} + msg: START nxos_l2_interfaces empty_config integration tests on connection={{ ansible_connection }} - name: Merged with empty configuration should give appropriate error message register: result diff --git a/tests/integration/targets/nxos_l2_interfaces/tests/common/overridden.yaml b/tests/integration/targets/nxos_l2_interfaces/tests/common/overridden.yaml index 077914d28..8dfdce65e 100644 --- a/tests/integration/targets/nxos_l2_interfaces/tests/common/overridden.yaml +++ b/tests/integration/targets/nxos_l2_interfaces/tests/common/overridden.yaml @@ -52,9 +52,11 @@ - result.changed == true - "'interface {{ test_int1 }}' in result.commands" - "'no switchport trunk allowed vlan' in result.commands" + - "'no cdp enable' in result.commands" - "'interface {{ test_int2 }}' in result.commands" - "'switchport access vlan 6' in result.commands" - "'switchport trunk allowed vlan 10-12' in result.commands" + - "'no cdp enable' in result.commands" - name: Gather l2_interfaces post facts cisco.nxos.nxos_facts: *id001 diff --git a/tests/integration/targets/nxos_l2_interfaces/tests/common/replaced.yaml b/tests/integration/targets/nxos_l2_interfaces/tests/common/replaced.yaml index 53e1f4cb3..983d9887c 100644 --- a/tests/integration/targets/nxos_l2_interfaces/tests/common/replaced.yaml +++ b/tests/integration/targets/nxos_l2_interfaces/tests/common/replaced.yaml @@ -71,11 +71,14 @@ - "'interface {{ test_int1 }}' in result.commands" - "'switchport access vlan 8' in result.commands" - "'switchport trunk allowed vlan 10-12' in result.commands" + - "'no cdp enable' in result.commands" - "'interface {{ test_int2 }}' in result.commands" - "'no switchport trunk native vlan 15' in result.commands" + - "'no cdp enable' in result.commands" - "'interface {{ test_int3 }}' in result.commands" - "'switchport trunk allowed vlan none' in result.commands" - - result.commands|length == 7 + - "'no cdp enable' in result.commands" + - result.commands|length == 10 - name: Gather l2_interfaces post facts cisco.nxos.nxos_facts: *id001 diff --git a/tests/integration/targets/nxos_l2_interfaces/tests/common/rtt.yaml b/tests/integration/targets/nxos_l2_interfaces/tests/common/rtt.yaml index 5ef0b101c..f09b92f7b 100644 --- a/tests/integration/targets/nxos_l2_interfaces/tests/common/rtt.yaml +++ b/tests/integration/targets/nxos_l2_interfaces/tests/common/rtt.yaml @@ -24,9 +24,11 @@ trunk: native_vlan: 10 allowed_vlans: 2,4,15 + cdp_enable: false - name: "{{ nxos_int2 }}" access: vlan: 30 + cdp_enable: false state: merged tags: base_config @@ -45,13 +47,16 @@ - name: "{{ nxos_int1 }}" trunk: native_vlan: 20 + cdp_enable: true - name: "{{ nxos_int2 }}" access: vlan: 31 + cdp_enable: true - name: "{{ nxos_int3 }}" trunk: native_vlan: 20 allowed_vlans: 5-10, 15 + cdp_enable: true state: overridden - ansible.builtin.assert: