From bafc95eb0f24de5fffbfe2854ec5046efc230dc5 Mon Sep 17 00:00:00 2001 From: Ganesh Nalawade Date: Mon, 17 Jun 2019 20:52:47 +0530 Subject: [PATCH] More iosxr integration zuul CI test fixes (#57909) * Ignore `` node from candidate and running configuration in xml diff * Add route-policy as prerequisite to BGP coonfiguration in integration test (cherry picked from commit 4a3e14f90b95108e56a670a11ca66afdfd93ef09) --- .../fragments/iosxr_fix_netconf_test_failures.yaml | 3 +++ lib/ansible/module_utils/network/iosxr/iosxr.py | 8 ++++++-- .../targets/iosxr_bgp/tests/cli/basic.yaml | 14 +++++++++++++- .../targets/netconf_config/tests/iosxr/basic.yaml | 1 + .../targets/netconf_get/tests/iosxr/basic.yaml | 2 +- 5 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/iosxr_fix_netconf_test_failures.yaml diff --git a/changelogs/fragments/iosxr_fix_netconf_test_failures.yaml b/changelogs/fragments/iosxr_fix_netconf_test_failures.yaml new file mode 100644 index 00000000000..e44d1ab2d8d --- /dev/null +++ b/changelogs/fragments/iosxr_fix_netconf_test_failures.yaml @@ -0,0 +1,3 @@ +bugfixes: + - Fix iosxr netconf config diff and integration test failures (https://github.com/ansible/ansible/pull/57909) + - Fix issues in iosxr integration test (https://github.com/ansible/ansible/pull/57882) diff --git a/lib/ansible/module_utils/network/iosxr/iosxr.py b/lib/ansible/module_utils/network/iosxr/iosxr.py index 8825ca0cea3..7b59331ae3f 100644 --- a/lib/ansible/module_utils/network/iosxr/iosxr.py +++ b/lib/ansible/module_utils/network/iosxr/iosxr.py @@ -345,8 +345,12 @@ def get_config_diff(module, running=None, candidate=None): return response elif is_netconf(module): if running and candidate: - running_data = running.split("\n", 1)[1].rsplit("\n", 1)[0] - candidate_data = candidate.split("\n", 1)[1].rsplit("\n", 1)[0] + # ignore rpc-reply root node and diff from data element onwards + running_data_ele = etree.fromstring(to_bytes(running.strip())).getchildren()[0] + candidate_data_ele = etree.fromstring(to_bytes(candidate.strip())).getchildren()[0] + + running_data = to_text(etree.tostring(running_data_ele)).strip() + candidate_data = to_text(etree.tostring(candidate_data_ele)).strip() if running_data != candidate_data: d = Differ() diff = list(d.compare(running_data.splitlines(), candidate_data.splitlines())) diff --git a/test/integration/targets/iosxr_bgp/tests/cli/basic.yaml b/test/integration/targets/iosxr_bgp/tests/cli/basic.yaml index fba1e33e078..bb3755916b8 100644 --- a/test/integration/targets/iosxr_bgp/tests/cli/basic.yaml +++ b/test/integration/targets/iosxr_bgp/tests/cli/basic.yaml @@ -108,6 +108,14 @@ that: - 'result.changed == false' + - name: create route-policy as prerequisite for BGP configuration + iosxr_config: + lines: + - no route-policy RMAP_1 + - route-policy RMAP_1 + - exit + register: result + - name: Configure networks under address family iosxr_bgp: &af_net operation: merge @@ -228,7 +236,11 @@ - assert: that: - 'result.changed == false' - + + - name: delete route-policy configures as prerequisite for BGP configuration (teardown) + iosxr_config: + lines: no route-policy RMAP_1 + when: facts['ansible_facts']['ansible_net_version'].split('[')[0] == '6.1.3' - debug: msg="END iosxr cli/iosxr_bgp.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/netconf_config/tests/iosxr/basic.yaml b/test/integration/targets/netconf_config/tests/iosxr/basic.yaml index 92a3ff6111d..c2cd38974de 100644 --- a/test/integration/targets/netconf_config/tests/iosxr/basic.yaml +++ b/test/integration/targets/netconf_config/tests/iosxr/basic.yaml @@ -5,6 +5,7 @@ netconf_config: backup: yes register: result + connection: netconf - assert: that: diff --git a/test/integration/targets/netconf_get/tests/iosxr/basic.yaml b/test/integration/targets/netconf_get/tests/iosxr/basic.yaml index fa03bb30eca..0a6066d4fa8 100644 --- a/test/integration/targets/netconf_get/tests/iosxr/basic.yaml +++ b/test/integration/targets/netconf_get/tests/iosxr/basic.yaml @@ -114,7 +114,7 @@ - assert: that: - - "{{ result['output']['rpc-reply']['data']['aaa'] is defined}}" + - "{{ result['output']['data']['aaa'] is defined}}" - name: get configuration data in xml pretty format netconf_get: