summaryrefslogtreecommitdiff
path: root/tests/integration
diff options
context:
space:
mode:
authoransible-zuul[bot] <48994755+ansible-zuul[bot]@users.noreply.github.com>2020-05-08 22:13:30 +0000
committerGitHub <noreply@github.com>2020-05-08 22:13:30 +0000
commit6291969bf7dfdbb655cde97124bd6071af2460fa (patch)
treeac772ec9185ca191737dfea451166465a55fc8c9 /tests/integration
parent790f63be8a22e6f95eddc2c23bf7a0945f48f2bb (diff)
parent0f07011f4ea59bf693110140fda37a07e4167128 (diff)
downloadvyos-ansible-old-6291969bf7dfdbb655cde97124bd6071af2460fa.tar.gz
vyos-ansible-old-6291969bf7dfdbb655cde97124bd6071af2460fa.zip
Merge pull request #26 from rohitthakur2590/l3_interfaces_states_added
[VyOS] L3 interfaces resource module updated with new states Reviewed-by: https://github.com/apps/ansible-zuul
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/tests/cli/_parsed_config.cfg9
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/tests/cli/empty_config.yaml23
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/tests/cli/gathered.yaml34
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/tests/cli/parsed.yaml16
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/tests/cli/rendered.yaml44
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/vars/main.yaml24
6 files changed, 150 insertions, 0 deletions
diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/_parsed_config.cfg b/tests/integration/targets/vyos_l3_interfaces/tests/cli/_parsed_config.cfg
new file mode 100644
index 0000000..ef070a7
--- /dev/null
+++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/_parsed_config.cfg
@@ -0,0 +1,9 @@
+set interfaces ethernet eth1 address '192.0.2.10/24'
+set interfaces ethernet eth1 address '2001:db8::10/32'
+set interfaces ethernet eth1 hw-id '08:00:27:da:67:43'
+set interfaces ethernet eth2 address '198.51.100.10/24'
+set interfaces ethernet eth2 hw-id '08:00:27:d8:70:b0'
+set interfaces ethernet eth2 vif 101 address '198.51.100.130/25'
+set interfaces ethernet eth2 vif 101 address '2001:db8::20/32'
+
+
diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/empty_config.yaml
index 96d4cda..9929dd7 100644
--- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/empty_config.yaml
+++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/empty_config.yaml
@@ -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_l3_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_l3_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_l3_interfaces/tests/cli/gathered.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/gathered.yaml
new file mode 100644
index 0000000..625047b
--- /dev/null
+++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/gathered.yaml
@@ -0,0 +1,34 @@
+---
+- debug:
+ msg: START vyos_l3_interfaces gathered 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
+ register: result
+ vyos.vyos.vyos_l3_interfaces: &id001
+ config:
+ state: gathered
+
+ - name: Assert that gathered dicts was correctly generated
+ assert:
+ that:
+ - "{{ populate | symmetric_difference(result['gathered']) |length == 0\
+ \ }}"
+
+ - name: Gather the existing running configuration (IDEMPOTENT)
+ register: result
+ vyos.vyos.vyos_l3_interfaces: *id001
+
+ - name: Assert that the previous task was idempotent
+ assert:
+ that:
+ - result['changed'] == false
+ always:
+
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/parsed.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/parsed.yaml
new file mode 100644
index 0000000..d5ff205
--- /dev/null
+++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/parsed.yaml
@@ -0,0 +1,16 @@
+---
+- debug:
+ msg: START vyos_l3_nterfaces parsed integration tests on connection={{ ansible_connection
+ }}
+
+- name: Parse externally provided interfaces config to agnostic model
+ register: result
+ vyos.vyos.vyos_l3_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_l3_interfaces/tests/cli/rendered.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/rendered.yaml
new file mode 100644
index 0000000..02a2865
--- /dev/null
+++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/rendered.yaml
@@ -0,0 +1,44 @@
+---
+- debug:
+ msg: START vyos_l3_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_l3_interfaces: &id001
+ config:
+ - name: eth1
+ ipv4:
+ - address: 192.0.2.14/24
+ - name: eth2
+ ipv4:
+ - address: 192.0.2.10/24
+ - address: 192.0.2.11/24
+ ipv6:
+ - address: 2001:db8::10/32
+ - address: 2001:db8::12/32
+ state: rendered
+
+ - name: Assert that correct set of commands were generated
+ assert:
+ that:
+ - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\
+ \ |length == 0 }}"
+
+ - name: Structure provided configuration into device specific commands (IDEMPOTENT)
+ register: result
+ vyos.vyos.vyos_l3_interfaces: *id001
+
+ - name: Assert that the previous task was idempotent
+ assert:
+ that:
+ - result['changed'] == false
+ always:
+
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_l3_interfaces/vars/main.yaml b/tests/integration/targets/vyos_l3_interfaces/vars/main.yaml
index ee329d3..e9781e6 100644
--- a/tests/integration/targets/vyos_l3_interfaces/vars/main.yaml
+++ b/tests/integration/targets/vyos_l3_interfaces/vars/main.yaml
@@ -79,6 +79,30 @@ overridden:
ipv4:
- address: 192.0.2.15/24
- name: eth2
+parsed:
+ after:
+ - name: eth1
+ ipv4:
+ - address: 192.0.2.10/24
+ ipv6:
+ - address: 2001:db8::10/32
+ - name: eth2
+ ipv4:
+ - address: 198.51.100.10/24
+ vifs:
+ - vlan_id: 101
+ ipv4:
+ - address: 198.51.100.130/25
+ ipv6:
+ - address: 2001:db8::20/32
+rendered:
+ commands:
+ - set interfaces ethernet eth1 address '192.0.2.14/24'
+ - set interfaces ethernet eth2 address '192.0.2.11/24'
+ - set interfaces ethernet eth2 address '192.0.2.10/24'
+ - set interfaces ethernet eth2 address '2001:db8::10/32'
+ - set interfaces ethernet eth2 address '2001:db8::12/32'
+
deleted:
commands:
- delete interfaces ethernet eth1 address '192.0.2.14/24'