summaryrefslogtreecommitdiff
path: root/tests/integration/targets/vyos_static_routes
diff options
context:
space:
mode:
authoransible-zuul[bot] <48994755+ansible-zuul[bot]@users.noreply.github.com>2020-02-19 21:10:08 +0000
committerGitHub <noreply@github.com>2020-02-19 21:10:08 +0000
commitc390b91be90c6fec33a1d4d3ed37d9c55f4328b2 (patch)
treec5ff33aa0e4770a13340a52b1e2bda7531541a5f /tests/integration/targets/vyos_static_routes
parentf63b5c97edbf598f7b2a4c044386de3dddfda100 (diff)
parent45f223636c73ba69d3fea3c8aab8edd41de01388 (diff)
downloadvyos.vyos-c390b91be90c6fec33a1d4d3ed37d9c55f4328b2.tar.gz
vyos.vyos-c390b91be90c6fec33a1d4d3ed37d9c55f4328b2.zip
Merge pull request #2 from CaptTrews/master
Updated from network content collector Reviewed-by: https://github.com/apps/ansible-zuul
Diffstat (limited to 'tests/integration/targets/vyos_static_routes')
-rw-r--r--tests/integration/targets/vyos_static_routes/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_static_routes/meta/main.yaml2
-rw-r--r--tests/integration/targets/vyos_static_routes/tasks/cli.yaml19
-rw-r--r--tests/integration/targets/vyos_static_routes/tasks/main.yaml4
-rw-r--r--tests/integration/targets/vyos_static_routes/tests/cli/_parsed_config.cfg6
-rw-r--r--tests/integration/targets/vyos_static_routes/tests/cli/_populate.yaml12
-rw-r--r--tests/integration/targets/vyos_static_routes/tests/cli/_remove_config.yaml6
-rw-r--r--tests/integration/targets/vyos_static_routes/tests/cli/deleted.yaml62
-rw-r--r--tests/integration/targets/vyos_static_routes/tests/cli/deleted_afi.yaml56
-rw-r--r--tests/integration/targets/vyos_static_routes/tests/cli/deleted_all.yaml50
-rw-r--r--tests/integration/targets/vyos_static_routes/tests/cli/deleted_nh.yaml68
-rw-r--r--tests/integration/targets/vyos_static_routes/tests/cli/empty_config.yaml60
-rw-r--r--tests/integration/targets/vyos_static_routes/tests/cli/gathered.yaml34
-rw-r--r--tests/integration/targets/vyos_static_routes/tests/cli/merged.yaml78
-rw-r--r--tests/integration/targets/vyos_static_routes/tests/cli/overridden.yaml61
-rw-r--r--tests/integration/targets/vyos_static_routes/tests/cli/parsed.yaml41
-rw-r--r--tests/integration/targets/vyos_static_routes/tests/cli/rendered.yaml62
-rw-r--r--tests/integration/targets/vyos_static_routes/tests/cli/replaced.yaml69
-rw-r--r--tests/integration/targets/vyos_static_routes/tests/cli/rtt.yaml90
-rw-r--r--tests/integration/targets/vyos_static_routes/vars/main.yaml147
20 files changed, 930 insertions, 0 deletions
diff --git a/tests/integration/targets/vyos_static_routes/defaults/main.yaml b/tests/integration/targets/vyos_static_routes/defaults/main.yaml
new file mode 100644
index 0000000..852a6be
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: '[^_].*'
+test_items: []
diff --git a/tests/integration/targets/vyos_static_routes/meta/main.yaml b/tests/integration/targets/vyos_static_routes/meta/main.yaml
new file mode 100644
index 0000000..91da2a7
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/meta/main.yaml
@@ -0,0 +1,2 @@
+---
+...
diff --git a/tests/integration/targets/vyos_static_routes/tasks/cli.yaml b/tests/integration/targets/vyos_static_routes/tasks/cli.yaml
new file mode 100644
index 0000000..93eb2fe
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/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=ansible.netcommon.network_cli)
+ include: '{{ test_case_to_run }}'
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: '{{ test_items }}'
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_static_routes/tasks/main.yaml b/tests/integration/targets/vyos_static_routes/tasks/main.yaml
new file mode 100644
index 0000000..a3db933
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/tasks/main.yaml
@@ -0,0 +1,4 @@
+---
+- include: cli.yaml
+ tags:
+ - cli
diff --git a/tests/integration/targets/vyos_static_routes/tests/cli/_parsed_config.cfg b/tests/integration/targets/vyos_static_routes/tests/cli/_parsed_config.cfg
new file mode 100644
index 0000000..b2ecd4e
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/tests/cli/_parsed_config.cfg
@@ -0,0 +1,6 @@
+set protocols static route 192.0.2.32/28 next-hop '192.0.2.9'
+set protocols static route 192.0.2.32/28 next-hop '192.0.2.10'
+set protocols static route 192.0.2.32/28 blackhole
+set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1'
+set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2'
+set protocols static route6 2001:db8:1000::/36 blackhole distance '2'
diff --git a/tests/integration/targets/vyos_static_routes/tests/cli/_populate.yaml b/tests/integration/targets/vyos_static_routes/tests/cli/_populate.yaml
new file mode 100644
index 0000000..f292e5d
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/tests/cli/_populate.yaml
@@ -0,0 +1,12 @@
+---
+- name: Setup
+ vars:
+ lines: "set protocols static route 192.0.2.32/28 next-hop '192.0.2.10'\nset\
+ \ protocols static route 192.0.2.32/28 next-hop '192.0.2.9'\nset protocols\
+ \ static route 192.0.2.32/28 blackhole\nset protocols static route 192.0.2.32/28\n\
+ set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1'\n\
+ set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2'\n\
+ set protocols static route6 2001:db8:1000::/36 blackhole distance '2'\nset\
+ \ protocols static route6 2001:db8:1000::/36\n"
+ ansible.netcommon.cli_config:
+ config: '{{ lines }}'
diff --git a/tests/integration/targets/vyos_static_routes/tests/cli/_remove_config.yaml b/tests/integration/targets/vyos_static_routes/tests/cli/_remove_config.yaml
new file mode 100644
index 0000000..5a5cccb
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/tests/cli/_remove_config.yaml
@@ -0,0 +1,6 @@
+---
+- name: Remove Config
+ vars:
+ lines: "delete protocols static route\ndelete protocols static route6\n"
+ ansible.netcommon.cli_config:
+ config: '{{ lines }}'
diff --git a/tests/integration/targets/vyos_static_routes/tests/cli/deleted.yaml b/tests/integration/targets/vyos_static_routes/tests/cli/deleted.yaml
new file mode 100644
index 0000000..7f098f5
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/tests/cli/deleted.yaml
@@ -0,0 +1,62 @@
+---
+- debug:
+ msg: Start vyos_static_routes deleted integration tests ansible_connection={{
+ ansible_connection }}
+
+- include_tasks: _populate.yaml
+
+- block:
+
+ - name: Delete static route based on destiation.
+ register: result
+ vyos.vyos.vyos_static_routes: &id001
+ config:
+
+ - address_families:
+
+ - afi: ipv4
+ routes:
+
+ - dest: 192.0.2.32/28
+
+ - afi: ipv6
+ routes:
+
+ - dest: 2001:db8:1000::/36
+ state: deleted
+
+ - 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_dest['commands'] | symmetric_difference(result['commands'])\
+ \ |length == 0 }}"
+
+ - name: Assert that the after dicts were correctly generated
+ assert:
+ that:
+ - "{{ deleted_dest['after'] | symmetric_difference(result['after']) |length\
+ \ == 0 }}"
+
+ - name: Delete attributes of given interfaces (IDEMPOTENT)
+ register: result
+ vyos.vyos.vyos_static_routes: *id001
+
+ - 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_dest['after'] | symmetric_difference(result['before']) |length\
+ \ == 0 }}"
+ always:
+
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_static_routes/tests/cli/deleted_afi.yaml b/tests/integration/targets/vyos_static_routes/tests/cli/deleted_afi.yaml
new file mode 100644
index 0000000..221f1b5
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/tests/cli/deleted_afi.yaml
@@ -0,0 +1,56 @@
+---
+- debug:
+ msg: Start vyos_static_routes deleted integration tests ansible_connection={{
+ ansible_connection }}
+
+- include_tasks: _populate.yaml
+
+- block:
+
+ - name: Delete static route based on afi.
+ register: result
+ vyos.vyos.vyos_static_routes: &id001
+ config:
+
+ - address_families:
+
+ - afi: ipv4
+
+ - afi: ipv6
+ state: deleted
+
+ - 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_afi_all['commands'] | symmetric_difference(result['commands'])\
+ \ |length == 0 }}"
+
+ - name: Assert that the after dicts were correctly generated
+ assert:
+ that:
+ - "{{ deleted_afi_all['after'] | symmetric_difference(result['after'])\
+ \ |length == 0 }}"
+
+ - name: Delete attributes of given interfaces (IDEMPOTENT)
+ register: result
+ vyos.vyos.vyos_static_routes: *id001
+
+ - 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_afi_all['after'] | symmetric_difference(result['before'])\
+ \ |length == 0 }}"
+ always:
+
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_static_routes/tests/cli/deleted_all.yaml b/tests/integration/targets/vyos_static_routes/tests/cli/deleted_all.yaml
new file mode 100644
index 0000000..e10f1bc
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/tests/cli/deleted_all.yaml
@@ -0,0 +1,50 @@
+---
+- debug:
+ msg: Start vyos_static_routes deleted integration tests ansible_connection={{
+ ansible_connection }}
+
+- include_tasks: _populate.yaml
+
+- block:
+
+ - name: Delete all the static routes.
+ register: result
+ vyos.vyos.vyos_static_routes: &id001
+ config:
+ state: deleted
+
+ - 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_afi_all['commands'] | symmetric_difference(result['commands'])\
+ \ |length == 0 }}"
+
+ - name: Assert that the after dicts were correctly generated
+ assert:
+ that:
+ - "{{ deleted_afi_all['after'] | symmetric_difference(result['after'])\
+ \ |length == 0 }}"
+
+ - name: Delete attributes of given interfaces (IDEMPOTENT)
+ register: result
+ vyos.vyos.vyos_static_routes: *id001
+
+ - 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_afi_all['after'] | symmetric_difference(result['before'])\
+ \ |length == 0 }}"
+ always:
+
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_static_routes/tests/cli/deleted_nh.yaml b/tests/integration/targets/vyos_static_routes/tests/cli/deleted_nh.yaml
new file mode 100644
index 0000000..f6075d2
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/tests/cli/deleted_nh.yaml
@@ -0,0 +1,68 @@
+---
+- debug:
+ msg: Start vyos_static_routes deleted integration tests ansible_connection={{
+ ansible_connection }}
+
+- include_tasks: _populate.yaml
+
+- block:
+
+ - name: Delete static route based on next_hop.
+ register: result
+ vyos.vyos.vyos_static_routes: &id001
+ config:
+
+ - address_families:
+
+ - afi: ipv4
+ routes:
+
+ - dest: 192.0.2.32/28
+ next_hops:
+
+ - forward_router_address: 192.0.2.9
+
+ - afi: ipv6
+ routes:
+
+ - dest: 2001:db8:1000::/36
+ next_hops:
+
+ - forward_router_address: 2001:db8:2000:2::1
+ state: deleted
+
+ - 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_nh['commands'] | symmetric_difference(result['commands'])\
+ \ |length == 0 }}"
+
+ - name: Assert that the after dicts were correctly generated
+ assert:
+ that:
+ - "{{ deleted_nh['after'] | symmetric_difference(result['after']) |length\
+ \ == 0 }}"
+
+ - name: Delete attributes of given interfaces (IDEMPOTENT)
+ register: result
+ vyos.vyos.vyos_static_routes: *id001
+
+ - 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_nh['after'] | symmetric_difference(result['before']) |length\
+ \ == 0 }}"
+ always:
+
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_static_routes/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_static_routes/tests/cli/empty_config.yaml
new file mode 100644
index 0000000..f58ef39
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/tests/cli/empty_config.yaml
@@ -0,0 +1,60 @@
+---
+- debug:
+ msg: START vyos_static_routes empty_config integration tests on connection={{
+ ansible_connection }}
+
+- name: Merged with empty config should give appropriate error message
+ register: result
+ ignore_errors: true
+ vyos.vyos.vyos_static_routes:
+ config:
+ state: merged
+
+- assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state merged'
+
+- name: Replaced with empty config should give appropriate error message
+ register: result
+ ignore_errors: true
+ vyos.vyos.vyos_static_routes:
+ config:
+ state: replaced
+
+- assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state replaced'
+
+- name: Overridden with empty config should give appropriate error message
+ register: result
+ ignore_errors: true
+ vyos.vyos.vyos_static_routes:
+ config:
+ state: overridden
+
+- 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_static_routes:
+ 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_static_routes:
+ 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_static_routes/tests/cli/gathered.yaml b/tests/integration/targets/vyos_static_routes/tests/cli/gathered.yaml
new file mode 100644
index 0000000..d3b84d1
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/tests/cli/gathered.yaml
@@ -0,0 +1,34 @@
+---
+- debug:
+ msg: START vyos_static_routes 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_static_routes: &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_static_routes: *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_static_routes/tests/cli/merged.yaml b/tests/integration/targets/vyos_static_routes/tests/cli/merged.yaml
new file mode 100644
index 0000000..999ae86
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/tests/cli/merged.yaml
@@ -0,0 +1,78 @@
+---
+- debug:
+ msg: START vyos_static_routes merged integration tests on connection={{ ansible_connection
+ }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+
+ - name: Merge the provided configuration with the exisiting running configuration
+ register: result
+ vyos.vyos.vyos_static_routes: &id001
+ config:
+
+ - address_families:
+
+ - afi: ipv4
+ routes:
+
+ - dest: 192.0.2.32/28
+ blackhole_config:
+ type: blackhole
+ next_hops:
+
+ - forward_router_address: 192.0.2.10
+
+ - forward_router_address: 192.0.2.9
+
+ - address_families:
+
+ - afi: ipv6
+ routes:
+
+ - dest: 2001:db8:1000::/36
+ blackhole_config:
+ distance: 2
+ next_hops:
+
+ - forward_router_address: 2001:db8:2000:2::1
+
+ - forward_router_address: 2001:db8:2000:2::2
+ state: merged
+
+ - 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)
+ register: result
+ vyos.vyos.vyos_static_routes: *id001
+
+ - 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/tests/integration/targets/vyos_static_routes/tests/cli/overridden.yaml b/tests/integration/targets/vyos_static_routes/tests/cli/overridden.yaml
new file mode 100644
index 0000000..a9112a5
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/tests/cli/overridden.yaml
@@ -0,0 +1,61 @@
+---
+- debug:
+ msg: START vyos_static_routes overridden integration tests on connection={{
+ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _populate.yaml
+
+- block:
+
+ - name: Overrides all device configuration with provided configuration
+ register: result
+ vyos.vyos.vyos_static_routes: &id001
+ config:
+
+ - address_families:
+
+ - afi: ipv4
+ routes:
+
+ - dest: 198.0.2.48/28
+ next_hops:
+
+ - forward_router_address: 192.0.2.18
+ state: overridden
+
+ - name: Assert that before dicts were correctly generated
+ assert:
+ that:
+ - "{{ populate | 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)
+ register: result
+ vyos.vyos.vyos_static_routes: *id001
+
+ - 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/tests/integration/targets/vyos_static_routes/tests/cli/parsed.yaml b/tests/integration/targets/vyos_static_routes/tests/cli/parsed.yaml
new file mode 100644
index 0000000..4b6e434
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/tests/cli/parsed.yaml
@@ -0,0 +1,41 @@
+---
+- debug:
+ msg: START vyos_static_routes parsed integration tests on connection={{ ansible_connection
+ }}
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _populate.yaml
+
+- block:
+
+ - name: Gather static_routes facts
+ register: static_routes_facts
+ vyos.vyos.vyos_facts:
+ gather_subset:
+ - default
+ gather_network_resources:
+ - static_routes
+
+ - name: Provide the running configuration for parsing (config to be parsed)
+ register: result
+ vyos.vyos.vyos_static_routes: &id001
+ running_config: "{{ lookup('file', '_parsed_config.cfg') }}"
+ state: parsed
+
+ - name: Assert that correct parsing done
+ assert:
+ that: "{{ ansible_facts['network_resources']['static_routes'] | symmetric_difference(result['parsed'])\
+ \ |length == 0 }}"
+
+ - name: Gather the existing running configuration (IDEMPOTENT)
+ register: result
+ vyos.vyos.vyos_static_routes: *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_static_routes/tests/cli/rendered.yaml b/tests/integration/targets/vyos_static_routes/tests/cli/rendered.yaml
new file mode 100644
index 0000000..ff18523
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/tests/cli/rendered.yaml
@@ -0,0 +1,62 @@
+---
+- debug:
+ msg: START vyos_static_routes 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_static_routes: &id001
+ config:
+
+ - address_families:
+
+ - afi: ipv4
+ routes:
+
+ - dest: 192.0.2.32/28
+ blackhole_config:
+ type: blackhole
+ next_hops:
+
+ - forward_router_address: 192.0.2.10
+
+ - forward_router_address: 192.0.2.9
+
+ - address_families:
+
+ - afi: ipv6
+ routes:
+
+ - dest: 2001:db8:1000::/36
+ blackhole_config:
+ distance: 2
+ next_hops:
+
+ - forward_router_address: 2001:db8:2000:2::1
+
+ - forward_router_address: 2001:db8:2000:2::2
+ 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_static_routes: *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_static_routes/tests/cli/replaced.yaml b/tests/integration/targets/vyos_static_routes/tests/cli/replaced.yaml
new file mode 100644
index 0000000..80ed801
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/tests/cli/replaced.yaml
@@ -0,0 +1,69 @@
+---
+- debug:
+ msg: START vyos_static_routes replaced integration tests on connection={{ ansible_connection
+ }}
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _populate.yaml
+
+- block:
+
+ - name: Replace device configurations of listed static routes with provided
+ configurations
+ register: result
+ vyos.vyos.vyos_static_routes: &id001
+ config:
+
+ - address_families:
+
+ - afi: ipv4
+ routes:
+
+ - dest: 192.0.2.32/28
+ blackhole_config:
+ distance: 2
+ next_hops:
+
+ - forward_router_address: 192.0.2.7
+
+ - forward_router_address: 192.0.2.8
+
+ - forward_router_address: 192.0.2.9
+ state: replaced
+
+ - 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 static routes with provided
+ configurarions (IDEMPOTENT)
+ register: result
+ vyos.vyos.vyos_static_routes: *id001
+
+ - 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/tests/integration/targets/vyos_static_routes/tests/cli/rtt.yaml b/tests/integration/targets/vyos_static_routes/tests/cli/rtt.yaml
new file mode 100644
index 0000000..340fde9
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/tests/cli/rtt.yaml
@@ -0,0 +1,90 @@
+---
+- debug:
+ msg: START vyos_static_routes round trip integration tests on connection={{
+ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+
+ - name: Apply the provided configuration (base config)
+ register: base_config
+ vyos.vyos.vyos_static_routes:
+ config:
+
+ - address_families:
+
+ - afi: ipv4
+ routes:
+
+ - dest: 192.0.2.32/28
+ blackhole_config:
+ type: blackhole
+ next_hops:
+
+ - forward_router_address: 192.0.2.10
+
+ - forward_router_address: 192.0.2.9
+
+ - address_families:
+
+ - afi: ipv6
+ routes:
+
+ - dest: 2001:db8:1000::/36
+ blackhole_config:
+ distance: 2
+ next_hops:
+
+ - forward_router_address: 2001:db8:2000:2::1
+
+ - forward_router_address: 2001:db8:2000:2::2
+ state: merged
+
+ - name: Gather static_routes facts
+ vyos.vyos.vyos_facts:
+ gather_subset:
+ - default
+ gather_network_resources:
+ - static_routes
+
+ - name: Apply the provided configuration (config to be reverted)
+ register: result
+ vyos.vyos.vyos_static_routes:
+ config:
+
+ - address_families:
+
+ - afi: ipv4
+ routes:
+
+ - dest: 192.0.2.32/28
+ blackhole_config:
+ distance: 2
+ next_hops:
+
+ - forward_router_address: 192.0.2.7
+
+ - forward_router_address: 192.0.2.8
+
+ - forward_router_address: 192.0.2.9
+ state: merged
+
+ - 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
+ register: revert
+ vyos.vyos.vyos_static_routes:
+ config: "{{ ansible_facts['network_resources']['static_routes'] }}"
+ state: overridden
+
+ - 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/tests/integration/targets/vyos_static_routes/vars/main.yaml b/tests/integration/targets/vyos_static_routes/vars/main.yaml
new file mode 100644
index 0000000..93b875f
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/vars/main.yaml
@@ -0,0 +1,147 @@
+---
+merged:
+ before: []
+ commands:
+ - set protocols static route 192.0.2.32/28 next-hop '192.0.2.10'
+ - set protocols static route 192.0.2.32/28 next-hop '192.0.2.9'
+ - set protocols static route 192.0.2.32/28 blackhole
+ - set protocols static route 192.0.2.32/28
+ - set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1'
+ - set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2'
+ - set protocols static route6 2001:db8:1000::/36 blackhole distance '2'
+ - set protocols static route6 2001:db8:1000::/36
+ after:
+ - address_families:
+ - afi: ipv4
+ routes:
+ - dest: 192.0.2.32/28
+ blackhole_config:
+ type: blackhole
+ next_hops:
+ - forward_router_address: 192.0.2.9
+ - forward_router_address: 192.0.2.10
+ - afi: ipv6
+ routes:
+ - dest: 2001:db8:1000::/36
+ blackhole_config:
+ distance: 2
+ next_hops:
+ - forward_router_address: 2001:db8:2000:2::1
+ - forward_router_address: 2001:db8:2000:2::2
+populate:
+ - address_families:
+ - afi: ipv4
+ routes:
+ - dest: 192.0.2.32/28
+ blackhole_config:
+ type: blackhole
+ next_hops:
+ - forward_router_address: 192.0.2.9
+ - forward_router_address: 192.0.2.10
+ - afi: ipv6
+ routes:
+ - dest: 2001:db8:1000::/36
+ blackhole_config:
+ distance: 2
+ next_hops:
+ - forward_router_address: 2001:db8:2000:2::1
+ - forward_router_address: 2001:db8:2000:2::2
+replaced:
+ commands:
+ - delete protocols static route 192.0.2.32/28 next-hop '192.0.2.10'
+ - set protocols static route 192.0.2.32/28 next-hop '192.0.2.7'
+ - set protocols static route 192.0.2.32/28 next-hop '192.0.2.8'
+ - set protocols static route 192.0.2.32/28 blackhole distance '2'
+ after:
+ - address_families:
+ - afi: ipv4
+ routes:
+ - dest: 192.0.2.32/28
+ blackhole_config:
+ distance: 2
+ next_hops:
+ - forward_router_address: 192.0.2.7
+ - forward_router_address: 192.0.2.8
+ - forward_router_address: 192.0.2.9
+ - afi: ipv6
+ routes:
+ - dest: 2001:db8:1000::/36
+ blackhole_config:
+ distance: 2
+ next_hops:
+ - forward_router_address: 2001:db8:2000:2::1
+ - forward_router_address: 2001:db8:2000:2::2
+overridden:
+ commands:
+ - delete protocols static route 192.0.2.32/28
+ - delete protocols static route6 2001:db8:1000::/36
+ - set protocols static route 198.0.2.48/28 next-hop '192.0.2.18'
+ - set protocols static route 198.0.2.48/28
+ after:
+ - address_families:
+ - afi: ipv4
+ routes:
+ - dest: 198.0.2.48/28
+ next_hops:
+ - forward_router_address: 192.0.2.18
+rendered:
+ commands:
+ - set protocols static route 192.0.2.32/28 next-hop '192.0.2.10'
+ - set protocols static route 192.0.2.32/28 next-hop '192.0.2.9'
+ - set protocols static route 192.0.2.32/28 blackhole
+ - set protocols static route 192.0.2.32/28
+ - set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1'
+ - set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2'
+ - set protocols static route6 2001:db8:1000::/36 blackhole distance '2'
+ - set protocols static route6 2001:db8:1000::/36
+deleted_dest:
+ commands:
+ - delete protocols static route 192.0.2.32/28
+ - delete protocols static route6 2001:db8:1000::/36
+ after: []
+deleted_nh:
+ commands:
+ - delete protocols static route 192.0.2.32/28 next-hop '192.0.2.9'
+ - delete protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1'
+ after:
+ - address_families:
+ - afi: ipv4
+ routes:
+ - dest: 192.0.2.32/28
+ blackhole_config:
+ type: blackhole
+ next_hops:
+ - forward_router_address: 192.0.2.10
+ - afi: ipv6
+ routes:
+ - dest: 2001:db8:1000::/36
+ blackhole_config:
+ distance: 2
+ next_hops:
+ - forward_router_address: 2001:db8:2000:2::2
+deleted_afi_all:
+ commands:
+ - delete protocols static route
+ - delete protocols static route6
+ after: []
+round_trip:
+ after:
+ - address_families:
+ - afi: ipv4
+ routes:
+ - dest: 192.0.2.32/28
+ blackhole_config:
+ distance: 2
+ next_hops:
+ - forward_router_address: 192.0.2.7
+ - forward_router_address: 192.0.2.8
+ - forward_router_address: 192.0.2.9
+ - forward_router_address: 192.0.2.10
+ - afi: ipv6
+ routes:
+ - dest: 2001:db8:1000::/36
+ blackhole_config:
+ distance: 2
+ next_hops:
+ - forward_router_address: 2001:db8:2000:2::1
+ - forward_router_address: 2001:db8:2000:2::2