Skip to content
This repository has been archived by the owner on May 30, 2022. It is now read-only.

Commit

Permalink
Merge pull request #202 from brett060102/ansible-2.1
Browse files Browse the repository at this point in the history
Add 2.1.* - 2.2.* tests
  • Loading branch information
arbulu89 committed Sep 14, 2021
2 parents f443545 + 4bd8b83 commit f276785
Show file tree
Hide file tree
Showing 22 changed files with 671 additions and 6 deletions.
90 changes: 90 additions & 0 deletions runner/ansible/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,96 @@
name: '1.5.2'
when: "'1.5.2' in cluster_selected_checks"

- name: include 2.1.1
import_role:
name: '2.1.1'
when: "'2.1.1' in cluster_selected_checks"

- name: include 2.1.2
import_role:
name: '2.1.2'
when: "'2.1.2' in cluster_selected_checks"

- name: include 2.1.3
import_role:
name: '2.1.3'
when: "'2.1.3' in cluster_selected_checks"

- name: include 2.1.4
import_role:
name: '2.1.4'
when: "'2.1.4' in cluster_selected_checks"

- name: include 2.1.5
import_role:
name: '2.1.5'
when: "'2.1.5' in cluster_selected_checks"

- name: include 2.1.6
import_role:
name: '2.1.6'
when: "'2.1.6' in cluster_selected_checks"

- name: include 2.1.7
import_role:
name: '2.1.7'
when: "'2.1.7' in cluster_selected_checks"

- name: include 2.1.8
import_role:
name: '2.1.8'
when: "'2.1.8' in cluster_selected_checks"

- name: include 2.2.1
import_role:
name: '2.2.1'
when: "'2.2.1' in cluster_selected_checks"

- name: include 2.2.2
import_role:
name: '2.2.2'
when: "'2.2.2' in cluster_selected_checks"

- name: include 2.2.3
import_role:
name: '2.2.3'
when: "'2.2.3' in cluster_selected_checks"

- name: include 2.2.3.exclude
import_role:
name: '2.2.3.exclude'
when: "'2.2.3.exclude' in cluster_selected_checks"

- name: include 2.2.4
import_role:
name: '2.2.4'
when: "'2.2.4' in cluster_selected_checks"

- name: include 2.2.5
import_role:
name: '2.2.5'
when: "'2.2.5' in cluster_selected_checks"

- name: include 2.2.5.exclude
import_role:
name: '2.2.5.exclude'
when: "'2.2.5.exclude' in cluster_selected_checks"

- name: include 2.2.6
import_role:
name: '2.2.6'
when: "'2.2.6' in cluster_selected_checks"

- name: include 2.2.7
import_role:
name: '2.2.7'
when: "'2.2.7' in cluster_selected_checks"

- name: include 2.2.8
import_role:
name: '2.2.8'
when: "'2.2.8' in cluster_selected_checks"

post_tasks:
- name: Post results
import_role:
Expand Down
14 changes: 8 additions & 6 deletions runner/ansible/roles/1.4.1/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
# if no Azure Fence Agent exit, with a pass
cibadmin -Q --xpath "//primitive[@type='fence_azure_arm']/@type" > /dev/null 2>&1 || exit 0
# Check that following match expected, exit with error if any do not
[[ $(cibadmin -Q --xpath "//primitive[@type='fence_azure_arm']/instance_attributes/nvpair[@name='pcmk_monitor_retries']" | grep -oP 'value="\K[^"]+') != "{{ expected[test_id + '.pcmk_monitor_retries'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "//primitive[@type='fence_azure_arm']/instance_attributes/nvpair[@name='pcmk_action_limit']" | grep -oP 'value="\K[^"]+') != "{{ expected[test_id + '.pcmk_action_limit'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "//primitive[@type='fence_azure_arm']/instance_attributes/nvpair[@name='power_timeout']" | grep -oP 'value="\K[^"]+') != "{{ expected[test_id + '.power_timeout'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "//primitive[@type='fence_azure_arm']/instance_attributes/nvpair[@name='pcmk_reboot_timeout']" | grep -oP 'value="\K[^"]+') != "{{ expected[test_id + '.pcmk_reboot_timeout'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "//primitive[@type='fence_azure_arm']/operations/op [@name='monitor']" | grep -oP 'interval="\K[^"]+') != "{{ expected[test_id + '.monitor_interval'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "//primitive[@type='fence_azure_arm']/operations/op [@name='monitor']" | grep -oP 'timeout="\K[^"]+') != "{{ expected[test_id + '.monitor_timeout'] }}" ]] && exit 1
XPATH="//primitive[@type='fence_azure_arm']/instance_attributes/nvpair"
[[ $(cibadmin -Q --xpath "${XPATH} [@name='pcmk_monitor_retries']" | grep -oP 'value="\K[^"]+') != "{{ expected[test_id + '.pcmk_monitor_retries'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "${XPATH} [@name='pcmk_action_limit']" | grep -oP 'value="\K[^"]+') != "{{ expected[test_id + '.pcmk_action_limit'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "${XPATH} [@name='power_timeout']" | grep -oP 'value="\K[^"]+') != "{{ expected[test_id + '.power_timeout'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "${XPATH} [@name='pcmk_reboot_timeout']" | grep -oP 'value="\K[^"]+') != "{{ expected[test_id + '.pcmk_reboot_timeout'] }}" ]] && exit 1
XPATH="//primitive[@type='fence_azure_arm']/operations/op"
[[ $(cibadmin -Q --xpath "${XPATH} [@name='monitor']" | grep -oP 'interval="\K[^"]+') != "{{ expected[test_id + '.monitor_interval'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "${XPATH} [@name='monitor']" | grep -oP 'timeout="\K[^"]+') != "{{ expected[test_id + '.monitor_timeout'] }}" ]] && exit 1
exit 0
check_mode: no
register: config_updated
Expand Down
24 changes: 24 additions & 0 deletions runner/ansible/roles/2.1.1/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---

- name: Set Test ID
set_fact:
test_id: '2.1.1'

- name: "{{ test_id }}.check"
shell: |
# Check that following match expected, exit with error if any do not
[[ $(crm_attribute -t rsc_defaults -G -n resource-stickiness --quiet) != "{{ expected[test_id + '.resource_stickiness'] }}" ]] && exit 1
[[ $(crm_attribute -t rsc_defaults -G -n migration-threshold --quiet) != "{{ expected[test_id + '.migration_threshold'] }}" ]] && exit 1
exit 0
check_mode: no
register: config_updated
changed_when: config_updated.rc != 0
failed_when: config_updated.rc > 1

- block:
- import_role:
name: post-results
when:
- ansible_check_mode
vars:
status: "{{ config_updated is not changed }}"
33 changes: 33 additions & 0 deletions runner/ansible/roles/2.1.2/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---

- name: Set Test ID
set_fact:
test_id: '2.1.2'

- name: "{{ test_id }}.check"
shell: |
# SAPHanaTopology is not configured, then fail
cibadmin -Q --xpath "//primitive[@type='SAPHanaTopology']/@type" || exit 1
# if configured and not clone, then fail
cibadmin -Q --xpath "//clone/primitive[@type='SAPHanaTopology']/@type" || exit 1
# check the following values, if any do not match expected fail.
XPATH="//primitive[@type='SAPHanaTopology']/operations/op"
[[ $(cibadmin -Q --xpath "${XPATH} [@name='monitor']" | grep -oP 'interval="\K[^"]+') != "{{ expected[test_id + '.monitor_interval'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "${XPATH} [@name='monitor']" | grep -oP 'timeout="\K[^"]+') != "{{ expected[test_id + '.monitor_timeout'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "${XPATH} [@name='start']" | grep -oP 'interval="\K[^"]+') != "{{ expected[test_id + '.start_interval'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "${XPATH} [@name='start']" | grep -oP 'timeout="\K[^"]+') != "{{ expected[test_id + '.start_timeout'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "${XPATH} [@name='stop']" | grep -oP 'interval="\K[^"]+') != "{{ expected[test_id + '.stop_interval'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "${XPATH} [@name='stop']" | grep -oP 'timeout="\K[^"]+') != "{{ expected[test_id + '.stop_timeout'] }}" ]] && exit 1
exit 0
check_mode: no
register: config_updated
changed_when: config_updated.rc != 0
failed_when: config_updated.rc > 1

- block:
- import_role:
name: post-results
when:
- ansible_check_mode
vars:
status: "{{ config_updated is not changed }}"
42 changes: 42 additions & 0 deletions runner/ansible/roles/2.1.3/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---

- name: Set Test ID
set_fact:
test_id: '2.1.3'

- name: "{{ test_id }}.check"
shell: |
# SAP HANA Resource Agent is not configured, then fail
cibadmin -Q --xpath "//primitive[@type='SAPHana']/@type" || exit 1
# if configured and not msl, then fail
cibadmin -Q --xpath "//master/primitive[@type='SAPHana']/@type" || exit 1
# check the following values, if any do not match expected fail.
XPATH="//primitive[@type='SAPHana']/operations/op"
[[ $(cibadmin -Q --xpath "${XPATH} [@name='monitor'] [@role='Master']" | grep -oP 'interval="\K[^"]+') != "{{ expected[test_id + '.master_interval'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "${XPATH} [@name='monitor'] [@role='Master']" | grep -oP 'timeout="\K[^"]+') != "{{ expected[test_id + '.master_timeout'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "${XPATH} [@name='monitor'] [@role='Slave']" | grep -oP 'interval="\K[^"]+') != "{{ expected[test_id + '.slave_interval'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "${XPATH} [@name='monitor'] [@role='Slave']" | grep -oP 'timeout="\K[^"]+') != "{{ expected[test_id + '.slave_timeout'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "${XPATH} [@name='start']" | grep -oP 'interval="\K[^"]+') != "{{ expected[test_id + '.start_interval'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "${XPATH} [@name='start']" | grep -oP 'timeout="\K[^"]+') != "{{ expected[test_id + '.start_timeout'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "${XPATH} [@name='stop']" | grep -oP 'interval="\K[^"]+') != "{{ expected[test_id + '.stop_interval'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "${XPATH} [@name='stop']" | grep -oP 'timeout="\K[^"]+') != "{{ expected[test_id + '.stop_timeout'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "${XPATH} [@name='promote']" | grep -oP 'interval="\K[^"]+') != "{{ expected[test_id + '.promote_interval'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "${XPATH} [@name='promote']" | grep -oP 'timeout="\K[^"]+') != "{{ expected[test_id + '.promote_timeout'] }}" ]] && exit 1
XPATH="//primitive[@type='SAPHana']/instance_attributes/nvpair"
[[ $(cibadmin -Q --xpath "${XPATH} [@name='PREFER_SITE_TAKEOVER']" | grep -oP 'value="\K[^"]+' | tr '[:upper:]' '[:lower:]') != "{{ expected[test_id + '.nvpair_PREFER_SITE_TAKEOVER'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "${XPATH} [@name='AUTOMATED_REGISTER']" | grep -oP 'value="\K[^"]+' | tr '[:upper:]' '[:lower:]') != "{{ expected[test_id + '.nvpair_AUTOMATED_REGISTER'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "${XPATH} [@name='DUPLICATE_PRIMARY_TIMEOUT']" | grep -oP 'value="\K[^"]+') != "{{ expected[test_id + '.nvpair_DUPLICATE_PRIMARY_TIMEOUT'] }}" ]] && exit 1
exit 0
check_mode: no
register: config_updated
changed_when: config_updated.rc != 0
failed_when: config_updated.rc > 1

- block:
- import_role:
name: post-results
when:
- ansible_check_mode
vars:
status: "{{ config_updated is not changed }}"
29 changes: 29 additions & 0 deletions runner/ansible/roles/2.1.4/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---

- name: Set Test ID
set_fact:
test_id: '2.1.4'

- name: "{{ test_id }}.check"
shell: |
# if virtIP not configured, exit with fail
cibadmin -Q --xpath "//primitive[@type='IPaddr2']/@type" || exit 1
# if not grouped, exit with fail
cibadmin -Q --xpath "//group/primitive[@type='IPaddr2']/@type" || exit 1
# Check that following match expected, exit with error if any do not
XPATH="//primitive[@type='IPaddr2']/operations/op"
[[ $(cibadmin -Q --xpath "${XPATH} [@name='monitor']" | grep -oP 'interval="\K[^"]+') != "{{ expected[test_id + '.monitor_interval'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "${XPATH} [@name='monitor']" | grep -oP 'timeout="\K[^"]+') != "{{ expected[test_id + '.monitor_timeout'] }}" ]] && exit 1
exit 0
check_mode: no
register: config_updated
changed_when: config_updated.rc != 0
failed_when: config_updated.rc > 1

- block:
- import_role:
name: post-results
when:
- ansible_check_mode
vars:
status: "{{ config_updated is not changed }}"
27 changes: 27 additions & 0 deletions runner/ansible/roles/2.1.5/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---

- name: Set Test ID
set_fact:
test_id: '2.1.5'

- name: "{{ test_id }}.check"
shell: |
# if azure-lb RA is not configured, then fail
cibadmin -Q --xpath "//primitive[@type='azure-lb']/@type" || exit 1
# if not grouped, exit with fail
cibadmin -Q --xpath "//group/primitive[@type='azure-lb']/@type" || exit 1
# Check that following match expected, exit with error if any do not
[[ $(cibadmin -Q --xpath "//primitive[@type='azure-lb']/meta_attributes/nvpair [@name='resource-stickiness']" | grep -oP 'value="\K[^"]+') != "{{ expected[test_id + '.nvpair_resource_stickiness'] }}" ]] && exit 1
exit 0
check_mode: no
register: config_updated
changed_when: config_updated.rc != 0
failed_when: config_updated.rc > 1

- block:
- import_role:
name: post-results
when:
- ansible_check_mode
vars:
status: "{{ config_updated is not changed }}"
38 changes: 38 additions & 0 deletions runner/ansible/roles/2.1.6/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---

- name: Set Test ID
set_fact:
test_id: '2.1.6'

- name: "{{ test_id }}.check"
shell: |
# if rsc_colocation constraint is not configured, then fail
cibadmin -Q --xpath "//constraints/rsc_colocation" || exit 1
# if rsc_order constraint is not configured, then fail
cibadmin -Q --xpath "//constraints/rsc_order" || exit 1
# Check that following match expected, exit with error if any do not
XPATH="//constraints/rsc_colocation [contains(@id, 'col_saphana')]"
[[ $(cibadmin -Q --xpath "${XPATH}" | grep -oP ' score="\K[^"]+') != "{{ expected[test_id + '.rsc_colocation_score'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "${XPATH}" | grep -oP ' rsc="\K[^"]+' | grep -o g_ip) != "{{ expected[test_id + '.rsc_colocation_rsc'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "${XPATH}" | grep -oP ' rsc-role="\K[^"]+') != "{{ expected[test_id + '.rsc_colocation_rsc_role'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "${XPATH}" | grep -oP ' with-rsc="\K[^"]+' | grep -o msl_SAPHana) != "{{ expected[test_id + '.rsc_colocation_with_rsc'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "${XPATH}" | grep -oP ' with-rsc-role="\K[^"]+') != "{{ expected[test_id + '.rsc_colocation_with_rsc_role'] }}" ]] && exit 1
XPATH="//constraints/rsc_order [contains(@id, 'ord_SAPHana')]"
[[ $(cibadmin -Q --xpath "${XPATH}" | grep -oP ' kind="\K[^"]+') != "{{ expected[test_id + '.rsc_order_kind'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "${XPATH}" | grep -oP ' first="\K[^"]+' | grep -o cln_SAPHanaTopology) != "{{ expected[test_id + '.rsc_order_first'] }}" ]] && exit 1
[[ $(cibadmin -Q --xpath "${XPATH}" | grep -oP ' then="\K[^"]+' | grep -o msl_SAPHana) != "{{ expected[test_id + '.rsc_order_then'] }}" ]] && exit 1
exit 0
check_mode: no
register: config_updated
changed_when: config_updated.rc != 0
failed_when: config_updated.rc > 1

- block:
- import_role:
name: post-results
when:
- ansible_check_mode
vars:
status: "{{ config_updated is not changed }}"
36 changes: 36 additions & 0 deletions runner/ansible/roles/2.1.7/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---

- name: Set Test ID
set_fact:
test_id: '2.1.7'

- name: "{{ test_id }}.check"
shell: |
# if no sid, then fail
sid=$(crm configure show | grep -m1 SID= | sed -e "s/.*SID=\(...\).*/\1/")
[[ $sid == "" ]] && exit 1
# if config file does not exist, exit fail
[[ -e /usr/sap/${sid}/SYS/global/hdb/custom/config/global.ini ]] || exit 1
# get ha_dr_provider_SAPHanaSR section from config file
ha_dr_provider_SAPHanaSR=$(sed -n -e '/ha_dr_provider_SAPHanaSR\]/,/\[/ p; /trace\]/,/\[/ p' /usr/sap/${sid}/SYS/global/hdb/custom/config/global.ini)
# if following not found, fail
echo ${ha_dr_provider_SAPHanaSR} | grep "provider = {{ expected[test_id + '.provider'] }}" || exit 1
echo ${ha_dr_provider_SAPHanaSR} | grep "path = {{ expected[test_id + '.path'] }}" || exit 1
echo ${ha_dr_provider_SAPHanaSR} | grep "execution_order = {{ expected[test_id + '.execution_order'] }}" || exit 1
echo ${ha_dr_provider_SAPHanaSR} | grep "ha_dr_saphanasr = {{ expected[test_id + '.ha_dr_saphanasr'] }}" || exit 1
# if hook not found, exit with fail
share_path=$(cat /hana/shared/${sid}/global/hdb/custom/config/global.ini | grep "path =" | sed "s/.*= //")
[[ -s "$share_path/SAPHanaSR.py" ]] || exit 1
exit 0
check_mode: no
register: config_updated
changed_when: config_updated.rc != 0
failed_when: config_updated.rc > 1

- block:
- import_role:
name: post-results
when:
- ansible_check_mode
vars:
status: "{{ config_updated is not changed }}"
28 changes: 28 additions & 0 deletions runner/ansible/roles/2.1.8/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---

- name: Set Test ID
set_fact:
test_id: '2.1.8'

- name: "{{ test_id }}.check"
shell: |
# make sure sudoers is set up
grep -E "[a-z][a-z0-9]{2}adm +ALL=\(ALL\) +NOPASSWD: +/usr/sbin/crm_attribute +-n +hana_[a-z][a-z0-9]{2}_site_srHook_\*" /etc/sudoers && exit 0
grep -E "^Cmnd_Alias +SOK_SITEA += +/usr/sbin/crm_attribute" /etc/sudoers grep -E "\-n +hana_[a-z][a-z0-9]{2}_site_srHook_.+" | grep -E "\-v +SOK" | grep -E "\-t +crm_config" | grep -E "\-s +SAPHanaSR" || exit 1
grep -E "^Cmnd_Alias +SFAIL_SITEA += +/usr/sbin/crm_attribute" /etc/sudoers | grep -E "\-n +hana_[a-z][a-z0-9]{2}_site_srHook_.+" | grep -E "\-v +SFAIL" | grep -E "\-t +crm_config" | grep -E "\-s +SAPHanaSR" || exit 1
grep -E "^Cmnd_Alias +SOK_SITEB += +/usr/sbin/crm_attribute" /etc/sudoers | grep -E "\-n +hana_[a-z][a-z0-9]{2}_site_srHook_.+" | grep -E "\-v +SOK" | grep -E "\-t +crm_config" | grep -E "\-s +SAPHanaSR" || exit 1
grep -E "^Cmnd_Alias +SFAIL_SITEB += +/usr/sbin/crm_attribute" /etc/sudoers | grep -E "\-n +hana_[a-z][a-z0-9]{2}_site_srHook_.+" | grep -E "\-v +SFAIL" | grep -E "\-t +crm_config" | grep -E "\-s +SAPHanaSR" || exit 1
grep -E "[a-z][a-z0-9]{2}adm +ALL=\(ALL\) +NOPASSWD:" /etc/sudoers | sed "s/.*: //" | grep SOK_SITEA | grep SFAIL_SITEA | grep SOK_SITEB | grep SFAIL_SITEB || exit 1
exit 0
check_mode: no
register: config_updated
changed_when: config_updated.rc != 0
failed_when: config_updated.rc > 1

- block:
- import_role:
name: post-results
when:
- ansible_check_mode
vars:
status: "{{ config_updated is not changed }}"

0 comments on commit f276785

Please sign in to comment.