summaryrefslogtreecommitdiff
path: root/tests/integration/targets/vyos_vlan
diff options
context:
space:
mode:
Diffstat (limited to 'tests/integration/targets/vyos_vlan')
-rw-r--r--tests/integration/targets/vyos_vlan/aliases1
-rw-r--r--tests/integration/targets/vyos_vlan/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_vlan/tasks/httpapi.yaml21
-rw-r--r--tests/integration/targets/vyos_vlan/tasks/main.yaml5
-rw-r--r--tests/integration/targets/vyos_vlan/tests/httpapi/_remove_config.yaml9
-rw-r--r--tests/integration/targets/vyos_vlan/tests/httpapi/absent.yaml45
-rw-r--r--tests/integration/targets/vyos_vlan/tests/httpapi/gathered.yaml28
-rw-r--r--tests/integration/targets/vyos_vlan/tests/httpapi/present.yaml44
-rw-r--r--tests/integration/targets/vyos_vlan/tests/httpapi/rtt.yaml43
-rw-r--r--tests/integration/targets/vyos_vlan/vars/main.yaml2
10 files changed, 201 insertions, 0 deletions
diff --git a/tests/integration/targets/vyos_vlan/aliases b/tests/integration/targets/vyos_vlan/aliases
new file mode 100644
index 0000000..cc0afef
--- /dev/null
+++ b/tests/integration/targets/vyos_vlan/aliases
@@ -0,0 +1 @@
+network/vyos
diff --git a/tests/integration/targets/vyos_vlan/defaults/main.yaml b/tests/integration/targets/vyos_vlan/defaults/main.yaml
new file mode 100644
index 0000000..164afea
--- /dev/null
+++ b/tests/integration/targets/vyos_vlan/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/tests/integration/targets/vyos_vlan/tasks/httpapi.yaml b/tests/integration/targets/vyos_vlan/tasks/httpapi.yaml
new file mode 100644
index 0000000..217692f
--- /dev/null
+++ b/tests/integration/targets/vyos_vlan/tasks/httpapi.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all httpapi test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/httpapi"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list | sort}}"
+
+- name: Run test case (connection=httpapi)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.httpapi
+ ansible_network_os: vyos.rest.vyos
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_vlan/tasks/main.yaml b/tests/integration/targets/vyos_vlan/tasks/main.yaml
new file mode 100644
index 0000000..b1f6193
--- /dev/null
+++ b/tests/integration/targets/vyos_vlan/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Run httpapi tests
+ ansible.builtin.include_tasks: httpapi.yaml
+ tags:
+ - httpapi
diff --git a/tests/integration/targets/vyos_vlan/tests/httpapi/_remove_config.yaml b/tests/integration/targets/vyos_vlan/tests/httpapi/_remove_config.yaml
new file mode 100644
index 0000000..a0959b8
--- /dev/null
+++ b/tests/integration/targets/vyos_vlan/tests/httpapi/_remove_config.yaml
@@ -0,0 +1,9 @@
+---
+- name: Remove test VLANs
+ vyos.rest.vyos_vlan:
+ config:
+ - vlan_id: 10
+ interfaces: [eth1]
+ - vlan_id: 20
+ interfaces: [eth1]
+ state: absent
diff --git a/tests/integration/targets/vyos_vlan/tests/httpapi/absent.yaml b/tests/integration/targets/vyos_vlan/tests/httpapi/absent.yaml
new file mode 100644
index 0000000..3547ed1
--- /dev/null
+++ b/tests/integration/targets/vyos_vlan/tests/httpapi/absent.yaml
@@ -0,0 +1,45 @@
+---
+- debug:
+ msg: START vyos_vlan absent integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Setup VLANs
+ vyos.rest.vyos_vlan:
+ config:
+ - vlan_id: 10
+ description: VLAN10
+ interfaces: [eth1]
+ - vlan_id: 20
+ description: VLAN20
+ interfaces: [eth1]
+ state: present
+
+ - name: Remove VLAN
+ register: result
+ vyos.rest.vyos_vlan:
+ config:
+ - vlan_id: 10
+ interfaces: [eth1]
+ state: absent
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Remove VLAN (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_vlan:
+ config:
+ - vlan_id: 10
+ interfaces: [eth1]
+ state: absent
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_vlan/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_vlan/tests/httpapi/gathered.yaml
new file mode 100644
index 0000000..483f7ad
--- /dev/null
+++ b/tests/integration/targets/vyos_vlan/tests/httpapi/gathered.yaml
@@ -0,0 +1,28 @@
+---
+- debug:
+ msg: START vyos_vlan gathered integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Setup VLANs
+ vyos.rest.vyos_vlan:
+ config:
+ - vlan_id: 10
+ description: VLAN10
+ address: 192.168.10.1/24
+ interfaces: [eth1]
+ state: present
+
+ - name: Gather VLANs
+ register: result
+ vyos.rest.vyos_vlan:
+ state: gathered
+
+ - assert:
+ that:
+ - result.gathered | selectattr('vlan_id', 'eq', 10) | list | length == 1
+ - (result.gathered | selectattr('vlan_id', 'eq', 10) | first).description == 'VLAN10'
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_vlan/tests/httpapi/present.yaml b/tests/integration/targets/vyos_vlan/tests/httpapi/present.yaml
new file mode 100644
index 0000000..cfbec27
--- /dev/null
+++ b/tests/integration/targets/vyos_vlan/tests/httpapi/present.yaml
@@ -0,0 +1,44 @@
+---
+- debug:
+ msg: START vyos_vlan present integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Configure VLANs
+ register: result
+ vyos.rest.vyos_vlan:
+ config:
+ - vlan_id: 10
+ description: VLAN10
+ address: 192.168.10.1/24
+ interfaces: [eth1]
+ - vlan_id: 20
+ description: VLAN20
+ interfaces: [eth1]
+ state: present
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Configure VLANs (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_vlan:
+ config:
+ - vlan_id: 10
+ description: VLAN10
+ address: 192.168.10.1/24
+ interfaces: [eth1]
+ - vlan_id: 20
+ description: VLAN20
+ interfaces: [eth1]
+ state: present
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_vlan/tests/httpapi/rtt.yaml b/tests/integration/targets/vyos_vlan/tests/httpapi/rtt.yaml
new file mode 100644
index 0000000..e30032f
--- /dev/null
+++ b/tests/integration/targets/vyos_vlan/tests/httpapi/rtt.yaml
@@ -0,0 +1,43 @@
+---
+- debug:
+ msg: START vyos_vlan round trip integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: RTT - Configure VLAN
+ vyos.rest.vyos_vlan:
+ config:
+ - vlan_id: 10
+ description: VLAN10
+ interfaces: [eth1]
+ state: present
+
+ - name: RTT - Gather
+ register: gathered
+ vyos.rest.vyos_vlan:
+ state: gathered
+
+ - assert:
+ that:
+ - gathered.gathered | selectattr('vlan_id', 'eq', 10) | list | length == 1
+
+ - name: RTT - Update description
+ vyos.rest.vyos_vlan:
+ config:
+ - vlan_id: 10
+ description: VLAN10-updated
+ interfaces: [eth1]
+ state: present
+
+ - name: RTT - Gather after update
+ register: gathered2
+ vyos.rest.vyos_vlan:
+ state: gathered
+
+ - assert:
+ that:
+ - (gathered2.gathered | selectattr('vlan_id', 'eq', 10) | first).description == 'VLAN10-updated'
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_vlan/vars/main.yaml b/tests/integration/targets/vyos_vlan/vars/main.yaml
new file mode 100644
index 0000000..4303881
--- /dev/null
+++ b/tests/integration/targets/vyos_vlan/vars/main.yaml
@@ -0,0 +1,2 @@
+---
+# only common vars here