From 45dc95873fd906c582fbbd5e6ca3838caf867399 Mon Sep 17 00:00:00 2001 From: omnom62 Date: Mon, 6 Jul 2026 14:54:12 +1000 Subject: T8989: wave4 vyos_command, dict_op refactor * T8989: vyos_command module * T8989: vyos_command module UAT and SIT * T8989: vyos_command changelog * T8989: vyos_command linter * T8989: vyos_config module * T8989: vyos_config module changelog * T8989: Wave 4 vyos_config module with integration and unit tests * T8323: vyos_system module * T8332: vyos_system SIT and UAT * T8323: vyos_vlan module * T8323: vyos_vlan module * T8323: vyos_vlan module SIT and UAT * T8323: vyos_system module * T8989: Wave 4 vyos_vlan reworked with dict_op engine * T8989: Fix dict_op single-value string list handling, add vyos_system integration tests * T8989: logging_global refactor * T8989: migrate ntp_global, logging_global, firewall_global to dict_op engine * T8989: vyos_nat module for REST API collection * T8989: vyos_nat module for REST API collection, linter fixes * T8989: vyos_ha module for REST API collection * T8989: vyos_ha module for REST API collection * T8989: vyos_ha module sanity and linter fixes * T8989: vyos_ha module sanity and linter fixes * T8989: vyos_ha module linter fixes * T8989: vyos.rest AI comment fixes * T8323: vyos_nat AI comment fixes * T8989 ai fixes * T8989: vyos_bgp_address_family dict_op * T8989: vyos_bgp_address_family vyos_bgp_global dict_op * T8989: dict_op refactor for firewall_*, nat, user * T8989: dict_op refactor for firewall_*, nat, user * T8989: dict_op refactor for ntp_global, ha * T8989: snmp_server dict_op refactor * T8989: snmp_server dict_op refactor * T8989: route_map dict_op refactor --- tests/integration/targets/vyos_command/aliases | 1 + .../targets/vyos_command/defaults/main.yaml | 3 ++ .../targets/vyos_command/tasks/httpapi.yaml | 21 ++++++++++ .../targets/vyos_command/tasks/main.yaml | 5 +++ .../targets/vyos_command/tests/httpapi/show.yaml | 45 ++++++++++++++++++++++ .../vyos_command/tests/httpapi/wait_for.yaml | 36 +++++++++++++++++ .../targets/vyos_command/vars/main.yaml | 2 + 7 files changed, 113 insertions(+) create mode 100644 tests/integration/targets/vyos_command/aliases create mode 100644 tests/integration/targets/vyos_command/defaults/main.yaml create mode 100644 tests/integration/targets/vyos_command/tasks/httpapi.yaml create mode 100644 tests/integration/targets/vyos_command/tasks/main.yaml create mode 100644 tests/integration/targets/vyos_command/tests/httpapi/show.yaml create mode 100644 tests/integration/targets/vyos_command/tests/httpapi/wait_for.yaml create mode 100644 tests/integration/targets/vyos_command/vars/main.yaml (limited to 'tests/integration/targets/vyos_command') diff --git a/tests/integration/targets/vyos_command/aliases b/tests/integration/targets/vyos_command/aliases new file mode 100644 index 0000000..cc0afef --- /dev/null +++ b/tests/integration/targets/vyos_command/aliases @@ -0,0 +1 @@ +network/vyos diff --git a/tests/integration/targets/vyos_command/defaults/main.yaml b/tests/integration/targets/vyos_command/defaults/main.yaml new file mode 100644 index 0000000..164afea --- /dev/null +++ b/tests/integration/targets/vyos_command/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/tests/integration/targets/vyos_command/tasks/httpapi.yaml b/tests/integration/targets/vyos_command/tasks/httpapi.yaml new file mode 100644 index 0000000..0ed3e42 --- /dev/null +++ b/tests/integration/targets/vyos_command/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_command/tasks/main.yaml b/tests/integration/targets/vyos_command/tasks/main.yaml new file mode 100644 index 0000000..b1f6193 --- /dev/null +++ b/tests/integration/targets/vyos_command/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_command/tests/httpapi/show.yaml b/tests/integration/targets/vyos_command/tests/httpapi/show.yaml new file mode 100644 index 0000000..fed35d7 --- /dev/null +++ b/tests/integration/targets/vyos_command/tests/httpapi/show.yaml @@ -0,0 +1,45 @@ +--- +- debug: + msg: START vyos_command show integration tests on connection={{ ansible_connection }} + +- block: + - name: Run show version + register: result + vyos.rest.vyos_command: + commands: + - version + + - assert: + that: + - result.stdout | length == 1 + - result.stdout[0] | length > 0 + - "'VyOS' in result.stdout[0]" + - result.stdout_lines | length == 1 + + - name: Run multiple show commands + register: result + vyos.rest.vyos_command: + commands: + - interfaces + - ip route + - system uptime + + - assert: + that: + - result.stdout | length == 3 + - result.stdout_lines | length == 3 + - result.stdout[0] | length > 0 + - result.stdout[1] | length > 0 + - result.stdout[2] | length > 0 + + - name: Run show commands as lists + register: result + vyos.rest.vyos_command: + commands: + - - system + - uptime + + - assert: + that: + - result.stdout | length == 1 + - "'Uptime' in result.stdout[0]" diff --git a/tests/integration/targets/vyos_command/tests/httpapi/wait_for.yaml b/tests/integration/targets/vyos_command/tests/httpapi/wait_for.yaml new file mode 100644 index 0000000..298c68c --- /dev/null +++ b/tests/integration/targets/vyos_command/tests/httpapi/wait_for.yaml @@ -0,0 +1,36 @@ +--- +- debug: + msg: START vyos_command wait_for integration tests on connection={{ ansible_connection }} + +- block: + - name: Wait for version output to contain VyOS + register: result + vyos.rest.vyos_command: + commands: + - version + wait_for: + - result[0] contains VyOS + retries: 3 + interval: 1 + + - assert: + that: + - result.stdout | length == 1 + - "'VyOS' in result.stdout[0]" + + - name: Wait for any condition to match + register: result + vyos.rest.vyos_command: + commands: + - version + - interfaces + wait_for: + - result[0] contains VyOS + - result[1] contains eth0 + match: all + retries: 3 + interval: 1 + + - assert: + that: + - result.stdout | length == 2 diff --git a/tests/integration/targets/vyos_command/vars/main.yaml b/tests/integration/targets/vyos_command/vars/main.yaml new file mode 100644 index 0000000..4303881 --- /dev/null +++ b/tests/integration/targets/vyos_command/vars/main.yaml @@ -0,0 +1,2 @@ +--- +# only common vars here -- cgit v1.2.3