diff options
author | Sumit Jaiswal <sjaiswal@redhat.com> | 2019-08-29 17:58:48 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-29 17:58:48 +0530 |
commit | 4d73c7b3975647ed709eb5fdb2f3beebad1f7309 (patch) | |
tree | 21c2e4e581c98ded4920dec646117cf58eb77d2f /test | |
parent | 68f34351fcd623e09d18baf5edaa6c91f8aa0299 (diff) | |
download | ansible-4d73c7b3975647ed709eb5fdb2f3beebad1f7309.tar.gz |
Resource module for iosxr_l3_interfaces (#60464)
* iosxr_l3_interfaces module
Diffstat (limited to 'test')
14 files changed, 440 insertions, 12 deletions
diff --git a/test/integration/targets/iosxr_interfaces/tests/cli/_remove_config.yaml b/test/integration/targets/iosxr_interfaces/tests/cli/_remove_config.yaml index c4452c8d90..650c581114 100644 --- a/test/integration/targets/iosxr_interfaces/tests/cli/_remove_config.yaml +++ b/test/integration/targets/iosxr_interfaces/tests/cli/_remove_config.yaml @@ -18,7 +18,6 @@ loop: - GigabitEthernet 0/0/0/0 - GigabitEthernet 0/0/0/1 - - preconfigure GigabitEthernet 0/0/0/1 - - preconfigure GigabitEthernet 0/0/0/2 - - preconfigure GigabitEthernet 0/0/0/3 + - GigabitEthernet 0/0/0/2 + - GigabitEthernet 0/0/0/3 ignore_errors: yes diff --git a/test/integration/targets/iosxr_l2_interfaces/tests/cli/_remove_config.yaml b/test/integration/targets/iosxr_l2_interfaces/tests/cli/_remove_config.yaml index d429769d9f..4484fbe8fd 100644 --- a/test/integration/targets/iosxr_l2_interfaces/tests/cli/_remove_config.yaml +++ b/test/integration/targets/iosxr_l2_interfaces/tests/cli/_remove_config.yaml @@ -11,6 +11,3 @@ no interface GigabitEthernet 0/0/0/3 no interface GigabitEthernet 0/0/0/3.900 no interface GigabitEthernet 0/0/0/4 - no interface preconfigure GigabitEthernet 0/0/0/3 - no interface preconfigure GigabitEthernet 0/0/0/3.900 - no interface preconfigure GigabitEthernet 0/0/0/4 diff --git a/test/integration/targets/iosxr_l2_interfaces/tests/cli/overridden.yaml b/test/integration/targets/iosxr_l2_interfaces/tests/cli/overridden.yaml index dc37d87b4a..f9ed4bf725 100644 --- a/test/integration/targets/iosxr_l2_interfaces/tests/cli/overridden.yaml +++ b/test/integration/targets/iosxr_l2_interfaces/tests/cli/overridden.yaml @@ -22,12 +22,6 @@ state: overridden register: result - - debug: - msg: - - "{{ overridden['commands'] | symmetric_difference(result['commands']) }}" - - "{{ overridden['before'] | symmetric_difference(result['before']) }}" - - "{{ overridden['after'] | symmetric_difference(result['after']) }}" - - name: Assert that correct set of commands were generated assert: that: diff --git a/test/integration/targets/iosxr_l3_interfaces/defaults/main.yaml b/test/integration/targets/iosxr_l3_interfaces/defaults/main.yaml new file mode 100644 index 0000000000..164afead28 --- /dev/null +++ b/test/integration/targets/iosxr_l3_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/test/integration/targets/iosxr_l3_interfaces/meta/main.yaml b/test/integration/targets/iosxr_l3_interfaces/meta/main.yaml new file mode 100644 index 0000000000..32cf5dda7e --- /dev/null +++ b/test/integration/targets/iosxr_l3_interfaces/meta/main.yaml @@ -0,0 +1 @@ +dependencies: [] diff --git a/test/integration/targets/iosxr_l3_interfaces/tasks/cli.yaml b/test/integration/targets/iosxr_l3_interfaces/tasks/cli.yaml new file mode 100644 index 0000000000..337e34133b --- /dev/null +++ b/test/integration/targets/iosxr_l3_interfaces/tasks/cli.yaml @@ -0,0 +1,20 @@ +--- +- name: Collect all cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + use_regex: true + register: test_cases + delegate_to: localhost + +- name: Set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + delegate_to: localhost + +- name: Run test case (connection=network_cli) + include: "{{ test_case_to_run }}" + vars: + ansible_connection: network_cli + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/test/integration/targets/iosxr_l3_interfaces/tasks/main.yaml b/test/integration/targets/iosxr_l3_interfaces/tasks/main.yaml new file mode 100644 index 0000000000..415c99d8b1 --- /dev/null +++ b/test/integration/targets/iosxr_l3_interfaces/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/iosxr_l3_interfaces/tests/cli/_populate_config.yaml b/test/integration/targets/iosxr_l3_interfaces/tests/cli/_populate_config.yaml new file mode 100644 index 0000000000..177d2d9028 --- /dev/null +++ b/test/integration/targets/iosxr_l3_interfaces/tests/cli/_populate_config.yaml @@ -0,0 +1,16 @@ +--- +- name: Populate Config + cli_config: + config: "{{ lines }}" + vars: + lines: | + interface GigabitEthernet 0/0/0/1 + ipv4 address 198.51.100.1 255.255.255.0 + interface GigabitEthernet 0/0/0/2 + ipv4 address 192.0.2.1 255.255.255.0 + ipv4 address 192.0.2.2 255.255.255.0 secondary + interface GigabitEthernet 0/0/0/3 + ipv4 address 203.0.110.1 255.255.255.0 + ipv6 address 2001:db8::/32 + interface GigabitEthernet 0/0/0/3.100 + ipv4 address 203.0.113.1 255.255.255.0 diff --git a/test/integration/targets/iosxr_l3_interfaces/tests/cli/_remove_config.yaml b/test/integration/targets/iosxr_l3_interfaces/tests/cli/_remove_config.yaml new file mode 100644 index 0000000000..a96cdb7f42 --- /dev/null +++ b/test/integration/targets/iosxr_l3_interfaces/tests/cli/_remove_config.yaml @@ -0,0 +1,13 @@ +--- +- name: Remove Config + cli_config: + config: "{{ lines }}" + vars: + lines: | + interface GigabitEthernet 0/0/0/1 + no ipv4 address + no ipv6 address + no interface GigabitEthernet 0/0/0/2 + no interface GigabitEthernet 0/0/0/3 + no interface GigabitEthernet 0/0/0/3.100 + no interface GigabitEthernet 0/0/0/4 diff --git a/test/integration/targets/iosxr_l3_interfaces/tests/cli/deleted.yaml b/test/integration/targets/iosxr_l3_interfaces/tests/cli/deleted.yaml new file mode 100644 index 0000000000..8c1d5ca3f9 --- /dev/null +++ b/test/integration/targets/iosxr_l3_interfaces/tests/cli/deleted.yaml @@ -0,0 +1,45 @@ +--- +- debug: + msg: "Start Deleted integration state for iosxr_l3_interfaces ansible_connection={{ ansible_connection }}" + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate_config.yaml + +- block: + - name: Delete attributes of all configured interfaces + iosxr_l3_interfaces: &deleted + config: + - name: GigabitEthernet0/0/0/1 + - name: GigabitEthernet0/0/0/2 + - name: GigabitEthernet0/0/0/3 + - name: GigabitEthernet0/0/0/3.100 + state: deleted + register: result + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ deleted['commands'] | symmetric_difference(result['commands']) | length == 0 }}" + + - name: Assert that before dicts are correctly generated + assert: + that: + - "{{ deleted['before'] | symmetric_difference(result['before']) | length == 0 }}" + + - name: Assert that after dict is correctly generated + assert: + that: + - "{{ deleted['after'] | symmetric_difference(result['after']) | length == 0 }}" + + - name: Delete attributes of all configured interfaces (IDEMPOTENT) + iosxr_l3_interfaces: *deleted + register: result + + - name: Assert that the previous task was idempotent + assert: + that: + - "result.changed == false" + + always: + - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/iosxr_l3_interfaces/tests/cli/merged.yaml b/test/integration/targets/iosxr_l3_interfaces/tests/cli/merged.yaml new file mode 100644 index 0000000000..02a0293a19 --- /dev/null +++ b/test/integration/targets/iosxr_l3_interfaces/tests/cli/merged.yaml @@ -0,0 +1,59 @@ +--- +- debug: + msg: "START Merged iosxr_l3_interfaces state for integration tests on connection={{ ansible_connection }}" + +- include_tasks: _remove_config.yaml + +- block: + - name: Merge provided configuration with device configuration + iosxr_l3_interfaces: &merged + config: + - name: GigabitEthernet0/0/0/1 + ipv4: + - address: 198.51.100.1/24 + - name: GigabitEthernet0/0/0/2 + ipv6: + - address: 2001:db8:0:3::/64 + ipv4: + - address: 192.0.2.1/24 + - address: 192.0.2.2/24 + secondary: True + - name: GigabitEthernet0/0/0/3 + ipv4: + - address: 203.0.110.1/24 + - address: 203.0.110.5/24 + secondary: True + - name: GigabitEthernet0/0/0/3.100 + ipv4: + - address: 198.51.100.14/24 + ipv6: + - address: 2001:db8:0:4::/64 + state: merged + register: result + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ merged['commands'] | symmetric_difference(result['commands']) | length == 0 }}" + + - name: Assert that before dicts are correctly generated + assert: + that: + - "{{ merged['before'] | symmetric_difference(result['before']) | length == 0 }}" + + - name: Assert that after dict is correctly generated + assert: + that: + - "{{ merged['after'] | symmetric_difference(result['after']) | length == 0 }}" + + - name: Merge provided configuration with device configuration (IDEMPOTENT) + iosxr_l3_interfaces: *merged + register: result + + - name: Assert that the previous task was idempotent + assert: + that: + - "result['changed'] == false" + + always: + - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/iosxr_l3_interfaces/tests/cli/overridden.yaml b/test/integration/targets/iosxr_l3_interfaces/tests/cli/overridden.yaml new file mode 100644 index 0000000000..7e2e8440ec --- /dev/null +++ b/test/integration/targets/iosxr_l3_interfaces/tests/cli/overridden.yaml @@ -0,0 +1,49 @@ +--- +- debug: + msg: "START Overridden iosxr_l3_interfaces state for integration tests on connection={{ ansible_connection }}" + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate_config.yaml + +- block: + - name: Override device configuration of all interfaces with provided configuration + iosxr_l3_interfaces: &overridden + config: + - name: GigabitEthernet0/0/0/3 + ipv4: + - address: 203.0.112.24/24 + - name: GigabitEthernet0/0/0/3.100 + ipv4: + - address: 198.51.102.1/24 + ipv6: + - address: 2001:db8:1::/64 + state: overridden + register: result + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ overridden['commands'] | symmetric_difference(result['commands']) | length == 0 }}" + + - name: Assert that before dicts are correctly generated + assert: + that: + - "{{ overridden['before'] | symmetric_difference(result['before']) | length == 0 }}" + + - name: Assert that after dict is correctly generated + assert: + that: + - "{{ overridden['after'] | symmetric_difference(result['after']) | length == 0 }}" + + - name: Override device configuration of all interfaces with provided configuration (IDEMPOTENT) + iosxr_l3_interfaces: *overridden + register: result + + - name: Assert that task was idempotent + assert: + that: + - "result['changed'] == false" + + always: + - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/iosxr_l3_interfaces/tests/cli/replaced.yaml b/test/integration/targets/iosxr_l3_interfaces/tests/cli/replaced.yaml new file mode 100644 index 0000000000..a867fbd6ce --- /dev/null +++ b/test/integration/targets/iosxr_l3_interfaces/tests/cli/replaced.yaml @@ -0,0 +1,52 @@ +--- +- debug: + msg: "START Replaced iosxr_l3_interfaces state for integration tests on connection={{ ansible_connection }}" + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate_config.yaml + +- block: + - name: Replaces device configuration of listed interfaces with provided configuration + iosxr_l3_interfaces: &replaced + config: + - name: GigabitEthernet0/0/0/1 + ipv4: + - address: 203.0.113.27/24 + - name: GigabitEthernet0/0/0/2 + ipv4: + - address: 203.0.115.2/24 + - address: 203.0.114.1/24 + secondary: True + - name: GigabitEthernet0/0/0/3.100 + ipv4: + - address: 192.0.2.10/24 + state: replaced + register: result + + - name: Assert that correct set of commands were generated + assert: + that: + - "{{ replaced['commands'] | symmetric_difference(result['commands']) | length == 0 }}" + + - name: Assert that before dicts are correctly generated + assert: + that: + - "{{ replaced['before'] | symmetric_difference(result['before']) | length == 0 }}" + + - name: Assert that after dict is correctly generated + assert: + that: + - "{{ replaced['after'] | symmetric_difference(result['after']) | length == 0 }}" + + - name: Replaces device configuration of listed interfaces with provided configuration (IDEMPOTENT) + iosxr_l3_interfaces: *replaced + register: result + + - name: Assert that task was idempotent + assert: + that: + - "result['changed'] == false" + + always: + - include_tasks: _remove_config.yaml diff --git a/test/integration/targets/iosxr_l3_interfaces/vars/main.yaml b/test/integration/targets/iosxr_l3_interfaces/vars/main.yaml new file mode 100644 index 0000000000..2d66aeb55d --- /dev/null +++ b/test/integration/targets/iosxr_l3_interfaces/vars/main.yaml @@ -0,0 +1,178 @@ +--- +merged: + before: + - name: Loopback888 + - name: Loopback999 + + commands: + - "interface GigabitEthernet0/0/0/1" + - "ipv4 address 198.51.100.1 255.255.255.0" + - "interface GigabitEthernet0/0/0/2" + - "ipv4 address 192.0.2.2 255.255.255.0 secondary" + - "ipv4 address 192.0.2.1 255.255.255.0" + - "ipv6 address 2001:db8:0:3::/64" + - "interface GigabitEthernet0/0/0/3" + - "ipv4 address 203.0.110.1 255.255.255.0" + - "ipv4 address 203.0.110.5 255.255.255.0 secondary" + - "interface GigabitEthernet0/0/0/3.100" + - "ipv4 address 198.51.100.14 255.255.255.0" + - "ipv6 address 2001:db8:0:4::/64" + + after: + - name: Loopback888 + - name: Loopback999 + - ipv4: + - address: 198.51.100.1 255.255.255.0 + name: GigabitEthernet0/0/0/1 + - ipv4: + - address: 192.0.2.1 255.255.255.0 + - address: 192.0.2.2 255.255.255.0 + secondary: true + ipv6: + - address: 2001:db8:0:3::/64 + name: GigabitEthernet0/0/0/2 + - ipv4: + - address: 203.0.110.1 255.255.255.0 + - address: 203.0.110.5 255.255.255.0 + secondary: true + name: GigabitEthernet0/0/0/3 + - ipv4: + - address: 198.51.100.14 255.255.255.0 + ipv6: + - address: 2001:db8:0:4::/64 + name: GigabitEthernet0/0/0/3.100 + +replaced: + before: + - name: Loopback888 + - name: Loopback999 + - ipv4: + - address: 198.51.100.1 255.255.255.0 + name: GigabitEthernet0/0/0/1 + - ipv4: + - address: 192.0.2.1 255.255.255.0 + - address: 192.0.2.2 255.255.255.0 + secondary: true + name: GigabitEthernet0/0/0/2 + - ipv4: + - address: 203.0.110.1 255.255.255.0 + ipv6: + - address: 2001:db8::/32 + name: GigabitEthernet0/0/0/3 + - ipv4: + - address: 203.0.113.1 255.255.255.0 + name: GigabitEthernet0/0/0/3.100 + + commands: + - "interface GigabitEthernet0/0/0/1" + - "ipv4 address 203.0.113.27 255.255.255.0" + - "interface GigabitEthernet0/0/0/2" + - "no ipv4 address" + - "ipv4 address 203.0.115.2 255.255.255.0" + - "ipv4 address 203.0.114.1 255.255.255.0 secondary" + - "interface GigabitEthernet0/0/0/3.100" + - "ipv4 address 192.0.2.10 255.255.255.0" + + after: + - name: Loopback888 + - name: Loopback999 + - ipv4: + - address: 203.0.113.27 255.255.255.0 + name: GigabitEthernet0/0/0/1 + - ipv4: + - address: 203.0.115.2 255.255.255.0 + - address: 203.0.114.1 255.255.255.0 + secondary: true + name: GigabitEthernet0/0/0/2 + - ipv4: + - address: 203.0.110.1 255.255.255.0 + ipv6: + - address: 2001:db8::/32 + name: GigabitEthernet0/0/0/3 + - ipv4: + - address: 192.0.2.10 255.255.255.0 + name: GigabitEthernet0/0/0/3.100 + +overridden: + before: + - name: Loopback888 + - name: Loopback999 + - ipv4: + - address: 198.51.100.1 255.255.255.0 + name: GigabitEthernet0/0/0/1 + - ipv4: + - address: 192.0.2.1 255.255.255.0 + - address: 192.0.2.2 255.255.255.0 + secondary: true + name: GigabitEthernet0/0/0/2 + - ipv4: + - address: 203.0.110.1 255.255.255.0 + ipv6: + - address: 2001:db8::/32 + name: GigabitEthernet0/0/0/3 + - ipv4: + - address: 203.0.113.1 255.255.255.0 + name: GigabitEthernet0/0/0/3.100 + + commands: + - "interface GigabitEthernet0/0/0/1" + - "no ipv4 address" + - "interface GigabitEthernet0/0/0/2" + - "no ipv4 address" + - "interface GigabitEthernet0/0/0/3" + - "no ipv6 address" + - "ipv4 address 203.0.112.24 255.255.255.0" + - "interface GigabitEthernet0/0/0/3.100" + - "ipv4 address 198.51.102.1 255.255.255.0" + - "ipv6 address 2001:db8:1::/64" + + after: + - name: Loopback888 + - name: Loopback999 + - name: GigabitEthernet0/0/0/2 + - ipv4: + - address: 203.0.112.24 255.255.255.0 + name: GigabitEthernet0/0/0/3 + - ipv4: + - address: 198.51.102.1 255.255.255.0 + ipv6: + - address: 2001:db8:1::/64 + name: GigabitEthernet0/0/0/3.100 + +deleted: + before: + - name: Loopback888 + - name: Loopback999 + - ipv4: + - address: 198.51.100.1 255.255.255.0 + name: GigabitEthernet0/0/0/1 + - ipv4: + - address: 192.0.2.1 255.255.255.0 + - address: 192.0.2.2 255.255.255.0 + secondary: true + name: GigabitEthernet0/0/0/2 + - ipv4: + - address: 203.0.110.1 255.255.255.0 + ipv6: + - address: 2001:db8::/32 + name: GigabitEthernet0/0/0/3 + - ipv4: + - address: 203.0.113.1 255.255.255.0 + name: GigabitEthernet0/0/0/3.100 + + commands: + - "interface GigabitEthernet0/0/0/1" + - "no ipv4 address" + - "interface GigabitEthernet0/0/0/2" + - "no ipv4 address" + - "interface GigabitEthernet0/0/0/3" + - "no ipv4 address" + - "no ipv6 address" + - "interface GigabitEthernet0/0/0/3.100" + - "no ipv4 address" + + after: + - name: Loopback888 + - name: Loopback999 + - name: GigabitEthernet0/0/0/3 + - name: GigabitEthernet0/0/0/3.100 |