Skip to content

Commit

Permalink
Merge branch 'tests-update'
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjelinek committed Nov 28, 2024
2 parents ae92bb7 + fd00915 commit 7e5752c
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 34 deletions.
1 change: 1 addition & 0 deletions .github/config/ubuntu-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ gcc
libffi-dev
libnss3-tools
pacemaker
pacemaker-dev
psmisc
puma
python3-cryptography
Expand Down
27 changes: 18 additions & 9 deletions .github/workflows/python-unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,20 @@ jobs:
python:
strategy:
matrix:
os:
- ubuntu-22.04
- ubuntu-latest
pcs_version:
- v0.11.4
- v0.11.5
- v0.11.6
- main
include:
- os: ubuntu-22.04
pcs_version: v0.11.4
- os: ubuntu-22.04
pcs_version: v0.11.5
- os: ubuntu-22.04
pcs_version: v0.11.6
- os: ubuntu-22.04
pcs_version: v0.11.7
- os: ubuntu-22.04
pcs_version: v0.11.8
- os: ubuntu-24.04
pcs_version: main
# pcs_version 0.12.x will go to ubuntu 24.04 only
runs-on: ${{ matrix.os }}
steps:
- name: Update git
Expand All @@ -47,6 +53,9 @@ jobs:
# package per line.
if [ -f .github/config/ubuntu-requirements.txt ]; then
sudo apt-get install -y $(cat .github/config/ubuntu-requirements.txt)
# remove pcs which is installed as a dependency of pacemaker (since
# ubuntu 23.10) and conflicts with pcs built from source
sudo dpkg --force-depends --purge pcs
fi
- name: Clone pcs
Expand All @@ -60,7 +69,7 @@ jobs:
run: |
set -euxo pipefail
pcs_dir="${RUNNER_TEMP}/pcs"
mkdir -p pcs_dir
mkdir -p "$pcs_dir"
cd pcs-upstream
if [ "x${{ matrix.pcs_version }}" == "xmain" ]; then
echo "0.0.1+ci" > .tarball-version
Expand Down
4 changes: 0 additions & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ variables:
- PYENV_PACKAGES="${PYENV_ROOT}/lib/python${PYTHON_VER}/site-packages"
- PCS_DIR=$(rpm -ql pcs | grep 'site-packages/pcs$')
- PCS_PYTHON_VER=$(echo "$PCS_DIR" | sed -e 's@.*/python\([0-9\.]\+\)/.*@\1@')
- PCS_EGG=$(rpm -ql pcs | grep 'site-packages/pcs.*\.egg-info$')
- PCS_EGG_NAME=$(basename "$PCS_EGG")
- if [ "x$PYTHON_VER" != "x$PCS_PYTHON_VER" ]; then ln -s "${PCS_DIR}" "${PYENV_PACKAGES}/pcs"; fi
- if [ "x$PYTHON_VER" != "x$PCS_PYTHON_VER" ]; then ln -s "${PCS_EGG}" "${PYENV_PACKAGES}/${PCS_EGG_NAME}"; fi
- if [ "x$PYTHON_VER" != "x$PCS_PYTHON_VER" ]; then pushd .; cd "${PYENV_PACKAGES}"; rename --verbose "${PCS_PYTHON_VER}" "${PYTHON_VER}" pcs-*.egg-info; popd; fi
- ls -l "$PYENV_PACKAGES"

.convert_role_to_collection: &convert_role_to_collection
Expand Down
8 changes: 8 additions & 0 deletions .sanity-ansible-ignore-2.18.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
plugins/modules/pcs_api_v2.py validate-modules:missing-gplv3-license
plugins/modules/pcs_qdevice_certs.py validate-modules:missing-gplv3-license
tests/ha_cluster/unit/test_pcs_api_v2.py shebang!skip
tests/ha_cluster/unit/test_pcs_qdevice_certs.py shebang!skip
plugins/modules/pcs_api_v2.py import-3.8!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py import-3.8!skip
plugins/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py compile-3.8!skip
plugins/modules/pcs_qdevice_certs.py import-3.8!skip
16 changes: 16 additions & 0 deletions tests/tasks/fetch_versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,19 @@
ansible_facts.packages['pacemaker'][0]['version']
}}"
__test_pcs_version: "{{ ansible_facts.packages['pcs'][0]['version'] }}"

- name: CIB schema version
when: with_cib_schema_version | d(false)
block:
- name: Discover CIB schema version
command:
cmd: >
xmllint
--xpath 'substring-after(/cib/@validate-with, "pacemaker-")'
/var/lib/pacemaker/cib/cib.xml
register: __test_cib_validate_with_xpath
changed_when: false

- name: Extract versions of cluster components
set_fact:
__test_cib_validate_with: "{{ __test_cib_validate_with_xpath.stdout }}"
34 changes: 20 additions & 14 deletions tests/tests_cib_constraints_create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -405,15 +405,8 @@

- name: Fetch cluster versions of cluster components
include_tasks: tasks/fetch_versions.yml

- name: Discover CIB schema version
command:
cmd: >
xmllint
--xpath 'substring-after(/cib/@validate-with, "pacemaker-")'
/var/lib/pacemaker/cib/cib.xml
register: __test_cib_validate_with
changed_when: false
vars:
with_cib_schema_version: true

- name: Discover role names
set_fact:
Expand All @@ -423,7 +416,12 @@
__test_new_roles_cib: "{{
__test_pcs_version is version('0.11', '>=')
and
__test_cib_validate_with.stdout is version('3.7', '>=')
__test_cib_validate_with is version('3.7', '>=')
}}"
__test_inner_rules_score: "{{
__test_cib_validate_with is version('3.9', '<')
or
__test_pcs_version is version('0.12', '<')
}}"

# yamllint disable rule:line-length
Expand Down Expand Up @@ -852,7 +850,9 @@
"in_effect": "UNKNOWN",
"options": {
"boolean-op": "or",
"score": "0"
{% if __test_inner_rules_score %}
"score": "0"
{% endif %}
},
"type": "RULE"
}
Expand Down Expand Up @@ -938,7 +938,9 @@
"in_effect": "UNKNOWN",
"options": {
"boolean-op": "or",
"score": "0"
{% if __test_inner_rules_score %}
"score": "0"
{% endif %}
},
"type": "RULE"
}
Expand Down Expand Up @@ -1235,7 +1237,9 @@
"in_effect": "UNKNOWN",
"options": {
"boolean-op": "or",
"score": "0"
{% if __test_inner_rules_score %}
"score": "0"
{% endif %}
},
"type": "RULE"
},
Expand Down Expand Up @@ -1320,7 +1324,9 @@
"in_effect": "UNKNOWN",
"options": {
"boolean-op": "or",
"score": "0"
{% if __test_inner_rules_score %}
"score": "0"
{% endif %}
},
"type": "RULE"
},
Expand Down
29 changes: 23 additions & 6 deletions tests/tests_cib_rsc_op_defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,19 @@
name: linux-system-roles.ha_cluster
public: true

- name: Fetch versions of cluster components
include_tasks: tasks/fetch_versions.yml
vars:
with_cib_schema_version: true

- name: Verify resource defaults
vars:
__test_rule_score: "{{
(
__test_cib_validate_with is version('3.9', '<')
or __test_pcs_version is version('0.12', '<')
)
| ternary(' score=INFINITY', '') }}"
__test_expected_lines:
- "Meta Attrs: rsc_defaults-meta_attributes"
- " rsc-key-1=rsc-val-1"
Expand All @@ -88,16 +99,16 @@
- " rsc-key-3=rsc-val-3"
- "Meta Attrs: rsc_defaults-meta_attributes-2"
- " rsc-key-4=rsc-val-4"
- " Rule: boolean-op=and score=INFINITY"
- " Rule: boolean-op=and{{ __test_rule_score }}"
- " Expression: resource ocf:pacemaker:"
- "Meta Attrs: without_attrs_rsc score=20"
- " Rule: boolean-op=or score=INFINITY"
- " Rule: boolean-op=or{{ __test_rule_score }}"
- " Expression: resource :pacemaker:"
- " Expression: resource :heartbeat:"
- "Meta Attrs: all_options_rsc score=INFINITY"
- " rsc-key-5=rsc-val-5"
- " rsc-key-6=rsc-val-6"
- " Rule: boolean-op=and score=INFINITY"
- " Rule: boolean-op=and{{ __test_rule_score }}"
- " Expression: resource ocf:pacemaker:test"
block:
- name: Fetch resource defaults configuration from the cluster
Expand All @@ -122,6 +133,12 @@

- name: Verify operation defaults
vars:
__test_rule_score: "{{
(
__test_cib_validate_with is version('3.9', '<')
or __test_pcs_version is version('0.12', '<')
)
| ternary(' score=INFINITY', '') }}"
__test_expected_lines:
- "Meta Attrs: op_defaults-meta_attributes"
- " op-key-1=op-val-1"
Expand All @@ -131,16 +148,16 @@
- " op-key-3=op-val-3"
- "Meta Attrs: op_defaults-meta_attributes-2"
- " op-key-4=op-val-4"
- " Rule: boolean-op=and score=INFINITY"
- " Rule: boolean-op=and{{ __test_rule_score }}"
- " Expression: resource ocf:pacemaker:"
- "Meta Attrs: without_attrs_op score=20"
- " Rule: boolean-op=or score=INFINITY"
- " Rule: boolean-op=or{{ __test_rule_score }}"
- " Expression: resource :pacemaker:"
- " Expression: op monitor"
- "Meta Attrs: all_options_op score=INFINITY"
- " op-key-5=op-val-5"
- " op-key-6=op-val-6"
- " Rule: boolean-op=and score=INFINITY"
- " Rule: boolean-op=and{{ __test_rule_score }}"
- " Expression: resource ocf:pacemaker:test"
block:
- name: Fetch operation defaults configuration from the cluster
Expand Down
74 changes: 73 additions & 1 deletion tests/tests_cib_stonith_levels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
include_tasks: tasks/fetch_versions.yml

- name: Verify stonith levels
when:
- '"pcmk.stonith.levels.config.output-formats" not in __test_pcs_capabilities'
vars:
__test_regexp_label: "{{
__test_pcs_version is version('0.10.10', '>')
Expand All @@ -79,7 +81,7 @@

- name: Print real stonith levels configuration
debug:
var: __test_pcs_stonith_level_config
var: __test_pcs_stonith_level_config.stdout_lines

- name: Print expected stonith levels configuration
debug:
Expand All @@ -91,5 +93,75 @@
- __test_pcs_stonith_level_config.stdout_lines
== __test_expected_lines | list

- name: Verify stonith levels
when:
- '"pcmk.stonith.levels.config.output-formats" in __test_pcs_capabilities'
vars:
__test_expected_lines: '
{
"target_node": [
{
"id": "fl-{{ __test_first_node }}-1",
"target": "{{ __test_first_node }}",
"index": 1,
"devices": [
"fence1"
]
}
],
"target_regex": [
{
"id": "fl-node-d-2",
"target_pattern": "node-\\d+",
"index": 2,
"devices": [
"fence2"
]
}
],
"target_attribute": [
{
"id": "fl-some-name-3",
"target_attribute": "some-name",
"target_value": "",
"index": 3,
"devices": [
"fence1",
"fence2"
]
},
{
"id": "fl-some-name-4",
"target_attribute": "some-name",
"target_value": "some-value",
"index": 4,
"devices": [
"fence2",
"fence1"
]
}
]
}'
block:
- name: Fetch stonith levels configuration from the cluster
command:
cmd: pcs --output-format=json stonith level config
register: __test_pcs_stonith_level_config
changed_when: false

- name: Print real stonith levels configuration
debug:
var: __test_pcs_stonith_level_config.stdout | from_json

- name: Print expected stonith levels configuration
debug:
var: __test_expected_lines | from_json

- name: Check stonith levels configuration
assert:
that:
- __test_pcs_stonith_level_config.stdout | from_json
== __test_expected_lines | from_json

- name: Check firewall and selinux state
include_tasks: tasks/check_firewall_selinux.yml

0 comments on commit 7e5752c

Please sign in to comment.