summaryrefslogtreecommitdiff
path: root/tests/integration/targets
diff options
context:
space:
mode:
Diffstat (limited to 'tests/integration/targets')
-rw-r--r--tests/integration/targets/vyos_logging_global/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_logging_global/meta/main.yaml2
-rw-r--r--tests/integration/targets/vyos_logging_global/tasks/cli.yaml19
-rw-r--r--tests/integration/targets/vyos_logging_global/tasks/main.yaml4
-rw-r--r--tests/integration/targets/vyos_logging_global/tests/cli/_parsed.cfg3
-rw-r--r--tests/integration/targets/vyos_logging_global/tests/cli/_populate.yaml53
-rw-r--r--tests/integration/targets/vyos_logging_global/tests/cli/_remove_config.yaml4
-rw-r--r--tests/integration/targets/vyos_logging_global/tests/cli/deleted.yaml22
-rw-r--r--tests/integration/targets/vyos_logging_global/tests/cli/empty_config.yaml60
-rw-r--r--tests/integration/targets/vyos_logging_global/tests/cli/gathered.yaml22
-rw-r--r--tests/integration/targets/vyos_logging_global/tests/cli/merged.yaml56
-rw-r--r--tests/integration/targets/vyos_logging_global/tests/cli/overridden.yaml39
-rw-r--r--tests/integration/targets/vyos_logging_global/tests/cli/parsed.yaml14
-rw-r--r--tests/integration/targets/vyos_logging_global/tests/cli/rendered.yaml50
-rw-r--r--tests/integration/targets/vyos_logging_global/vars/main.yaml95
15 files changed, 446 insertions, 0 deletions
diff --git a/tests/integration/targets/vyos_logging_global/defaults/main.yaml b/tests/integration/targets/vyos_logging_global/defaults/main.yaml
new file mode 100644
index 0000000..852a6be
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_global/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: '[^_].*'
+test_items: []
diff --git a/tests/integration/targets/vyos_logging_global/meta/main.yaml b/tests/integration/targets/vyos_logging_global/meta/main.yaml
new file mode 100644
index 0000000..91da2a7
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_global/meta/main.yaml
@@ -0,0 +1,2 @@
+---
+...
diff --git a/tests/integration/targets/vyos_logging_global/tasks/cli.yaml b/tests/integration/targets/vyos_logging_global/tasks/cli.yaml
new file mode 100644
index 0000000..93eb2fe
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_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=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_logging_global/tasks/main.yaml b/tests/integration/targets/vyos_logging_global/tasks/main.yaml
new file mode 100644
index 0000000..b957d2f
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_global/tasks/main.yaml
@@ -0,0 +1,4 @@
+---
+- include: cli.yaml
+ tags:
+ - network_cli
diff --git a/tests/integration/targets/vyos_logging_global/tests/cli/_parsed.cfg b/tests/integration/targets/vyos_logging_global/tests/cli/_parsed.cfg
new file mode 100644
index 0000000..fb2c3dc
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_global/tests/cli/_parsed.cfg
@@ -0,0 +1,3 @@
+set system syslog console facility news level 'debug'
+set system syslog file def facility local7 level 'emerg'
+set system syslog global facility local7 level 'debug'
diff --git a/tests/integration/targets/vyos_logging_global/tests/cli/_populate.yaml b/tests/integration/targets/vyos_logging_global/tests/cli/_populate.yaml
new file mode 100644
index 0000000..2f3828f
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_global/tests/cli/_populate.yaml
@@ -0,0 +1,53 @@
+---
+- name: POPULATE Apply the provided configuration
+ register: result
+ vyos.vyos.vyos_logging_global:
+ config:
+ console:
+ facilities:
+ - facility: all
+ - facility: local7
+ severity: err
+ - facility: news
+ severity: debug
+ files:
+ - path: def
+ archive:
+ file_num: 2
+ facilities:
+ - facility: local6
+ severity: emerg
+ - facility: local7
+ severity: emerg
+ hosts:
+ - hostname: 172.16.2.15
+ facilities:
+ - facility: all
+ severity: all
+ - facility: all
+ protocol: udp
+ - hostname: 172.16.2.12
+ facilities:
+ - facility: all
+ protocol: udp
+ users:
+ - username: vyos
+ facilities:
+ - facility: local7
+ severity: debug
+ - facility: local6
+ severity: alert
+ - username: paul
+ facilities:
+ - facility: local7
+ severity: err
+ global_params:
+ archive:
+ file_num: 2
+ size: 111
+ facilities:
+ - facility: cron
+ severity: debug
+ - facility: local7
+ severity: debug
+ state: merged
diff --git a/tests/integration/targets/vyos_logging_global/tests/cli/_remove_config.yaml b/tests/integration/targets/vyos_logging_global/tests/cli/_remove_config.yaml
new file mode 100644
index 0000000..1c2187b
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_global/tests/cli/_remove_config.yaml
@@ -0,0 +1,4 @@
+---
+- name: delete the provided configuration
+ vyos.vyos.vyos_logging_global:
+ state: deleted
diff --git a/tests/integration/targets/vyos_logging_global/tests/cli/deleted.yaml b/tests/integration/targets/vyos_logging_global/tests/cli/deleted.yaml
new file mode 100644
index 0000000..2a0a355
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_global/tests/cli/deleted.yaml
@@ -0,0 +1,22 @@
+---
+- debug:
+ msg: Start Deleted integration state for vyos_logging ansible_connection={{
+ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate.yaml
+
+- block:
+ - name: TEST - [deleted] Remove all configuration
+ vyos.vyos.vyos_logging_global:
+ state: deleted
+ register: result
+
+ - name: TEST - [deleted] Assert that correct set of commands were generated
+ assert:
+ that:
+ - "{{ deleted['commands'] | symmetric_difference(result['commands']) |\
+ \ length == 0 }}"
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_logging_global/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_logging_global/tests/cli/empty_config.yaml
new file mode 100644
index 0000000..f70fff1
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_global/tests/cli/empty_config.yaml
@@ -0,0 +1,60 @@
+---
+- debug:
+ msg: START vyos_logging_global 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_logging_global:
+ 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_logging_global:
+ 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_logging_global:
+ 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_logging_global:
+ 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_logging_global:
+ 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_logging_global/tests/cli/gathered.yaml b/tests/integration/targets/vyos_logging_global/tests/cli/gathered.yaml
new file mode 100644
index 0000000..af1fa52
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_global/tests/cli/gathered.yaml
@@ -0,0 +1,22 @@
+---
+- debug:
+ msg: START vyos_logging_global gathered integration tests on connection={{
+ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _populate.yaml
+
+- block:
+ - name: TEST - [gathered] Gather the provided configuration with the existing running configuration
+ register: result
+ vyos.vyos.vyos_logging_global:
+ config:
+ state: gathered
+
+ - name: TEST - [gathered] Assert
+ assert:
+ that:
+ - result.changed == false
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_logging_global/tests/cli/merged.yaml b/tests/integration/targets/vyos_logging_global/tests/cli/merged.yaml
new file mode 100644
index 0000000..d47d309
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_global/tests/cli/merged.yaml
@@ -0,0 +1,56 @@
+---
+- debug:
+ msg:
+ START vyos_logging_global merged integration tests on connection={{ ansible_connection
+ }}
+
+- include_tasks: _remove_config.yaml
+
+- block: # no after state match because 1.1.8 vyos does show all commands on show command
+ - name: Merge the provided configuration with the existing running configuration
+ register: result
+ vyos.vyos.vyos_logging_global: &id001
+ config:
+ console:
+ facilities:
+ - facility: all
+ files:
+ - path: def
+ archive:
+ file_num: 2
+ facilities:
+ - facility: local6
+ severity: emerg
+ hosts:
+ - hostname: 172.16.2.15
+ facilities:
+ - facility: all
+ severity: all
+ users:
+ - username: vyos
+ facilities:
+ - facility: local7
+ severity: debug
+ global_params:
+ archive:
+ file_num: 2
+ size: 111
+ facilities:
+ - facility: cron
+ severity: debug
+ state: merged
+
+ - name: Assert that correct set of commands were generated
+ assert:
+ that:
+ - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\
+ \ == 0 }}"
+
+ - name:
+ Merge the provided configuration with the existing running configuration
+ (IDEMPOTENT)
+ register: result
+ vyos.vyos.vyos_logging_global: *id001
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_logging_global/tests/cli/overridden.yaml b/tests/integration/targets/vyos_logging_global/tests/cli/overridden.yaml
new file mode 100644
index 0000000..1df1a8d
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_global/tests/cli/overridden.yaml
@@ -0,0 +1,39 @@
+---
+- debug:
+ msg: START vyos_logging_global overridden integration tests on connection={{
+ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _populate.yaml
+
+- block: # no after state match because 1.1.8 vyos does show all commands on show command
+ - name: Overrides all device configuration with provided configuration
+ register: result
+ vyos.vyos.vyos_logging_global: &id001
+ config:
+ console:
+ facilities:
+ - facility: all
+ - facility: local7
+ severity: err
+ - facility: news
+ severity: debug
+ global_params:
+ archive:
+ file_num: 2
+ state: overridden
+
+ - name: Assert that correct commands were generated
+ assert:
+ that:
+ - "{{ overridden['commands'] | symmetric_difference(result['commands'])\
+ \ |length == 0 }}"
+
+ - name: Overrides all device configuration with provided configurations (IDEMPOTENT)
+ register: result
+ vyos.vyos.vyos_logging_global: *id001
+
+ always:
+
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_logging_global/tests/cli/parsed.yaml b/tests/integration/targets/vyos_logging_global/tests/cli/parsed.yaml
new file mode 100644
index 0000000..40a14f6
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_global/tests/cli/parsed.yaml
@@ -0,0 +1,14 @@
+---
+- debug:
+ msg: START vyos_logging_global parsed integration tests on connection={{ ansible_connection }}
+
+- name: TEST - [parsed] Parse the commands for provided configuration
+ register: result
+ vyos.vyos.vyos_logging_global:
+ running_config: "{{ lookup('file', '_parsed.cfg') }}"
+ state: parsed
+
+- assert:
+ that:
+ - result.changed == false
+ - parsed['after'] == result.parsed
diff --git a/tests/integration/targets/vyos_logging_global/tests/cli/rendered.yaml b/tests/integration/targets/vyos_logging_global/tests/cli/rendered.yaml
new file mode 100644
index 0000000..366f889
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_global/tests/cli/rendered.yaml
@@ -0,0 +1,50 @@
+---
+- debug:
+ msg: START vyos_logging_global 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_logging_global: &id001
+ config:
+ console:
+ facilities:
+ - facility: all
+ files:
+ - path: abc
+ archive:
+ size: 125
+ hosts:
+ - hostname: 172.16.2.15
+ facilities:
+ - facility: all
+ severity: all
+ users:
+ - username: vyos
+ facilities:
+ - facility: local7
+ severity: debug
+ global_params:
+ archive:
+ file_num: 2
+ size: 111
+ facilities:
+ - facility: cron
+ severity: debug
+ 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_logging_global/vars/main.yaml b/tests/integration/targets/vyos_logging_global/vars/main.yaml
new file mode 100644
index 0000000..ae8b853
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_global/vars/main.yaml
@@ -0,0 +1,95 @@
+---
+merged:
+ before: {}
+ commands:
+ - set system syslog host 172.16.2.15 facility all level all
+ - set system syslog console facility all
+ - set system syslog user vyos facility local7 level debug
+ - set system syslog global facility cron level debug
+ - set system syslog global archive file 2
+ - set system syslog global archive size 111
+ - set system syslog file def archive file 2
+ - set system syslog file def facility local6 level emerg
+ after:
+ console:
+ facilities:
+ - facility: all
+ files:
+ - path: def
+ facilities:
+ - facility: local6
+ severity: emerg
+ hosts:
+ - hostname: 172.16.2.15
+ facilities:
+ - facility: all
+ severity: all
+ users:
+ - username: vyos
+ facilities:
+ - facility: local7
+ severity: debug
+ global_params:
+ archive:
+ size: 111
+ facilities:
+ - facility: cron
+ severity: debug
+
+overridden:
+ commands:
+ - delete system syslog file def
+ - delete system syslog global facility cron
+ - delete system syslog global facility local7
+ - delete system syslog host 172.16.2.12
+ - delete system syslog host 172.16.2.15
+ - delete system syslog user paul
+ - delete system syslog user vyos
+ - set system syslog console facility all
+ - set system syslog global archive file 2
+ - delete system syslog global archive size 111
+
+ after:
+ console:
+ facilities:
+ - facility: all
+ - facility: local7
+ severity: err
+ - facility: news
+ severity: debug
+ files:
+ - path: Myfile
+ global_params:
+ archive:
+ file_num: 2
+
+rendered:
+ commands:
+ - set system syslog console facility all
+ - set system syslog file abc archive size 125
+ - set system syslog host 172.16.2.15 facility all level all
+ - set system syslog user vyos facility local7 level debug
+ - set system syslog global facility cron level debug
+ - set system syslog global archive file 2
+ - set system syslog global archive size 111
+
+deleted:
+ commands:
+ - delete system syslog
+ after: {}
+
+parsed:
+ after:
+ console:
+ facilities:
+ - facility: news
+ severity: debug
+ files:
+ - path: def
+ facilities:
+ - facility: local7
+ severity: emerg
+ global_params:
+ facilities:
+ - facility: local7
+ severity: debug