summaryrefslogtreecommitdiff
path: root/tests/integration/targets
diff options
context:
space:
mode:
authoransible-zuul[bot] <48994755+ansible-zuul[bot]@users.noreply.github.com>2020-05-07 19:53:53 +0000
committerGitHub <noreply@github.com>2020-05-07 19:53:53 +0000
commit07a53b4407c46dc19cdbde092fbf96970bb61306 (patch)
tree46ba4ea2a996e06ae195b7e2d209791759456364 /tests/integration/targets
parent62d621f64c082d889950d48ccf4d1177aa24000a (diff)
parent622294ebf8acee14f4f8f9041cea14f66c13b643 (diff)
downloadvyos-ansible-collection-07a53b4407c46dc19cdbde092fbf96970bb61306.tar.gz
vyos-ansible-collection-07a53b4407c46dc19cdbde092fbf96970bb61306.zip
Merge pull request #25 from rohitthakur2590/interfaces_states_addded
[VyOS] interfaces resource module updated with new states Reviewed-by: https://github.com/apps/ansible-zuul
Diffstat (limited to 'tests/integration/targets')
-rw-r--r--tests/integration/targets/vyos_interfaces/tests/cli/_parsed_config.cfg12
-rw-r--r--tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml27
-rw-r--r--tests/integration/targets/vyos_interfaces/tests/cli/gathered.yaml26
-rw-r--r--tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml16
-rw-r--r--tests/integration/targets/vyos_interfaces/tests/cli/rendered.yaml47
-rw-r--r--tests/integration/targets/vyos_interfaces/vars/main.yaml37
6 files changed, 163 insertions, 2 deletions
diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/_parsed_config.cfg b/tests/integration/targets/vyos_interfaces/tests/cli/_parsed_config.cfg
new file mode 100644
index 0000000..e5c3fc7
--- /dev/null
+++ b/tests/integration/targets/vyos_interfaces/tests/cli/_parsed_config.cfg
@@ -0,0 +1,12 @@
+set interfaces ethernet eth1 description 'Configured by Ansible - Interface 1'
+set interfaces ethernet eth1 duplex 'auto'
+set interfaces ethernet eth1 hw-id '08:00:27:da:67:43'
+set interfaces ethernet eth1 mtu '1500'
+set interfaces ethernet eth1 speed 'auto'
+set interfaces ethernet eth1 vif 100 description 'Eth1 - VIF 100'
+set interfaces ethernet eth1 vif 100 mtu '400'
+set interfaces ethernet eth1 vif 101 description 'Eth1 - VIF 101'
+set interfaces ethernet eth2 description 'Configured by Ansible - Interface 2 (ADMIN DOWN)'
+set interfaces ethernet eth2 'disable'
+set interfaces ethernet eth2 hw-id '08:00:27:d8:70:b0'
+set interfaces ethernet eth2 mtu '600'
diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml
index e1e154d..652f158 100644
--- a/tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml
+++ b/tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml
@@ -1,7 +1,7 @@
---
- debug:
- msg: START vyos_interfaces empty_config integration tests on connection={{ ansible_connection
- }}
+ msg: START vyos_interfaces empty_config integration tests on connection={{
+ ansible_connection }}
- name: Merged with empty config should give appropriate error message
register: result
@@ -35,3 +35,26 @@
- assert:
that:
- result.msg == 'value of config parameter must not be empty for state overridden'
+
+- name: Parsed with empty running_config should give appropriate error message
+ register: result
+ ignore_errors: true
+ vyos.vyos.vyos_interfaces:
+ running_config:
+ state: parsed
+
+- assert:
+ that:
+ - result.msg == 'value of running_config parameter must not be empty for state
+ parsed'
+
+- name: Rendered with empty config should give appropriate error message
+ register: result
+ ignore_errors: true
+ vyos.vyos.vyos_interfaces:
+ config:
+ state: rendered
+
+- assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state rendered'
diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/gathered.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/gathered.yaml
new file mode 100644
index 0000000..ac9892c
--- /dev/null
+++ b/tests/integration/targets/vyos_interfaces/tests/cli/gathered.yaml
@@ -0,0 +1,26 @@
+---
+- debug:
+ msg: START vyos_interfaces gathered integration tests on connection={{ ansible_connection
+ }}
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _populate.yaml
+
+- block:
+
+ - name: Gather the provided configuration with the exisiting running configuration
+ register: result
+ vyos.vyos.vyos_interfaces:
+ config:
+ state: gathered
+
+ - name: Assert that gathered dicts was correctly generated
+ assert:
+ that:
+ - "{{ populate | symmetric_difference(result['gathered']) |length == 0\
+ \ }}"
+
+ always:
+
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml
new file mode 100644
index 0000000..a44fc2f
--- /dev/null
+++ b/tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml
@@ -0,0 +1,16 @@
+---
+- debug:
+ msg: START vyos_interfaces parsed integration tests on connection={{ ansible_connection
+ }}
+
+- name: Parse externally provided interfaces config to agnostic model
+ register: result
+ vyos.vyos.vyos_interfaces:
+ running_config: "{{ lookup('file', '_parsed_config.cfg') }}"
+ state: parsed
+
+- name: Assert that config was correctly parsed
+ assert:
+ that:
+ - "{{ parsed['after'] | symmetric_difference(result['parsed']) |length ==\
+ \ 0 }}"
diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/rendered.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/rendered.yaml
new file mode 100644
index 0000000..5030d71
--- /dev/null
+++ b/tests/integration/targets/vyos_interfaces/tests/cli/rendered.yaml
@@ -0,0 +1,47 @@
+---
+- debug:
+ msg: START vyos_interfaces rendered integration tests on connection={{ ansible_connection
+ }}
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _populate.yaml
+
+- block:
+
+ - name: Structure provided configuration into device specific commands
+ register: result
+ vyos.vyos.vyos_interfaces:
+ config:
+ - name: eth0
+ enabled: true
+ duplex: auto
+ speed: auto
+ - name: eth1
+ description: Configured by Ansible - Interface 1
+ mtu: 1500
+ speed: auto
+ duplex: auto
+ enabled: true
+ vifs:
+ - vlan_id: 100
+ description: Eth1 - VIF 100
+ mtu: 400
+ enabled: true
+ - vlan_id: 101
+ description: Eth1 - VIF 101
+ enabled: true
+ - name: eth2
+ description: Configured by Ansible - Interface 2 (ADMIN DOWN)
+ mtu: 600
+ enabled: false
+ state: rendered
+
+ - name: Assert that correct set of commands were generated
+ assert:
+ that:
+ - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\
+ \ |length == 0 }}"
+ always:
+
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_interfaces/vars/main.yaml b/tests/integration/targets/vyos_interfaces/vars/main.yaml
index b730080..84a8bf0 100644
--- a/tests/integration/targets/vyos_interfaces/vars/main.yaml
+++ b/tests/integration/targets/vyos_interfaces/vars/main.yaml
@@ -104,6 +104,26 @@ replaced:
enabled: true
duplex: auto
speed: auto
+parsed:
+ after:
+ - name: eth1
+ description: Configured by Ansible - Interface 1
+ mtu: 1500
+ speed: auto
+ duplex: auto
+ enabled: true
+ vifs:
+ - vlan_id: 100
+ description: Eth1 - VIF 100
+ mtu: 400
+ enabled: true
+ - vlan_id: 101
+ description: Eth1 - VIF 101
+ enabled: true
+ - name: eth2
+ description: Configured by Ansible - Interface 2 (ADMIN DOWN)
+ mtu: 600
+ enabled: false
overridden:
commands:
- delete interfaces ethernet eth1 description
@@ -133,6 +153,23 @@ overridden:
vifs:
- vlan_id: 200
enabled: true
+rendered:
+ commands:
+ - set interfaces ethernet eth0 duplex 'auto'
+ - set interfaces ethernet eth0 speed 'auto'
+ - delete interfaces ethernet eth0 disable
+ - set interfaces ethernet eth1 duplex 'auto'
+ - delete interfaces ethernet eth1 disable
+ - set interfaces ethernet eth1 speed 'auto'
+ - set interfaces ethernet eth1 description 'Configured by Ansible - Interface 1'
+ - set interfaces ethernet eth1 mtu '1500'
+ - set interfaces ethernet eth1 vif 100 description 'Eth1 - VIF 100'
+ - set interfaces ethernet eth1 vif 100 mtu '400'
+ - set interfaces ethernet eth1 vif 101 description 'Eth1 - VIF 101'
+ - set interfaces ethernet eth2 disable
+ - set interfaces ethernet eth2 description 'Configured by Ansible - Interface 2 (ADMIN DOWN)'
+ - set interfaces ethernet eth2 mtu '600'
+
deleted:
commands:
- delete interfaces ethernet eth1 description