diff options
| author | omnom62 <omnom62@outlook.com> | 2026-06-03 21:47:02 +1000 |
|---|---|---|
| committer | omnom62 <omnom62@outlook.com> | 2026-06-03 21:47:02 +1000 |
| commit | ba080f20749a7c79dc3033e5e022e3ccb00c65c5 (patch) | |
| tree | f00d1d3603606b1bd55189d85be49a7024860a3b /tests/integration | |
| parent | 197c021ddeb7bdd5cfa5155a09d6d253e1247a04 (diff) | |
| download | rest.vyos-ba080f20749a7c79dc3033e5e022e3ccb00c65c5.tar.gz rest.vyos-ba080f20749a7c79dc3033e5e022e3ccb00c65c5.zip | |
vyos_configure tests
Diffstat (limited to 'tests/integration')
6 files changed, 84 insertions, 0 deletions
diff --git a/tests/integration/targets/vyos_configure/aliases b/tests/integration/targets/vyos_configure/aliases new file mode 100644 index 0000000..cc0afef --- /dev/null +++ b/tests/integration/targets/vyos_configure/aliases @@ -0,0 +1 @@ +network/vyos diff --git a/tests/integration/targets/vyos_configure/defaults/main.yaml b/tests/integration/targets/vyos_configure/defaults/main.yaml new file mode 100644 index 0000000..164afea --- /dev/null +++ b/tests/integration/targets/vyos_configure/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/tests/integration/targets/vyos_configure/tasks/httpapi.yaml b/tests/integration/targets/vyos_configure/tasks/httpapi.yaml new file mode 100644 index 0000000..4147e6d --- /dev/null +++ b/tests/integration/targets/vyos_configure/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_configure/tasks/main.yaml b/tests/integration/targets/vyos_configure/tasks/main.yaml new file mode 100644 index 0000000..b1f6193 --- /dev/null +++ b/tests/integration/targets/vyos_configure/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_configure/tests/httpapi/configure.yaml b/tests/integration/targets/vyos_configure/tests/httpapi/configure.yaml new file mode 100644 index 0000000..2f95df3 --- /dev/null +++ b/tests/integration/targets/vyos_configure/tests/httpapi/configure.yaml @@ -0,0 +1,52 @@ +--- +- debug: + msg: START vyos_configure integration tests on connection={{ ansible_connection }} + +- block: + - name: Set a loopback address via vyos_configure + register: result + vyos.rest.vyos_configure: + commands: + - set interfaces loopback lo address 192.0.2.100/32 + + - assert: + that: + - result.changed == true + - result.commands | length == 1 + - result.commands[0][0] == "set" + - result.commands[0][1] == ["interfaces", "loopback", "lo", "address", "192.0.2.100/32"] + + - name: Set multiple commands in one atomic commit + register: result + vyos.rest.vyos_configure: + commands: + - set interfaces loopback lo address 192.0.2.101/32 + - set interfaces loopback lo address 192.0.2.102/32 + + - assert: + that: + - result.changed == true + - result.commands | length == 2 + + - name: Delete loopback addresses + register: result + vyos.rest.vyos_configure: + commands: + - delete interfaces loopback lo address 192.0.2.100/32 + - delete interfaces loopback lo address 192.0.2.101/32 + - delete interfaces loopback lo address 192.0.2.102/32 + + - assert: + that: + - result.changed == true + - result.commands | length == 3 + - result.commands[0][0] == "delete" + + always: + - name: Cleanup — remove test loopback addresses + vyos.rest.vyos_configure: + commands: + - delete interfaces loopback lo address 192.0.2.100/32 + - delete interfaces loopback lo address 192.0.2.101/32 + - delete interfaces loopback lo address 192.0.2.102/32 + ignore_errors: true diff --git a/tests/integration/targets/vyos_configure/vars/main.yaml b/tests/integration/targets/vyos_configure/vars/main.yaml new file mode 100644 index 0000000..4303881 --- /dev/null +++ b/tests/integration/targets/vyos_configure/vars/main.yaml @@ -0,0 +1,2 @@ +--- +# only common vars here |
