summaryrefslogtreecommitdiff
path: root/tests/integration
diff options
context:
space:
mode:
authoromnom62 <75066712+omnom62@users.noreply.github.com>2026-08-21 23:54:29 +1000
committerGitHub <noreply@github.com>2026-08-21 08:54:29 -0500
commit885b9462480712210ddeea9ca4a4b7a52e9ef587 (patch)
treea994ef61f704d41bdab770c86a21481a5d95d2b1 /tests/integration
parent6dc9d721513dca5a573c7ee01b74d703ff41f95f (diff)
downloadrest.vyos-885b9462480712210ddeea9ca4a4b7a52e9ef587.tar.gz
rest.vyos-885b9462480712210ddeea9ca4a4b7a52e9ef587.zip
T8989: static_routes module
* T8989 static_routes * T8989 static_routes * T8989 added changelog fragment for static routes module * t8989 static route changelog * t8989 static_routes module * T8989: static_routes SIT overridden and rtt * T8989: SIT updated * T8989: vyos_static_routes dict_op refactor
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/targets/vyos_static_routes/aliases1
-rw-r--r--tests/integration/targets/vyos_static_routes/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_static_routes/tasks/httpapi.yaml21
-rw-r--r--tests/integration/targets/vyos_static_routes/tasks/main.yaml5
-rw-r--r--tests/integration/targets/vyos_static_routes/tests/httpapi.yaml21
-rw-r--r--tests/integration/targets/vyos_static_routes/tests/httpapi/_populate_config.yaml19
-rw-r--r--tests/integration/targets/vyos_static_routes/tests/httpapi/_remove_config.yaml5
-rw-r--r--tests/integration/targets/vyos_static_routes/tests/httpapi/deleted.yaml28
-rw-r--r--tests/integration/targets/vyos_static_routes/tests/httpapi/gathered.yaml20
-rw-r--r--tests/integration/targets/vyos_static_routes/tests/httpapi/merged.yaml37
-rw-r--r--tests/integration/targets/vyos_static_routes/tests/httpapi/overridden.yaml34
-rw-r--r--tests/integration/targets/vyos_static_routes/tests/httpapi/replaced.yaml35
-rw-r--r--tests/integration/targets/vyos_static_routes/tests/httpapi/rtt.yaml71
-rw-r--r--tests/integration/targets/vyos_static_routes/vars/main.yaml1
14 files changed, 301 insertions, 0 deletions
diff --git a/tests/integration/targets/vyos_static_routes/aliases b/tests/integration/targets/vyos_static_routes/aliases
new file mode 100644
index 0000000..cc0afef
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/aliases
@@ -0,0 +1 @@
+network/vyos
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..164afea
--- /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/tasks/httpapi.yaml b/tests/integration/targets/vyos_static_routes/tasks/httpapi.yaml
new file mode 100644
index 0000000..4147e6d
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/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 }}"
+
+- 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_static_routes/tasks/main.yaml b/tests/integration/targets/vyos_static_routes/tasks/main.yaml
new file mode 100644
index 0000000..b1f6193
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/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_static_routes/tests/httpapi.yaml b/tests/integration/targets/vyos_static_routes/tests/httpapi.yaml
new file mode 100644
index 0000000..4147e6d
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/tests/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 }}"
+
+- 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_static_routes/tests/httpapi/_populate_config.yaml b/tests/integration/targets/vyos_static_routes/tests/httpapi/_populate_config.yaml
new file mode 100644
index 0000000..e257075
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/tests/httpapi/_populate_config.yaml
@@ -0,0 +1,19 @@
+---
+- name: Populate static_routes config for testing
+ vyos.rest.vyos_static_routes:
+ config:
+ - afi: ipv4
+ routes:
+ - dest: 192.0.2.0/24
+ next_hops:
+ - forward_router_address: 10.0.0.1
+ - dest: 203.0.113.0/24
+ blackhole_config:
+ distance: 200
+ - afi: ipv6
+ routes:
+ - dest: 2001:db8::/32
+ next_hops:
+ - forward_router_address: 2001:db8::1
+ state: merged
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_static_routes/tests/httpapi/_remove_config.yaml b/tests/integration/targets/vyos_static_routes/tests/httpapi/_remove_config.yaml
new file mode 100644
index 0000000..dd02da6
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/tests/httpapi/_remove_config.yaml
@@ -0,0 +1,5 @@
+---
+- name: Remove pre-existing static_routes config
+ vyos.rest.vyos_static_routes:
+ state: deleted
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_static_routes/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_static_routes/tests/httpapi/deleted.yaml
new file mode 100644
index 0000000..b02e256
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/tests/httpapi/deleted.yaml
@@ -0,0 +1,28 @@
+---
+- debug:
+ msg: START vyos_static_routes deleted integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Delete all static_routes configuration
+ register: result
+ vyos.rest.vyos_static_routes: &id001
+ state: deleted
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Delete static_routes configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_static_routes: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_static_routes/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_static_routes/tests/httpapi/gathered.yaml
new file mode 100644
index 0000000..c6d5e59
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/tests/httpapi/gathered.yaml
@@ -0,0 +1,20 @@
+---
+- debug:
+ msg: START vyos_static_routes gathered integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather static_routes configuration
+ register: result
+ vyos.rest.vyos_static_routes:
+ state: gathered
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.gathered | selectattr('afi', 'eq', 'ipv4') | list | length > 0
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_static_routes/tests/httpapi/merged.yaml b/tests/integration/targets/vyos_static_routes/tests/httpapi/merged.yaml
new file mode 100644
index 0000000..6cf6a01
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/tests/httpapi/merged.yaml
@@ -0,0 +1,37 @@
+---
+- debug:
+ msg: START vyos_static_routes merged integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Merge static_routes configuration
+ register: result
+ vyos.rest.vyos_static_routes: &id001
+ config:
+ - afi: ipv4
+ routes:
+ - dest: 192.0.2.0/24
+ next_hops:
+ - forward_router_address: 10.0.0.1
+ - dest: 203.0.113.0/24
+ blackhole_config:
+ distance: 200
+ state: merged
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Merge static_routes configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_static_routes: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_static_routes/tests/httpapi/overridden.yaml b/tests/integration/targets/vyos_static_routes/tests/httpapi/overridden.yaml
new file mode 100644
index 0000000..e716d75
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/tests/httpapi/overridden.yaml
@@ -0,0 +1,34 @@
+---
+- debug:
+ msg: START vyos_static_routes overridden integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Override static_routes configuration
+ register: result
+ vyos.rest.vyos_static_routes: &id001
+ config:
+ - afi: ipv4
+ routes:
+ - dest: 192.0.2.0/24
+ next_hops:
+ - forward_router_address: 10.0.0.2
+ state: overridden
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Override static_routes configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_static_routes: *id001
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_static_routes/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_static_routes/tests/httpapi/replaced.yaml
new file mode 100644
index 0000000..a27e637
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/tests/httpapi/replaced.yaml
@@ -0,0 +1,35 @@
+---
+- debug:
+ msg: START vyos_static_routes replaced integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replace static_routes configuration
+ register: result
+ vyos.rest.vyos_static_routes: &id001
+ config:
+ - afi: ipv4
+ routes:
+ - dest: 192.0.2.0/24
+ next_hops:
+ - forward_router_address: 10.0.0.2
+ state: replaced
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Replace static_routes configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_static_routes: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_static_routes/tests/httpapi/rtt.yaml b/tests/integration/targets/vyos_static_routes/tests/httpapi/rtt.yaml
new file mode 100644
index 0000000..e0c76f9
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/tests/httpapi/rtt.yaml
@@ -0,0 +1,71 @@
+---
+- debug:
+ msg: START vyos_static_routes round trip integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: RTT - Apply base configuration
+ vyos.rest.vyos_static_routes:
+ config:
+ - afi: ipv4
+ routes:
+ - dest: 192.0.2.0/24
+ next_hops:
+ - forward_router_address: 10.0.0.1
+ - dest: 203.0.113.0/24
+ blackhole_config:
+ distance: 200
+ state: merged
+
+ - name: RTT - Gather configuration
+ register: gathered
+ vyos.rest.vyos_static_routes:
+ state: gathered
+
+ - name: RTT - Assert gathered matches applied
+ vars:
+ ipv4_routes: >-
+ {{ gathered.gathered
+ | selectattr('afi', 'eq', 'ipv4')
+ | map(attribute='routes')
+ | first }}
+ assert:
+ that:
+ - gathered.gathered | selectattr('afi', 'eq', 'ipv4') | list | length == 1
+ - ipv4_routes | selectattr('dest', 'eq', '192.0.2.0/24') | list | length == 1
+
+ - name: RTT - Modify configuration
+ vyos.rest.vyos_static_routes:
+ config:
+ - afi: ipv4
+ routes:
+ - dest: 192.0.2.0/24
+ next_hops:
+ - forward_router_address: 10.0.0.2
+ state: replaced
+
+ - name: RTT - Gather modified configuration
+ register: gathered2
+ vyos.rest.vyos_static_routes:
+ state: gathered
+
+ - name: RTT - Assert modification applied correctly
+ vars:
+ ipv4_routes2: >-
+ {{ gathered2.gathered
+ | selectattr('afi', 'eq', 'ipv4')
+ | map(attribute='routes')
+ | first }}
+ dest_hops: >-
+ {{ ipv4_routes2
+ | selectattr('dest', 'eq', '192.0.2.0/24')
+ | map(attribute='next_hops')
+ | first }}
+ assert:
+ that:
+ - gathered2.gathered | selectattr('afi', 'eq', 'ipv4') | list | length == 1
+ - dest_hops | selectattr('forward_router_address', 'eq', '10.0.0.2') | list | length == 1
+
+ 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..ed97d53
--- /dev/null
+++ b/tests/integration/targets/vyos_static_routes/vars/main.yaml
@@ -0,0 +1 @@
+---