summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBradley A. Thornton <bthornto@thethorntons.net>2019-08-19 07:56:36 -0700
committerBradley A. Thornton <bthornto@thethorntons.net>2019-08-19 07:56:36 -0700
commit7d4127b40ce899b43180df68d84ec6adcda20c0e (patch)
treeb5d5a7a85b6aa288ea4d183e129d00d2b9b8d527 /test
parent3fabcd898a415a724048f445dfc35e29f895fe2e (diff)
downloadvyos-ansible-collection-7d4127b40ce899b43180df68d84ec6adcda20c0e.tar.gz
vyos-ansible-collection-7d4127b40ce899b43180df68d84ec6adcda20c0e.zip
based on ansible/ansible 843a51628b49d7aaa1447616fe0fcdf6a4ec7b1a
Diffstat (limited to 'test')
-rw-r--r--test/integration/targets/vyos_lldp_global/defaults/main.yaml3
-rw-r--r--test/integration/targets/vyos_lldp_global/tasks/cli.yaml19
-rw-r--r--test/integration/targets/vyos_lldp_global/tasks/main.yaml2
-rw-r--r--test/integration/targets/vyos_lldp_global/tests/cli/_populate.yaml9
-rw-r--r--test/integration/targets/vyos_lldp_global/tests/cli/_remove_config.yaml9
-rw-r--r--test/integration/targets/vyos_lldp_global/tests/cli/deleted.yaml44
-rw-r--r--test/integration/targets/vyos_lldp_global/tests/cli/merged.yaml49
-rw-r--r--test/integration/targets/vyos_lldp_global/tests/cli/replaced.yaml51
-rw-r--r--test/integration/targets/vyos_lldp_global/tests/cli/rtt.yaml51
-rw-r--r--test/integration/targets/vyos_lldp_global/vars/main.yaml56
10 files changed, 293 insertions, 0 deletions
diff --git a/test/integration/targets/vyos_lldp_global/defaults/main.yaml b/test/integration/targets/vyos_lldp_global/defaults/main.yaml
new file mode 100644
index 0000000..164afea
--- /dev/null
+++ b/test/integration/targets/vyos_lldp_global/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/test/integration/targets/vyos_lldp_global/tasks/cli.yaml b/test/integration/targets/vyos_lldp_global/tasks/cli.yaml
new file mode 100644
index 0000000..655e51e
--- /dev/null
+++ b/test/integration/targets/vyos_lldp_global/tasks/cli.yaml
@@ -0,0 +1,19 @@
+---
+- 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 }}"
+
+- 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/vyos_lldp_global/tasks/main.yaml b/test/integration/targets/vyos_lldp_global/tasks/main.yaml
new file mode 100644
index 0000000..415c99d
--- /dev/null
+++ b/test/integration/targets/vyos_lldp_global/tasks/main.yaml
@@ -0,0 +1,2 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
diff --git a/test/integration/targets/vyos_lldp_global/tests/cli/_populate.yaml b/test/integration/targets/vyos_lldp_global/tests/cli/_populate.yaml
new file mode 100644
index 0000000..088aa7b
--- /dev/null
+++ b/test/integration/targets/vyos_lldp_global/tests/cli/_populate.yaml
@@ -0,0 +1,9 @@
+---
+- name: Setup
+ network.cli.cli_config:
+ config: "{{ lines }}"
+ vars:
+ lines: |
+ set service lldp
+ set service lldp legacy-protocols 'cdp'
+ set service lldp management-address '192.0.2.17'
diff --git a/test/integration/targets/vyos_lldp_global/tests/cli/_remove_config.yaml b/test/integration/targets/vyos_lldp_global/tests/cli/_remove_config.yaml
new file mode 100644
index 0000000..b000a94
--- /dev/null
+++ b/test/integration/targets/vyos_lldp_global/tests/cli/_remove_config.yaml
@@ -0,0 +1,9 @@
+---
+- name: Remove Config
+ network.cli.cli_config:
+ config: "{{ lines }}"
+ vars:
+ lines: |
+ delete service lldp legacy-protocols
+ delete service lldp management-address
+ delete service lldp
diff --git a/test/integration/targets/vyos_lldp_global/tests/cli/deleted.yaml b/test/integration/targets/vyos_lldp_global/tests/cli/deleted.yaml
new file mode 100644
index 0000000..79660af
--- /dev/null
+++ b/test/integration/targets/vyos_lldp_global/tests/cli/deleted.yaml
@@ -0,0 +1,44 @@
+---
+- debug:
+ msg: "Start vyos_lldp_global deleted integration tests ansible_connection={{ ansible_connection }}"
+
+- include_tasks: _populate.yaml
+
+- block:
+ - name: Delete attributes of LLDP service.
+ vyos.vyos.vyos_lldp_global: &deleted
+ config:
+ 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)
+ vyos.vyos.vyos_lldp_global: *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/vyos_lldp_global/tests/cli/merged.yaml b/test/integration/targets/vyos_lldp_global/tests/cli/merged.yaml
new file mode 100644
index 0000000..b1687da
--- /dev/null
+++ b/test/integration/targets/vyos_lldp_global/tests/cli/merged.yaml
@@ -0,0 +1,49 @@
+---
+- debug:
+ msg: "START vyos_lldp_global merged integration tests on connection={{ ansible_connection }}"
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _populate.yaml
+
+- block:
+ - name: Merge the provided configuration with the exisiting running configuration
+ vyos.vyos.vyos_lldp_global: &merged
+ config:
+ legacy_protocols:
+ - 'fdp'
+ - 'cdp'
+ address: 192.0.2.11
+ 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)
+ vyos.vyos.vyos_lldp_global: *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/vyos_lldp_global/tests/cli/replaced.yaml b/test/integration/targets/vyos_lldp_global/tests/cli/replaced.yaml
new file mode 100644
index 0000000..22bd8e5
--- /dev/null
+++ b/test/integration/targets/vyos_lldp_global/tests/cli/replaced.yaml
@@ -0,0 +1,51 @@
+---
+- debug:
+ msg: "START vyos_lldp_global replaced integration tests on connection={{ ansible_connection }}"
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _populate.yaml
+
+- block:
+ - name: Replace device configurations of LLDP service with provided configurations
+ vyos.vyos.vyos_lldp_global: &replaced
+ config:
+ legacy_protocols:
+ - 'edp'
+ - 'sonmp'
+ - 'cdp'
+ address: 192.0.2.14
+ 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 LLDP service with provided configurarions (IDEMPOTENT)
+ vyos.vyos.vyos_lldp_global: *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/vyos_lldp_global/tests/cli/rtt.yaml b/test/integration/targets/vyos_lldp_global/tests/cli/rtt.yaml
new file mode 100644
index 0000000..4f8ca9c
--- /dev/null
+++ b/test/integration/targets/vyos_lldp_global/tests/cli/rtt.yaml
@@ -0,0 +1,51 @@
+---
+- debug:
+ msg: "START vyos_lldp_global round trip integration tests on connection={{ ansible_connection }}"
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Apply the provided configuration (base config)
+ vyos.vyos.vyos_lldp_global:
+ config:
+ legacy_protocols:
+ - 'fdp'
+ - 'cdp'
+ address: 192.0.2.11
+ state: merged
+ register: base_config
+
+ - name: Gather vyos_lldp_global facts
+ vyos.vyos.vyos_facts:
+ gather_subset:
+ - default
+ gather_network_resources:
+ - lldp_global
+
+ - name: Apply the provided configuration (config to be reverted)
+ vyos.vyos.vyos_lldp_global:
+ config:
+ legacy_protocols:
+ - 'edp'
+ - 'sonmp'
+ - 'cdp'
+ address: 192.0.2.14
+ 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
+ vyos.vyos.vyos_lldp_global:
+ config: "{{ ansible_facts['network_resources']['lldp_global'] }}"
+ 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/vyos_lldp_global/vars/main.yaml b/test/integration/targets/vyos_lldp_global/vars/main.yaml
new file mode 100644
index 0000000..f091f2c
--- /dev/null
+++ b/test/integration/targets/vyos_lldp_global/vars/main.yaml
@@ -0,0 +1,56 @@
+---
+merged:
+ before:
+ address: '192.0.2.17'
+ enable: true
+ legacy_protocols:
+ - 'cdp'
+
+ commands:
+ - "set service lldp management-address '192.0.2.11'"
+ - "set service lldp legacy-protocols 'fdp'"
+
+ after:
+ address: '192.0.2.11'
+ enable: true
+ legacy_protocols:
+ - 'cdp'
+ - 'fdp'
+
+populate:
+ address: '192.0.2.17'
+ enable: true
+ legacy_protocols:
+ - 'cdp'
+
+replaced:
+ commands:
+ - "set service lldp legacy-protocols 'edp'"
+ - "set service lldp legacy-protocols 'sonmp'"
+ - "set service lldp management-address '192.0.2.14'"
+
+ after:
+ address: '192.0.2.14'
+ enable: true
+ legacy_protocols:
+ - 'cdp'
+ - 'edp'
+ - 'sonmp'
+
+deleted:
+ commands:
+ - "delete service lldp management-address"
+ - "delete service lldp legacy-protocols"
+
+ after:
+ "enable": true
+
+round_trip:
+ after:
+ address: '192.0.2.14'
+ enable: true
+ legacy_protocols:
+ - 'cdp'
+ - 'edp'
+ - 'fdp'
+ - 'sonmp'