summaryrefslogtreecommitdiff
path: root/test/integration
diff options
context:
space:
mode:
authorCaptTrews <capttrews@gmail.com>2019-08-24 02:26:40 +0000
committerCaptTrews <capttrews@gmail.com>2019-08-24 02:26:40 +0000
commite2a6e043664ef340aa474b0d3ab9d24865d0efdf (patch)
treee4422fabb09a8801a035592b7264efce1bb83f9c /test/integration
parentffd898f5dc0d1233bb05fce342d91e14bffed4b5 (diff)
downloadvyos.vyos-e2a6e043664ef340aa474b0d3ab9d24865d0efdf.tar.gz
vyos.vyos-e2a6e043664ef340aa474b0d3ab9d24865d0efdf.zip
Updated from network content collector
Signed-off-by: CaptTrews <capttrews@gmail.com>
Diffstat (limited to 'test/integration')
-rw-r--r--test/integration/integration_config.yml3
-rw-r--r--test/integration/target-prefixes.network2
-rw-r--r--test/integration/targets/prepare_vyos_tests/tasks/main.yaml2
-rw-r--r--test/integration/targets/vyos_lldp_interfaces/defaults/main.yaml3
-rw-r--r--test/integration/targets/vyos_lldp_interfaces/meta/main.yaml2
-rw-r--r--test/integration/targets/vyos_lldp_interfaces/tasks/cli.yaml19
-rw-r--r--test/integration/targets/vyos_lldp_interfaces/tasks/main.yaml2
-rw-r--r--test/integration/targets/vyos_lldp_interfaces/tests/cli/_populate.yaml14
-rw-r--r--test/integration/targets/vyos_lldp_interfaces/tests/cli/_populate_intf.yaml10
-rw-r--r--test/integration/targets/vyos_lldp_interfaces/tests/cli/_remove_config.yaml8
-rw-r--r--test/integration/targets/vyos_lldp_interfaces/tests/cli/deleted.yaml46
-rw-r--r--test/integration/targets/vyos_lldp_interfaces/tests/cli/merged.yaml58
-rw-r--r--test/integration/targets/vyos_lldp_interfaces/tests/cli/overridden.yaml49
-rw-r--r--test/integration/targets/vyos_lldp_interfaces/tests/cli/replaced.yaml63
-rw-r--r--test/integration/targets/vyos_lldp_interfaces/tests/cli/rtt.yaml57
-rw-r--r--test/integration/targets/vyos_lldp_interfaces/vars/main.yaml130
16 files changed, 464 insertions, 4 deletions
diff --git a/test/integration/integration_config.yml b/test/integration/integration_config.yml
deleted file mode 100644
index 6b47a35..0000000
--- a/test/integration/integration_config.yml
+++ /dev/null
@@ -1,3 +0,0 @@
----
-win_output_dir: 'C:\ansible_testing'
-output_dir: ~/ansible_testing
diff --git a/test/integration/target-prefixes.network b/test/integration/target-prefixes.network
index 2d0f40c..0c45eba 100644
--- a/test/integration/target-prefixes.network
+++ b/test/integration/target-prefixes.network
@@ -1 +1 @@
-vyos
+vyos \ No newline at end of file
diff --git a/test/integration/targets/prepare_vyos_tests/tasks/main.yaml b/test/integration/targets/prepare_vyos_tests/tasks/main.yaml
index a156ea4..1a81fb1 100644
--- a/test/integration/targets/prepare_vyos_tests/tasks/main.yaml
+++ b/test/integration/targets/prepare_vyos_tests/tasks/main.yaml
@@ -5,6 +5,8 @@
vars:
lines: |
set interfaces ethernet eth0 address dhcp
+ set interfaces ethernet eth0 speed auto
+ set interfaces ethernet eth0 duplex auto
set interfaces ethernet eth1
set interfaces ethernet eth2
delete interfaces loopback lo
diff --git a/test/integration/targets/vyos_lldp_interfaces/defaults/main.yaml b/test/integration/targets/vyos_lldp_interfaces/defaults/main.yaml
new file mode 100644
index 0000000..164afea
--- /dev/null
+++ b/test/integration/targets/vyos_lldp_interfaces/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/test/integration/targets/vyos_lldp_interfaces/meta/main.yaml b/test/integration/targets/vyos_lldp_interfaces/meta/main.yaml
new file mode 100644
index 0000000..f88bce5
--- /dev/null
+++ b/test/integration/targets/vyos_lldp_interfaces/meta/main.yaml
@@ -0,0 +1,2 @@
+dependencies:
+ - prepare_vyos_tests
diff --git a/test/integration/targets/vyos_lldp_interfaces/tasks/cli.yaml b/test/integration/targets/vyos_lldp_interfaces/tasks/cli.yaml
new file mode 100644
index 0000000..655e51e
--- /dev/null
+++ b/test/integration/targets/vyos_lldp_interfaces/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_interfaces/tasks/main.yaml b/test/integration/targets/vyos_lldp_interfaces/tasks/main.yaml
new file mode 100644
index 0000000..415c99d
--- /dev/null
+++ b/test/integration/targets/vyos_lldp_interfaces/tasks/main.yaml
@@ -0,0 +1,2 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
diff --git a/test/integration/targets/vyos_lldp_interfaces/tests/cli/_populate.yaml b/test/integration/targets/vyos_lldp_interfaces/tests/cli/_populate.yaml
new file mode 100644
index 0000000..80f7d1a
--- /dev/null
+++ b/test/integration/targets/vyos_lldp_interfaces/tests/cli/_populate.yaml
@@ -0,0 +1,14 @@
+---
+- name: Setup
+ network.cli.cli_config:
+ config: "{{ lines }}"
+ vars:
+ lines: |
+ set service lldp interface eth1
+ set service lldp interface eth1 location civic-based country-code US
+ set service lldp interface eth1 location civic-based ca-type 0 ca-value ENGLISH
+ set service lldp interface eth2
+ set service lldp interface eth2 location coordinate-based latitude 33.524449N
+ set service lldp interface eth2 location coordinate-based altitude 2200
+ set service lldp interface eth2 location coordinate-based datum WGS84
+ set service lldp interface eth2 location coordinate-based longitude 222.267255W
diff --git a/test/integration/targets/vyos_lldp_interfaces/tests/cli/_populate_intf.yaml b/test/integration/targets/vyos_lldp_interfaces/tests/cli/_populate_intf.yaml
new file mode 100644
index 0000000..ee9a9bd
--- /dev/null
+++ b/test/integration/targets/vyos_lldp_interfaces/tests/cli/_populate_intf.yaml
@@ -0,0 +1,10 @@
+---
+- name: Setup
+ network.cli.cli_config:
+ config: "{{ lines }}"
+ vars:
+ lines: |
+ set service lldp interface eth2
+ set service lldp interface eth2 location civic-based country-code US
+ set service lldp interface eth2 location civic-based ca-type 0 ca-value ENGLISH
+ set service lldp interface eth2 disable
diff --git a/test/integration/targets/vyos_lldp_interfaces/tests/cli/_remove_config.yaml b/test/integration/targets/vyos_lldp_interfaces/tests/cli/_remove_config.yaml
new file mode 100644
index 0000000..e3abbdb
--- /dev/null
+++ b/test/integration/targets/vyos_lldp_interfaces/tests/cli/_remove_config.yaml
@@ -0,0 +1,8 @@
+---
+- name: Remove Config
+ network.cli.cli_config:
+ config: "{{ lines }}"
+ vars:
+ lines: |
+ delete service lldp interface
+ delete service lldp
diff --git a/test/integration/targets/vyos_lldp_interfaces/tests/cli/deleted.yaml b/test/integration/targets/vyos_lldp_interfaces/tests/cli/deleted.yaml
new file mode 100644
index 0000000..bd7c713
--- /dev/null
+++ b/test/integration/targets/vyos_lldp_interfaces/tests/cli/deleted.yaml
@@ -0,0 +1,46 @@
+---
+- debug:
+ msg: "Start vyos_lldp_interfaces deleted integration tests ansible_connection={{ ansible_connection }}"
+
+- include_tasks: _populate.yaml
+
+- block:
+ - name: Delete attributes of given LLDP interfaces.
+ vyos.vyos.vyos_lldp_interfaces: &deleted
+ config:
+ - name: 'eth1'
+ - name: 'eth2'
+ state: deleted
+ register: result
+
+ - name: Assert that the before dicts were correctly generated
+ assert:
+ that:
+ - "{{ populate | symmetric_difference(result['before']) |length == 0 }}"
+
+ - 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'] | symmetric_difference(result['after']) |length == 0 }}"
+
+ - name: Delete attributes of given interfaces (IDEMPOTENT)
+ vyos.vyos.vyos_lldp_interfaces: *deleted
+ register: result
+
+ - name: Assert that the previous task was idempotent
+ assert:
+ that:
+ - "result.changed == false"
+ - "result.commands|length == 0"
+
+ - name: Assert that the before dicts were correctly generated
+ assert:
+ that:
+ - "{{ deleted['after'] | symmetric_difference(result['before']) |length == 0 }}"
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/test/integration/targets/vyos_lldp_interfaces/tests/cli/merged.yaml b/test/integration/targets/vyos_lldp_interfaces/tests/cli/merged.yaml
new file mode 100644
index 0000000..ae5b10b
--- /dev/null
+++ b/test/integration/targets/vyos_lldp_interfaces/tests/cli/merged.yaml
@@ -0,0 +1,58 @@
+---
+- debug:
+ msg: "START vyos_lldp_interfaces merged integration tests on connection={{ ansible_connection }}"
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Merge the provided configuration with the exisiting running configuration
+ vyos.vyos.vyos_lldp_interfaces: &merged
+ config:
+ - name: 'eth1'
+ location:
+ civic_based:
+ country_code: 'US'
+ ca_info:
+ - ca_type: 0
+ ca_value: 'ENGLISH'
+
+ - name: 'eth2'
+ location:
+ coordinate_based:
+ altitude: 2200
+ datum: 'WGS84'
+ longitude: '222.267255W'
+ latitude: '33.524449N'
+ state: merged
+ register: result
+
+ - name: Assert that before dicts were correctly generated
+ assert:
+ that: "{{ merged['before'] | symmetric_difference(result['before']) |length == 0 }}"
+
+ - 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'] | symmetric_difference(result['after']) |length == 0 }}"
+
+ - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT)
+ vyos.vyos.vyos_lldp_interfaces: *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'] | symmetric_difference(result['before']) |length == 0 }}"
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/test/integration/targets/vyos_lldp_interfaces/tests/cli/overridden.yaml b/test/integration/targets/vyos_lldp_interfaces/tests/cli/overridden.yaml
new file mode 100644
index 0000000..eedb563
--- /dev/null
+++ b/test/integration/targets/vyos_lldp_interfaces/tests/cli/overridden.yaml
@@ -0,0 +1,49 @@
+---
+- debug:
+ msg: "START vyos_lldp_interfaces overridden integration tests on connection={{ ansible_connection }}"
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _populate_intf.yaml
+
+- block:
+ - name: Overrides all device configuration with provided configuration
+ vyos.vyos.vyos_lldp_interfaces: &overridden
+ config:
+ - name: 'eth2'
+ location:
+ elin: '0000000911'
+ state: overridden
+ register: result
+
+ - name: Assert that before dicts were correctly generated
+ assert:
+ that:
+ - "{{ populate_intf | symmetric_difference(result['before']) |length == 0 }}"
+
+ - name: Assert that correct commands were generated
+ assert:
+ that:
+ - "{{ overridden['commands'] | symmetric_difference(result['commands']) |length == 0 }}"
+
+ - name: Assert that after dicts were correctly generated
+ assert:
+ that:
+ - "{{ overridden['after'] | symmetric_difference(result['after']) |length == 0 }}"
+
+ - name: Overrides all device configuration with provided configurations (IDEMPOTENT)
+ vyos.vyos.vyos_lldp_interfaces: *overridden
+ 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:
+ - "{{ overridden['after'] | symmetric_difference(result['before']) |length == 0 }}"
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/test/integration/targets/vyos_lldp_interfaces/tests/cli/replaced.yaml b/test/integration/targets/vyos_lldp_interfaces/tests/cli/replaced.yaml
new file mode 100644
index 0000000..07fec9e
--- /dev/null
+++ b/test/integration/targets/vyos_lldp_interfaces/tests/cli/replaced.yaml
@@ -0,0 +1,63 @@
+---
+- debug:
+ msg: "START vyos_lldp_interfaces replaced integration tests on connection={{ ansible_connection }}"
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _populate.yaml
+
+- block:
+ - name: Replace device configurations of listed LLDP interfaces with provided configurations
+ vyos.vyos.vyos_lldp_interfaces: &replaced
+ config:
+ - name: 'eth2'
+ enable: false
+ location:
+ civic_based:
+ country_code: 'US'
+ ca_info:
+ - ca_type: 0
+ ca_value: 'ENGLISH'
+
+ - name: 'eth1'
+ enable: false
+ location:
+ coordinate_based:
+ altitude: 2200
+ datum: 'WGS84'
+ longitude: '222.267255W'
+ latitude: '33.524449N'
+ 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 | 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: Replace device configurations of listed LLDP interfaces with provided configurarions (IDEMPOTENT)
+ vyos.vyos.vyos_lldp_interfaces: *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'] | symmetric_difference(result['before']) |length == 0 }}"
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/test/integration/targets/vyos_lldp_interfaces/tests/cli/rtt.yaml b/test/integration/targets/vyos_lldp_interfaces/tests/cli/rtt.yaml
new file mode 100644
index 0000000..d97cf9c
--- /dev/null
+++ b/test/integration/targets/vyos_lldp_interfaces/tests/cli/rtt.yaml
@@ -0,0 +1,57 @@
+---
+- debug:
+ msg: "START vyos_lldp_interfaces 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_interfaces:
+ config:
+ - name: 'eth1'
+ location:
+ civic_based:
+ country_code: 'US'
+ ca_info:
+ - ca_type: 0
+ ca_value: 'ENGLISH'
+
+ state: merged
+ register: base_config
+
+ - name: Gather lldp_interfaces facts
+ vyos.vyos.vyos_facts:
+ gather_subset:
+ - default
+ gather_network_resources:
+ - lldp_interfaces
+
+ - name: Apply the provided configuration (config to be reverted)
+ vyos.vyos.vyos_lldp_interfaces:
+ config:
+ - name: 'eth2'
+ location:
+ coordinate_based:
+ altitude: 2200
+ datum: 'WGS84'
+ longitude: '222.267255W'
+ latitude: '33.524449N'
+ state: merged
+ register: result
+
+ - name: Assert that changes were applied
+ assert:
+ that: "{{ round_trip['after'] | symmetric_difference(result['after']) |length == 0 }}"
+
+ - name: Revert back to base config using facts round trip
+ vyos.vyos.vyos_lldp_interfaces:
+ config: "{{ ansible_facts['network_resources']['lldp_interfaces'] }}"
+ state: overridden
+ register: revert
+
+ - name: Assert that config was reverted
+ assert:
+ that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length == 0 }}"
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/test/integration/targets/vyos_lldp_interfaces/vars/main.yaml b/test/integration/targets/vyos_lldp_interfaces/vars/main.yaml
new file mode 100644
index 0000000..6f33343
--- /dev/null
+++ b/test/integration/targets/vyos_lldp_interfaces/vars/main.yaml
@@ -0,0 +1,130 @@
+---
+merged:
+ before: []
+
+
+ commands:
+ - "set service lldp interface eth1 location civic-based country-code 'US'"
+ - "set service lldp interface eth1 location civic-based ca-type 0 ca-value 'ENGLISH'"
+ - "set service lldp interface eth1"
+ - "set service lldp interface eth2 location coordinate-based latitude '33.524449N'"
+ - "set service lldp interface eth2 location coordinate-based altitude '2200'"
+ - "set service lldp interface eth2 location coordinate-based datum 'WGS84'"
+ - "set service lldp interface eth2 location coordinate-based longitude '222.267255W'"
+ - "set service lldp interface eth2 location coordinate-based latitude '33.524449N'"
+ - "set service lldp interface eth2 location coordinate-based altitude '2200'"
+ - "set service lldp interface eth2 location coordinate-based datum 'WGS84'"
+ - "set service lldp interface eth2 location coordinate-based longitude '222.267255W'"
+ - "set service lldp interface eth2"
+
+ after:
+ - name: 'eth1'
+ location:
+ civic_based:
+ country_code: 'US'
+ ca_info:
+ - ca_type: 0
+ ca_value: 'ENGLISH'
+
+ - name: 'eth2'
+ location:
+ coordinate_based:
+ altitude: 2200
+ datum: 'WGS84'
+ longitude: '222.267255W'
+ latitude: '33.524449N'
+
+populate:
+ - name: 'eth1'
+ location:
+ civic_based:
+ country_code: 'US'
+ ca_info:
+ - ca_type: 0
+ ca_value: 'ENGLISH'
+
+ - name: 'eth2'
+ location:
+ coordinate_based:
+ altitude: 2200
+ datum: 'WGS84'
+ longitude: '222.267255W'
+ latitude: '33.524449N'
+
+replaced:
+ commands:
+ - "delete service lldp interface eth2 location"
+ - "set service lldp interface eth2 'disable'"
+ - "set service lldp interface eth2 location civic-based country-code 'US'"
+ - "set service lldp interface eth2 location civic-based ca-type 0 ca-value 'ENGLISH'"
+ - "delete service lldp interface eth1 location"
+ - "set service lldp interface eth1 'disable'"
+ - "set service lldp interface eth1 location coordinate-based latitude '33.524449N'"
+ - "set service lldp interface eth1 location coordinate-based altitude '2200'"
+ - "set service lldp interface eth1 location coordinate-based datum 'WGS84'"
+ - "set service lldp interface eth1 location coordinate-based longitude '222.267255W'"
+
+ after:
+ - name: 'eth2'
+ enable: false
+ location:
+ civic_based:
+ country_code: 'US'
+ ca_info:
+ - ca_type: 0
+ ca_value: 'ENGLISH'
+
+ - name: 'eth1'
+ enable: false
+ location:
+ coordinate_based:
+ altitude: 2200
+ datum: 'WGS84'
+ longitude: '222.267255W'
+ latitude: '33.524449N'
+
+populate_intf:
+ - name: 'eth2'
+ enable: false
+ location:
+ civic_based:
+ country_code: 'US'
+ ca_info:
+ - ca_type: 0
+ ca_value: 'ENGLISH'
+
+overridden:
+ commands:
+ - "delete service lldp interface eth2 location"
+ - "delete service lldp interface eth2 'disable'"
+ - "set service lldp interface eth2 location elin '0000000911'"
+
+ after:
+ - name: 'eth2'
+ location:
+ elin: 0000000911
+
+deleted:
+ commands:
+ - "delete service lldp interface eth1"
+ - "delete service lldp interface eth2"
+
+ after: []
+
+round_trip:
+ after:
+ - name: 'eth1'
+ location:
+ civic_based:
+ country_code: 'US'
+ ca_info:
+ - ca_type: 0
+ ca_value: 'ENGLISH'
+
+ - name: 'eth2'
+ location:
+ coordinate_based:
+ altitude: 2200
+ datum: 'WGS84'
+ longitude: '222.267255W'
+ latitude: '33.524449N'