From 6a0e8cae10f1b97558c933240b2a52a66bf68685 Mon Sep 17 00:00:00 2001 From: Ganesh Nalawade Date: Thu, 2 Nov 2017 11:36:18 +0530 Subject: [PATCH] Fix net platform agnostic network module integration tests (#32489) --- .../net_linkagg/tests/junos/basic.yaml | 70 +++++++++++++++++-- .../targets/net_linkagg/tests/vyos/basic.yaml | 37 +++++----- .../net_lldp_interface/tests/junos/basic.yaml | 30 +++++++- .../targets/net_logging/tests/ios/basic.yaml | 2 +- 4 files changed, 112 insertions(+), 27 deletions(-) diff --git a/test/integration/targets/net_linkagg/tests/junos/basic.yaml b/test/integration/targets/net_linkagg/tests/junos/basic.yaml index 6133221bf77..cb8d235de9d 100644 --- a/test/integration/targets/net_linkagg/tests/junos/basic.yaml +++ b/test/integration/targets/net_linkagg/tests/junos/basic.yaml @@ -100,10 +100,10 @@ - "result.changed == true" - "'' not in config.xml" -- name: Disable linkagg interface +- name: Change device count net_linkagg: name: ae0 - state: down + device_count: 2 provider: "{{ netconf }}" register: result @@ -116,8 +116,19 @@ - assert: that: - "result.changed == true" - - "'' in config.xml" - - "'+ disable;' in result.diff.prepared" + - "'2' in config.xml" + +- name: Disable linkagg interface + net_linkagg: + name: ae0 + state: down + provider: "{{ netconf }}" + register: result + +- assert: + that: + - "result.changed == true" + - result.diff.prepared | search("\+ *disable") - name: Enable linkagg interface net_linkagg: @@ -126,6 +137,50 @@ provider: "{{ netconf }}" register: result +- assert: + that: + - "result.changed == true" + - result.diff.prepared | search("\- *disable") + +- name: Deactivate linkagg + net_linkagg: + name: ae0 + members: + - ge-0/0/6 + - ge-0/0/7 + mode: active + device_count: 4 + state: present + active: False + provider: "{{ netconf }}" + register: result + +- name: Get running configuration + junos_rpc: + rpc: get-configuration + provider: "{{ netconf }}" + register: config + +- assert: + that: + - "result.changed == true" + - "'ae0' in config.xml" + - "'4' in config.xml" + - "'inactive: ae0' in result.diff.prepared" + +- name: Activate linkagg + net_linkagg: + name: ae0 + members: + - ge-0/0/6 + - ge-0/0/7 + mode: active + device_count: 4 + state: present + active: True + provider: "{{ netconf }}" + register: result + - name: Get running configuration junos_rpc: rpc: get-configuration @@ -135,7 +190,10 @@ - assert: that: - "result.changed == true" - - "'' not in config.xml" + - "'' in config.xml" + - "'ae0' in config.xml" + - "'active: device-count 4' in result.diff.prepared" + - "'active: ae0' in result.diff.prepared" - name: Delete linkagg net_linkagg: @@ -178,3 +236,5 @@ - assert: that: - "result.changed == false" + +- debug: msg="END net_linkagg junos/basic.yaml" diff --git a/test/integration/targets/net_linkagg/tests/vyos/basic.yaml b/test/integration/targets/net_linkagg/tests/vyos/basic.yaml index cc5ab485b03..0ef35ebc2e3 100644 --- a/test/integration/targets/net_linkagg/tests/vyos/basic.yaml +++ b/test/integration/targets/net_linkagg/tests/vyos/basic.yaml @@ -4,12 +4,16 @@ name: bond0 state: absent +- name: Remove linkagg + net_linkagg: + name: bond1 + state: absent + - name: Create linkagg net_linkagg: name: bond0 members: - eth1 - - eth2 state: present register: result @@ -18,14 +22,12 @@ - 'result.changed == true' - '"set interfaces bonding bond0 mode 802.3ad" in result.commands' - '"set interfaces ethernet eth1 bond-group bond0" in result.commands' - - '"set interfaces ethernet eth2 bond-group bond0" in result.commands' - name: Create linkagg again (idempotent) net_linkagg: name: bond0 members: - eth1 - - eth2 state: present register: result @@ -37,20 +39,20 @@ net_linkagg: name: bond0 members: - - eth3 + - eth2 state: present register: result - assert: that: - 'result.changed == true' - - '"set interfaces ethernet eth3 bond-group bond0" in result.commands' + - '"set interfaces ethernet eth2 bond-group bond0" in result.commands' - name: Add linkagg member again (idempotent) net_linkagg: name: bond0 members: - - eth3 + - eth2 state: present register: result @@ -111,7 +113,6 @@ - 'result.changed == true' - '"delete interfaces ethernet eth1 bond-group" in result.commands' - '"delete interfaces ethernet eth2 bond-group" in result.commands' - - '"delete interfaces ethernet eth3 bond-group" in result.commands' - '"delete interfaces bonding bond0" in result.commands' - name: Remove linkagg again (idempotent) @@ -127,8 +128,8 @@ - name: Create collection of linkagg definitions net_linkagg: aggregate: - - { name: bond0, members: [eth1, eth2] } - - { name: bond1, members: [eth3, eth4] } + - { name: bond0, members: [eth1] } + - { name: bond1, members: [eth2] } state: present register: result @@ -137,16 +138,14 @@ - 'result.changed == true' - '"set interfaces bonding bond0 mode 802.3ad" in result.commands' - '"set interfaces ethernet eth1 bond-group bond0" in result.commands' - - '"set interfaces ethernet eth2 bond-group bond0" in result.commands' - '"set interfaces bonding bond1 mode 802.3ad" in result.commands' - - '"set interfaces ethernet eth3 bond-group bond1" in result.commands' - - '"set interfaces ethernet eth4 bond-group bond1" in result.commands' + - '"set interfaces ethernet eth2 bond-group bond1" in result.commands' - name: Create collection of linkagg definitions again (idempotent) net_linkagg: aggregate: - - { name: bond0, members: [eth1, eth2] } - - { name: bond1, members: [eth3, eth4] } + - { name: bond0, members: [eth1] } + - { name: bond1, members: [eth2] } state: present register: result @@ -157,8 +156,8 @@ - name: Remove collection of linkagg definitions net_linkagg: aggregate: - - { name: bond0 } - - { name: bond1 } + - name: bond0 + - name: bond1 state: absent register: result @@ -166,17 +165,15 @@ that: - 'result.changed == true' - '"delete interfaces ethernet eth1 bond-group" in result.commands' - - '"delete interfaces ethernet eth2 bond-group" in result.commands' - '"delete interfaces bonding bond0" in result.commands' - - '"delete interfaces ethernet eth1 bond-group" in result.commands' - '"delete interfaces ethernet eth2 bond-group" in result.commands' - '"delete interfaces bonding bond1" in result.commands' - name: Remove collection of linkagg definitions again (idempotent) net_linkagg: aggregate: - - { name: bond0 } - - { name: bond1 } + - name: bond0 + - name: bond1 state: absent register: result diff --git a/test/integration/targets/net_lldp_interface/tests/junos/basic.yaml b/test/integration/targets/net_lldp_interface/tests/junos/basic.yaml index dc83484014f..f2b63982378 100644 --- a/test/integration/targets/net_lldp_interface/tests/junos/basic.yaml +++ b/test/integration/targets/net_lldp_interface/tests/junos/basic.yaml @@ -30,6 +30,32 @@ that: - "result.changed == false" +- name: Deactivate lldp interface configuration + net_lldp_interface: + name: ge-0/0/5 + state: present + active: False + provider: "{{ netconf }}" + register: result + +- assert: + that: + - "result.changed == true" + - result.diff.prepared | search("! *inactive[:] interface ge-0/0/5") + +- name: Activate lldp interface configuration + net_lldp_interface: + name: ge-0/0/5 + state: present + active: True + provider: "{{ netconf }}" + register: result + +- assert: + that: + - "result.changed == true" + - result.diff.prepared | search("! *active[:] interface ge-0/0/5") + - name: Disable lldp on particular interface net_lldp_interface: name: ge-0/0/5 @@ -52,7 +78,7 @@ - assert: that: - "result.changed == true" - - result.diff.prepared | search("\+ *disable") + - result.diff.prepared | search("\- *disable") - name: Delete lldp on particular interface net_lldp_interface: @@ -76,3 +102,5 @@ - assert: that: - "result.changed == false" + +- debug: msg="END net_lldp_interface junos/basic.yaml" diff --git a/test/integration/targets/net_logging/tests/ios/basic.yaml b/test/integration/targets/net_logging/tests/ios/basic.yaml index eaac43f7173..318fd35a1aa 100644 --- a/test/integration/targets/net_logging/tests/ios/basic.yaml +++ b/test/integration/targets/net_logging/tests/ios/basic.yaml @@ -9,7 +9,7 @@ - assert: that: - - 'result.chaned == true' + - 'result.changed == true' - '"logging host 172.16.0.1" in result.commands' - '"logging facility local7" in result.commands'