summaryrefslogtreecommitdiff
path: root/test/integration/targets/iosxr_lacp
diff options
context:
space:
mode:
authorNilashish Chakraborty <nilashishchakraborty8@gmail.com>2019-07-24 22:55:42 +0530
committerGitHub <noreply@github.com>2019-07-24 22:55:42 +0530
commitf2b0bfd4aaa3c71be4c0fb8f566451936aeca629 (patch)
treec317200e1604833b11e1168bfdce7257f4f32616 /test/integration/targets/iosxr_lacp
parent97edfccc702a27ee42312edb5d84e3eb5edb1b3d (diff)
downloadansible-f2b0bfd4aaa3c71be4c0fb8f566451936aeca629.tar.gz
Add iosxr_lacp resource module (#59281)
Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>
Diffstat (limited to 'test/integration/targets/iosxr_lacp')
-rw-r--r--test/integration/targets/iosxr_lacp/defaults/main.yaml3
-rw-r--r--test/integration/targets/iosxr_lacp/tasks/cli.yaml20
-rw-r--r--test/integration/targets/iosxr_lacp/tasks/main.yaml2
-rw-r--r--test/integration/targets/iosxr_lacp/tests/cli/_populate.yaml9
-rw-r--r--test/integration/targets/iosxr_lacp/tests/cli/_remove_config.yaml8
-rw-r--r--test/integration/targets/iosxr_lacp/tests/cli/deleted.yaml45
-rw-r--r--test/integration/targets/iosxr_lacp/tests/cli/merged.yaml45
-rw-r--r--test/integration/targets/iosxr_lacp/tests/cli/replaced.yaml48
-rw-r--r--test/integration/targets/iosxr_lacp/tests/cli/rtt.yaml49
-rw-r--r--test/integration/targets/iosxr_lacp/vars/main.yaml40
10 files changed, 269 insertions, 0 deletions
diff --git a/test/integration/targets/iosxr_lacp/defaults/main.yaml b/test/integration/targets/iosxr_lacp/defaults/main.yaml
new file mode 100644
index 0000000000..164afead28
--- /dev/null
+++ b/test/integration/targets/iosxr_lacp/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/test/integration/targets/iosxr_lacp/tasks/cli.yaml b/test/integration/targets/iosxr_lacp/tasks/cli.yaml
new file mode 100644
index 0000000000..337e34133b
--- /dev/null
+++ b/test/integration/targets/iosxr_lacp/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_lacp/tasks/main.yaml b/test/integration/targets/iosxr_lacp/tasks/main.yaml
new file mode 100644
index 0000000000..415c99d8b1
--- /dev/null
+++ b/test/integration/targets/iosxr_lacp/tasks/main.yaml
@@ -0,0 +1,2 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
diff --git a/test/integration/targets/iosxr_lacp/tests/cli/_populate.yaml b/test/integration/targets/iosxr_lacp/tests/cli/_populate.yaml
new file mode 100644
index 0000000000..5f34cde033
--- /dev/null
+++ b/test/integration/targets/iosxr_lacp/tests/cli/_populate.yaml
@@ -0,0 +1,9 @@
+---
+- name: Setup
+ cli_config:
+ config: "{{ lines }}"
+ vars:
+ lines: |
+ lacp system priority 12
+ lacp system mac 00c1.4c00.bd16
+
diff --git a/test/integration/targets/iosxr_lacp/tests/cli/_remove_config.yaml b/test/integration/targets/iosxr_lacp/tests/cli/_remove_config.yaml
new file mode 100644
index 0000000000..fcdfb194b9
--- /dev/null
+++ b/test/integration/targets/iosxr_lacp/tests/cli/_remove_config.yaml
@@ -0,0 +1,8 @@
+---
+- name: Remove Config
+ cli_config:
+ config: "{{ lines }}"
+ vars:
+ lines: |
+ no lacp system priority
+ no lacp system mac
diff --git a/test/integration/targets/iosxr_lacp/tests/cli/deleted.yaml b/test/integration/targets/iosxr_lacp/tests/cli/deleted.yaml
new file mode 100644
index 0000000000..2d8e537d11
--- /dev/null
+++ b/test/integration/targets/iosxr_lacp/tests/cli/deleted.yaml
@@ -0,0 +1,45 @@
+---
+- debug:
+ msg: "Start iosxr_lacp deleted integration tests ansible_connection={{ ansible_connection }}"
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _populate.yaml
+
+- block:
+ - name: Delete attributes of given interfaces
+ iosxr_lacp: &deleted
+ state: deleted
+ register: result
+
+ - name: Assert that the before dicts were correctly generated
+ assert:
+ that:
+ - "{{ populate == result['before'] }}"
+
+ - name: Assert that the correct set of commands were generated
+ assert:
+ that:
+ - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length == 0 }}"
+
+ - name: Assert that the after dicts were correctly generated
+ assert:
+ that:
+ - "{{ deleted['after'] == result['after'] }}"
+
+ - name: Delete attributes of given interfaces (IDEMPOTENT)
+ iosxr_lacp: *deleted
+ register: result
+
+ - name: Assert that the previous task was idempotent
+ assert:
+ that:
+ - "result.changed == false"
+
+ - name: Assert that the before dicts were correctly generated
+ assert:
+ that:
+ - "{{ deleted['after'] == result['before'] }}"
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/test/integration/targets/iosxr_lacp/tests/cli/merged.yaml b/test/integration/targets/iosxr_lacp/tests/cli/merged.yaml
new file mode 100644
index 0000000000..2fbab882ef
--- /dev/null
+++ b/test/integration/targets/iosxr_lacp/tests/cli/merged.yaml
@@ -0,0 +1,45 @@
+---
+- debug:
+ msg: "START iosxr_lacp merged integration tests on connection={{ ansible_connection }}"
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Merge the provided configuration with the exisiting running configuration
+ iosxr_lacp: &merged
+ config:
+ system:
+ priority: 11
+ mac: 00c1.4c00.bd15
+ state: merged
+ register: result
+
+ - name: Assert that before dicts were correctly generated
+ assert:
+ that: "{{ merged['before'] == result['before'] }}"
+
+ - name: Assert that correct set of commands were generated
+ assert:
+ that:
+ - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}"
+
+ - name: Assert that after dicts was correctly generated
+ assert:
+ that:
+ - "{{ merged['after'] == result['after'] }}"
+
+ - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT)
+ iosxr_lacp: *merged
+ register: result
+
+ - name: Assert that the previous task was idempotent
+ assert:
+ that:
+ - "result['changed'] == false"
+
+ - name: Assert that before dicts were correctly generated
+ assert:
+ that:
+ - "{{ merged['after'] == result['before']}}"
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/test/integration/targets/iosxr_lacp/tests/cli/replaced.yaml b/test/integration/targets/iosxr_lacp/tests/cli/replaced.yaml
new file mode 100644
index 0000000000..9f147b8b1f
--- /dev/null
+++ b/test/integration/targets/iosxr_lacp/tests/cli/replaced.yaml
@@ -0,0 +1,48 @@
+---
+- debug:
+ msg: "START iosxr_lacp replaced integration tests on connection={{ ansible_connection }}"
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _populate.yaml
+
+- block:
+ - name: Replace device configurations of listed interfaces with provided configurations
+ iosxr_lacp: &replaced
+ config:
+ system:
+ priority: 11
+ 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:
+ - "{{ populate == result['before'] }}"
+
+ - name: Assert that after dict is correctly generated
+ assert:
+ that:
+ - "{{ replaced['after'] == result['after'] }}"
+
+ - name: Replace device configurations of listed interfaces with provided configurarions (IDEMPOTENT)
+ iosxr_lacp: *replaced
+ register: result
+
+ - name: Assert that task was idempotent
+ assert:
+ that:
+ - "result['changed'] == false"
+
+ - name: Assert that before dict is correctly generated
+ assert:
+ that:
+ - "{{ replaced['after'] == result['before'] }}"
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/test/integration/targets/iosxr_lacp/tests/cli/rtt.yaml b/test/integration/targets/iosxr_lacp/tests/cli/rtt.yaml
new file mode 100644
index 0000000000..aa449ab6e6
--- /dev/null
+++ b/test/integration/targets/iosxr_lacp/tests/cli/rtt.yaml
@@ -0,0 +1,49 @@
+---
+- debug:
+ msg: "START isoxr_lacp round trip integration tests on connection={{ ansible_connection }}"
+
+- block:
+ - include_tasks: _remove_config.yaml
+
+ - name: Apply the provided configuration (base config)
+ iosxr_lacp:
+ config:
+ system:
+ priority: 15
+ mac: 00c1.4c00.bd16
+ state: merged
+ register: base_config
+
+ - name: Gather interfaces facts
+ iosxr_facts:
+ gather_subset:
+ - "!all"
+ - "!min"
+ gather_network_resources:
+ - lacp
+
+ - name: Apply the provided configuration (config to be reverted)
+ iosxr_lacp:
+ config:
+ system:
+ priority: 10
+ mac: 00c1.4c00.bd10
+ state: merged
+ register: result
+
+ - name: Assert that changes were applied
+ assert:
+ that: "{{ round_trip['after'] == result['after'] }}"
+
+ - name: Revert back to base config using facts round trip
+ iosxr_lacp:
+ config: "{{ ansible_facts['network_resources']['lacp'] }}"
+ state: replaced
+ register: revert
+
+ - name: Assert that config was reverted
+ assert:
+ that: "{{ base_config['after'] == revert['after'] }}"
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/test/integration/targets/iosxr_lacp/vars/main.yaml b/test/integration/targets/iosxr_lacp/vars/main.yaml
new file mode 100644
index 0000000000..6c8e835ab4
--- /dev/null
+++ b/test/integration/targets/iosxr_lacp/vars/main.yaml
@@ -0,0 +1,40 @@
+---
+merged:
+ before: {}
+
+ commands:
+ - "lacp system priority 11"
+ - "lacp system mac 00c1.4c00.bd15"
+
+ after:
+ system:
+ priority: 11
+ mac: "00c1.4c00.bd15"
+
+populate:
+ system:
+ priority: 12
+ mac: "00c1.4c00.bd16"
+
+replaced:
+ commands:
+ - "no lacp system mac"
+ - "lacp system priority 11"
+
+ after:
+ system:
+ priority: 11
+
+deleted:
+ commands:
+ - "no lacp system priority"
+ - "no lacp system mac"
+
+ after: {}
+
+round_trip:
+ after:
+ system:
+ priority: 10
+ mac: "00c1.4c00.bd10"
+