forked from Azure/sap-automation-qa
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsecondary-block-network.yml
More file actions
155 lines (139 loc) · 10.3 KB
/
secondary-block-network.yml
File metadata and controls
155 lines (139 loc) · 10.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# /*---------------------------------------------------------------------------
# | Block Network Communication From Secondary Site |
# +--------------------------------------------------------------------------*/
- name: "Test Setup Tasks"
ansible.builtin.include_tasks: "roles/misc/tasks/test-case-setup.yml"
run_once: true
# /*---------------------------------------------------------------------------
# | Pre Validations |
# +--------------------------------------------------------------------------*/
- name: "Pre Validations: HANA DB Nodes"
ansible.builtin.include_tasks: "roles/misc/tasks/pre-validations-db.yml"
# /*---------------------------------------------------------------------------
# | Test Execution |
# +--------------------------------------------------------------------------*/
- name: "Test Execution: Block Network Communication From Secondary Master"
become: true
when:
- node_tier == "hana"
- pre_validations_status == "PASSED"
- hana_topology == 'scale_out_hsr'
- cluster_status_pre.stonith_action == "reboot"
- ansible_hostname == primary_master_node
block:
- name: "Test Execution: Start timer on primary master"
ansible.builtin.set_fact:
test_execution_start: "{{ now(utc=true, fmt='%Y-%m-%d %H:%M:%S') }}"
test_execution_hostname: "{{ hostvars[secondary_master_node].ansible_hostname }}"
- name: "Test Execution: Block all network communication on secondary site"
become: true
ansible.builtin.shell: "sleep 3; iptables -P INPUT DROP; iptables -P OUTPUT DROP"
async: 15
poll: 0
register: firewall_rule_created
delegate_to: "{{ secondary_node }}"
loop: "{{ cluster_status_pre.secondary_site_nodes }}"
loop_control:
loop_var: secondary_node
ignore_unreachable: true
- name: "Test Execution: Wait for the cluster to be in a stable state"
ansible.builtin.wait_for:
timeout: "{{ default_timeout }}"
- name: "Test Execution: Validate HANA DB cluster status during partition"
get_cluster_status_db:
db_instance_number: "{{ db_instance_number }}"
operation_step: "test_execution"
database_sid: "{{ db_sid | lower }}"
saphanasr_provider: "{{ saphanasr_provider | default('SAPHanaSR') }}"
hana_clone_resource_name: "{{ hana_clone_resource_name | default('') }}"
hana_primitive_resource_name: "{{ hana_primitive_resource_name | default('') }}"
hana_topology: "{{ hana_topology | default('scale_up') }}"
register: cluster_status_test_execution
retries: "{{ default_retries }}"
delay: "{{ default_delay }}"
until: >
cluster_status_test_execution.primary_node != "" and
cluster_status_test_execution.primary_node in cluster_status_pre.primary_site_nodes and
cluster_status_test_execution.secondary_node == ""
- name: "Test Execution: Wait for the cluster to be in a stable state"
ansible.builtin.wait_for:
timeout: "{{ default_timeout }}"
- name: "Test Execution: Validate HANA DB cluster status (post recovery)"
get_cluster_status_db:
db_instance_number: "{{ db_instance_number }}"
operation_step: "post_failover"
database_sid: "{{ db_sid | lower }}"
saphanasr_provider: "{{ saphanasr_provider | default('SAPHanaSR') }}"
hana_clone_resource_name: "{{ hana_clone_resource_name | default('') }}"
hana_primitive_resource_name: "{{ hana_primitive_resource_name | default('') }}"
hana_topology: "{{ hana_topology | default('scale_up') }}"
register: cluster_status_post
retries: "{{ default_retries }}"
delay: "{{ default_delay }}"
until: >
cluster_status_post.primary_node != "" and
cluster_status_post.secondary_node != "" and
cluster_status_post.primary_node in cluster_status_pre.primary_site_nodes and
cluster_status_post.secondary_node in cluster_status_pre.secondary_site_nodes
- name: "Test Execution: Stop timer"
ansible.builtin.set_fact:
test_execution_end: "{{ now(utc=true, fmt='%Y-%m-%d %H:%M:%S') }}"
- name: "Test Execution: Determine test execution status"
ansible.builtin.set_fact:
test_execution_status: "{{ 'PASSED' if (
cluster_status_post.primary_node in cluster_status_pre.primary_site_nodes and
cluster_status_post.secondary_node in cluster_status_pre.secondary_site_nodes
) else 'FAILED' }}"
- name: "Set test case message and details"
ansible.builtin.set_fact:
test_case_message_from_test_case: |
Source node: {{ secondary_master_node }}
Primary after recovery: {{ cluster_status_post.primary_node }}
Secondary after recovery: {{ cluster_status_post.secondary_node }}
test_case_details_from_test_case: {
"Pre Validations: Remove any location_constraints": "{{ location_constraints_results }}",
"Pre Validations: Validate HANA DB cluster status": "{{ cluster_status_pre }}",
"Pre Validations: CleanUp any failed resource": "{{ cleanup_failed_resource_pre }}",
"Test Execution: Network blocked on secondary site": "{{ firewall_rule_created | default('iptables -P DROP applied') }}",
"Test Execution: Cluster Status during partition": "{{ cluster_status_test_execution }}",
"Test Execution: Firewall removed by": "Secondary site nodes rebooted by fencing",
"Post Validations: Validate HANA DB cluster status": "{{ cluster_status_post }}",
}
# /*---------------------------------------------------------------------------
# | Post Validations |
# +--------------------------------------------------------------------------*/
- name: "Post Validations Tasks"
ansible.builtin.include_tasks: "roles/misc/tasks/post-validations.yml"
rescue:
- name: "Test Execution Failure: Reset iptables policies on secondary site nodes"
become: true
ansible.builtin.shell: "iptables -P INPUT ACCEPT; iptables -P OUTPUT ACCEPT"
register: firewall_rule_deleted
changed_when: firewall_rule_deleted.rc == 0
failed_when: false
ignore_unreachable: true
loop: "{{ cluster_status_pre.secondary_site_nodes }}"
delegate_to: "{{ item }}"
- name: "Rescue operation"
ansible.builtin.include_tasks: "roles/misc/tasks/rescue.yml"
- name: "Pre Validations: Test Case Skipped"
become: true
when: >
pre_validations_status == "FAILED" or
hana_topology != 'scale_out_hsr'
block:
- name: "Set test case message and details"
ansible.builtin.set_fact:
test_case_message_from_test_case: >-
Pre Validations for the scale-out secondary block-network
test failed. Please check the details.
test_case_details_from_test_case: {
"Pre Validations: Remove any location_constraints": "{{ location_constraints_results }}",
"Pre Validations: Validate HANA DB cluster status": "{{ cluster_status_pre }}",
"Pre Validations: CleanUp any failed resource": "{{ cleanup_failed_resource_pre }}",
"Cluster Status": "{{ cluster_status_pre }}",
}
- name: "Post Validations Tasks"
ansible.builtin.include_tasks: "roles/misc/tasks/post-validations.yml"