Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: support for qdevice tls and kaptb options #153

Merged
merged 3 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ variables:
- include_vars_from_parent
- qdevice_all_options
- qdevice_minimal
- qdevice_tls_kaptb_options
- qnetd_and_cluster
- qnetd_disabled
- qnetd
Expand Down
68 changes: 68 additions & 0 deletions tests/template_qdevice.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# SPDX-License-Identifier: MIT
---
- name: Run test
vars:
ha_cluster_cluster_name: test-cluster
block:
- name: Set up test environment
include_role:
name: linux-system-roles.ha_cluster
tasks_from: test_setup.yml

- name: Clean up test environment for qnetd
include_role:
name: linux-system-roles.ha_cluster
tasks_from: test_cleanup_qnetd.yml

- name: Set up test environment for qnetd
include_role:
name: linux-system-roles.ha_cluster
tasks_from: test_setup_qnetd.yml
run_once: true # noqa: run_once[task]

- name: Back up qnetd
include_tasks: tasks/qnetd_backup_restore.yml
vars:
operation: backup
run_once: true # noqa: run_once[task]

- name: Run HA Cluster role
include_role:
name: linux-system-roles.ha_cluster
# variables for the role are supposed to be defined in a playbook which
# includes this task file

# The role removed qnetd configuration
- name: Restore qnetd
include_tasks: tasks/qnetd_backup_restore.yml
vars:
operation: restore
run_once: true # noqa: run_once[task]

- name: Get services status
service_facts:

- name: Check qdevice status
assert:
that:
- ansible_facts.services["corosync-qdevice.service"].status
== "enabled"
- ansible_facts.services["corosync-qdevice.service"].state
== "running"

- name: Check corosync
include_tasks: tasks/assert_corosync_config.yml
# __test_expected_lines is supposed to be defined in a playbook which
# includes this task file

- name: Check cluster status
include_tasks: tasks/assert_cluster_running.yml

- name: Check qdevice status
include_tasks: tasks/assert_qdevice_in_cluster.yml

always:
- name: Clean up test environment for qnetd
include_role:
name: linux-system-roles.ha_cluster
tasks_from: test_cleanup_qnetd.yml
8 changes: 2 additions & 6 deletions tests/tests_cib_properties_one_set.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@
__test_pcs_property_config.stdout_lines | map('trim') | list }}"
when:
- >
not((ansible_facts['distribution'] in ['RedHat', 'CentOS'])
and
ansible_facts['distribution_major_version'] == '9'
not((__test_pcs_version is version('0.11', '>='))
and
('pcmk.properties.cluster.config.output-formats'
in __test_pcs_capabilities))
Expand All @@ -67,9 +65,7 @@
__test_pcs_property_config.stdout_lines | map('trim') | list }}"
when:
- >
(ansible_facts['distribution'] in ['RedHat', 'CentOS'])
and
ansible_facts['distribution_major_version'] == '9'
(__test_pcs_version is version('0.11', '>='))
and
('pcmk.properties.cluster.config.output-formats'
in __test_pcs_capabilities)
Expand Down
167 changes: 59 additions & 108 deletions tests/tests_qdevice_all_options.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,114 +3,65 @@
- name: Test qdevice - all options
hosts: all
vars_files: vars/main.yml
vars:
ha_cluster_cluster_name: test-cluster

tasks:
- name: Set qnetd address
set_fact:
__test_qnetd_address: "{{
(ansible_play_hosts_all | length == 1)
| ternary('localhost', ansible_play_hosts[0]) }}"

- name: Run test
tags: tests::verify
block:
- name: Set up test environment
include_role:
name: linux-system-roles.ha_cluster
tasks_from: test_setup.yml

- name: Set up test environment for qnetd / qdevice
include_role:
name: linux-system-roles.ha_cluster
tasks_from: test_setup_qnetd.yml
run_once: true # noqa: run_once[task]

- name: Back up qnetd
include_tasks: tasks/qnetd_backup_restore.yml
vars:
operation: backup
run_once: true # noqa: run_once[task]

- name: Set qnetd address
set_fact:
__test_qnetd_address: "{{
(ansible_play_hosts_all | length == 1)
| ternary('localhost', ansible_play_hosts[0]) }}"

- name: Run HA Cluster role
include_role:
name: linux-system-roles.ha_cluster
vars:
ha_cluster_quorum:
device:
model: net
model_options:
- name: host
value: "{{ __test_qnetd_address }}"
- name: algorithm
value: lms
generic_options:
- name: timeout
value: 1000
- name: sync_timeout
value: 3000
heuristics_options:
- name: mode
value: "on"
- name: exec_ping
value: /usr/bin/ping -c 1 127.0.0.1

# The role removed qnetd configuration
- name: Restore qnetd
include_tasks: tasks/qnetd_backup_restore.yml
vars:
operation: restore
run_once: true # noqa: run_once[task]

- name: Get services status
service_facts:

- name: Check qdevice status
assert:
that:
- ansible_facts.services["corosync-qdevice.service"].status
== "enabled"
- ansible_facts.services["corosync-qdevice.service"].state
== "running"

- name: Check corosync
include_tasks: tasks/assert_corosync_config.yml
vars:
__test_expected_lines:
- 'totem {'
- ' version: 2'
- ' cluster_name: {{ ha_cluster_cluster_name }}'
- ' transport: knet'
- ' crypto_cipher: aes256'
- ' crypto_hash: sha256'
- '}'
- 'nodelist {'
- '}'
- "quorum {"
- " provider: corosync_votequorum"
- " device {"
- " sync_timeout: 3000"
- " timeout: 1000"
- " model: net"
- " net {"
- " algorithm: lms"
- " host: {{ __test_qnetd_address }}"
- " }"
- " heuristics {"
- " exec_ping: /usr/bin/ping -c 1 127.0.0.1"
- " mode: on"
- " }"
- " }"
- "}"
- 'logging {'
- ' to_logfile: yes'
- ' logfile: /var/log/cluster/corosync.log'
- ' to_syslog: yes'
- ' timestamp: on'
- '}'

- name: Check cluster status
include_tasks: tasks/assert_cluster_running.yml

- name: Check qdevice status
include_tasks: tasks/assert_qdevice_in_cluster.yml
include_tasks: template_qdevice.yml
vars:
ha_cluster_quorum:
device:
model: net
model_options:
- name: host
value: "{{ __test_qnetd_address }}"
- name: algorithm
value: lms
generic_options:
- name: timeout
value: 1000
- name: sync_timeout
value: 3000
heuristics_options:
- name: mode
value: "on"
- name: exec_ping
value: /usr/bin/ping -c 1 127.0.0.1
__test_expected_lines:
- "totem {"
- " version: 2"
- " cluster_name: {{ ha_cluster_cluster_name }}"
- " transport: knet"
- " crypto_cipher: aes256"
- " crypto_hash: sha256"
- "}"
- "nodelist {"
- "}"
- "quorum {"
- " provider: corosync_votequorum"
- " device {"
- " sync_timeout: 3000"
- " timeout: 1000"
- " model: net"
- " net {"
- " algorithm: lms"
- " host: {{ __test_qnetd_address }}"
- " }"
- " heuristics {"
- " exec_ping: /usr/bin/ping -c 1 127.0.0.1"
- " mode: on"
- " }"
- " }"
- "}"
- "logging {"
- " to_logfile: yes"
- " logfile: /var/log/cluster/corosync.log"
- " to_syslog: yes"
- " timestamp: on"
- "}"
Loading