diff options
Diffstat (limited to 'tests/integration/targets/vyos_ha')
12 files changed, 288 insertions, 0 deletions
diff --git a/tests/integration/targets/vyos_ha/aliases b/tests/integration/targets/vyos_ha/aliases new file mode 100644 index 0000000..cc0afef --- /dev/null +++ b/tests/integration/targets/vyos_ha/aliases @@ -0,0 +1 @@ +network/vyos diff --git a/tests/integration/targets/vyos_ha/defaults/main.yaml b/tests/integration/targets/vyos_ha/defaults/main.yaml new file mode 100644 index 0000000..164afea --- /dev/null +++ b/tests/integration/targets/vyos_ha/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/tests/integration/targets/vyos_ha/tasks/httpapi.yaml b/tests/integration/targets/vyos_ha/tasks/httpapi.yaml new file mode 100644 index 0000000..014aa9d --- /dev/null +++ b/tests/integration/targets/vyos_ha/tasks/httpapi.yaml @@ -0,0 +1,18 @@ +--- +- name: Collect all httpapi test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/httpapi" + patterns: "*.yaml" + excludes: "_*.yaml" + 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 }}" + loop: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/tests/integration/targets/vyos_ha/tasks/main.yaml b/tests/integration/targets/vyos_ha/tasks/main.yaml new file mode 100644 index 0000000..d14215c --- /dev/null +++ b/tests/integration/targets/vyos_ha/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- name: Run httpapi tests + ansible.builtin.include_tasks: httpapi.yaml diff --git a/tests/integration/targets/vyos_ha/tests/httpapi/_populate_config.yaml b/tests/integration/targets/vyos_ha/tests/httpapi/_populate_config.yaml new file mode 100644 index 0000000..0a73b89 --- /dev/null +++ b/tests/integration/targets/vyos_ha/tests/httpapi/_populate_config.yaml @@ -0,0 +1,40 @@ +--- +- name: Populate HA config for testing + vyos.rest.vyos_ha: + config: + vrrp: + global_parameters: + startup_delay: 30 + garp: + master_repeat: 6 + groups: + - name: g1 + interface: eth0 + vrid: 20 + priority: 100 + address: + - 192.168.1.100/24 + peer_address: 192.168.1.3 + - name: g2 + interface: eth1 + vrid: 21 + priority: 50 + address: + - 192.168.2.100/24 + sync_groups: + - name: sg1 + member: [g1] + health_check: + failure_count: 5 + ping: 192.168.1.1 + snmp: enabled + virtual_servers: + - name: s1 + address: 10.10.10.5 + algorithm: round-robin + port: 80 + protocol: tcp + real_server: + - address: 10.10.50.2 + port: 8080 + state: merged diff --git a/tests/integration/targets/vyos_ha/tests/httpapi/_remove_config.yaml b/tests/integration/targets/vyos_ha/tests/httpapi/_remove_config.yaml new file mode 100644 index 0000000..77a90d0 --- /dev/null +++ b/tests/integration/targets/vyos_ha/tests/httpapi/_remove_config.yaml @@ -0,0 +1,4 @@ +--- +- name: Remove all HA configuration + vyos.rest.vyos_ha: + state: deleted diff --git a/tests/integration/targets/vyos_ha/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_ha/tests/httpapi/deleted.yaml new file mode 100644 index 0000000..571e02d --- /dev/null +++ b/tests/integration/targets/vyos_ha/tests/httpapi/deleted.yaml @@ -0,0 +1,36 @@ +--- +- debug: + msg: START vyos_ha deleted integration tests on connection={{ ansible_connection }} + +- include_tasks: _remove_config.yaml +- block: + - include_tasks: _populate_config.yaml + + - name: Delete all HA configuration + vyos.rest.vyos_ha: &id001 + state: deleted + register: result + + - assert: + that: + - result.changed == true + + - name: Gather after delete + vyos.rest.vyos_ha: + state: gathered + register: gathered + + - assert: + that: + - gathered.gathered == {} + + - name: Delete again (IDEMPOTENT) + vyos.rest.vyos_ha: *id001 + register: result + + - assert: + that: + - result.changed == false + + always: + - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_ha/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_ha/tests/httpapi/gathered.yaml new file mode 100644 index 0000000..cf261fb --- /dev/null +++ b/tests/integration/targets/vyos_ha/tests/httpapi/gathered.yaml @@ -0,0 +1,29 @@ +--- +- debug: + msg: START vyos_ha gathered integration tests on connection={{ ansible_connection }} + +- include_tasks: _remove_config.yaml +- block: + - include_tasks: _populate_config.yaml + + - name: Gather HA configuration + vyos.rest.vyos_ha: + state: gathered + register: result + + - assert: + that: + - result.changed == false + - "'vrrp' in result.gathered" + - "'virtual_servers' in result.gathered" + - result.gathered.vrrp.groups | length == 2 + - result.gathered.vrrp.groups | selectattr('name','equalto','g1') | list | length == 1 + - result.gathered.vrrp.groups | selectattr('name','equalto','g2') | list | length == 1 + - result.gathered.vrrp.snmp == "enabled" + - result.gathered.vrrp.global_parameters.startup_delay == 30 + - result.gathered.vrrp.sync_groups[0].name == "sg1" + - result.gathered.vrrp.sync_groups[0].member == ["g1"] + - result.gathered.virtual_servers[0].name == "s1" + + always: + - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_ha/tests/httpapi/merged.yaml b/tests/integration/targets/vyos_ha/tests/httpapi/merged.yaml new file mode 100644 index 0000000..5614720 --- /dev/null +++ b/tests/integration/targets/vyos_ha/tests/httpapi/merged.yaml @@ -0,0 +1,54 @@ +--- +- debug: + msg: START vyos_ha merged integration tests on connection={{ ansible_connection }} + +- include_tasks: _remove_config.yaml + +- block: + - name: Merge HA configuration + vyos.rest.vyos_ha: &id001 + config: + vrrp: + global_parameters: + startup_delay: 30 + groups: + - name: g1 + interface: eth0 + vrid: 20 + priority: 100 + address: + - 192.168.1.100/24 + sync_groups: + - name: sg1 + member: [g1] + health_check: + failure_count: 3 + ping: 192.168.1.1 + snmp: enabled + virtual_servers: + - name: s1 + address: 10.10.10.5 + port: 80 + protocol: tcp + real_server: + - address: 10.10.50.2 + port: 8080 + state: merged + register: result + + - assert: + that: + - result.changed == true + - result.commands | length > 0 + + - name: Merge again (IDEMPOTENT) + vyos.rest.vyos_ha: *id001 + register: result + + - assert: + that: + - result.changed == false + - result.commands == [] + + always: + - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_ha/tests/httpapi/overridden.yaml b/tests/integration/targets/vyos_ha/tests/httpapi/overridden.yaml new file mode 100644 index 0000000..c916e2d --- /dev/null +++ b/tests/integration/targets/vyos_ha/tests/httpapi/overridden.yaml @@ -0,0 +1,50 @@ +--- +- debug: + msg: START vyos_ha overridden integration tests on connection={{ ansible_connection }} + +- include_tasks: _remove_config.yaml +- block: + - include_tasks: _populate_config.yaml + + - name: Override - only g1 remains, virtual_servers removed + vyos.rest.vyos_ha: &id001 + config: + vrrp: + groups: + - name: g1 + interface: eth0 + vrid: 20 + priority: 100 + address: + - 192.168.1.100/24 + state: overridden + register: result + + - assert: + that: + - result.changed == true + + - name: Gather after override + vyos.rest.vyos_ha: + state: gathered + register: gathered + + - assert: + that: + - gathered.gathered.vrrp.groups | length == 1 + - gathered.gathered.vrrp.groups[0].name == "g1" + - "'virtual_servers' not in gathered.gathered" + - "'sync_groups' not in gathered.gathered.vrrp" + - "'snmp' not in gathered.gathered.vrrp" + + - name: Override again (IDEMPOTENT) + vyos.rest.vyos_ha: *id001 + register: result + + - assert: + that: + - result.changed == false + - result.commands == [] + + always: + - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_ha/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_ha/tests/httpapi/replaced.yaml new file mode 100644 index 0000000..6ad458b --- /dev/null +++ b/tests/integration/targets/vyos_ha/tests/httpapi/replaced.yaml @@ -0,0 +1,48 @@ +--- +- debug: + msg: START vyos_ha replaced integration tests on connection={{ ansible_connection }} + +- include_tasks: _remove_config.yaml +- block: + - include_tasks: _populate_config.yaml + + - name: Replace vrrp groups - removes g2, keeps virtual_servers + vyos.rest.vyos_ha: &id001 + config: + vrrp: + groups: + - name: g1 + interface: eth0 + vrid: 20 + priority: 100 + address: + - 192.168.1.100/24 + state: replaced + register: result + + - assert: + that: + - result.changed == true + + - name: Gather after replace + vyos.rest.vyos_ha: + state: gathered + register: gathered + + - assert: + that: + - gathered.gathered.vrrp.groups | length == 1 + - gathered.gathered.vrrp.groups[0].name == "g1" + - "'virtual_servers' in gathered.gathered" + + - name: Replace again (IDEMPOTENT) + vyos.rest.vyos_ha: *id001 + register: result + + - assert: + that: + - result.changed == false + - result.commands == [] + + always: + - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_ha/vars/main.yaml b/tests/integration/targets/vyos_ha/vars/main.yaml new file mode 100644 index 0000000..4303881 --- /dev/null +++ b/tests/integration/targets/vyos_ha/vars/main.yaml @@ -0,0 +1,2 @@ +--- +# only common vars here |
