forked from linux-system-roles/ha_cluster
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests_cib_utilization.yml
More file actions
180 lines (162 loc) · 6.47 KB
/
tests_cib_utilization.yml
File metadata and controls
180 lines (162 loc) · 6.47 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# SPDX-License-Identifier: MIT
---
- name: Configure utilization
hosts: all
vars_files: vars/main.yml
tasks:
- name: Run test
tags:
- tests::booted
- tests::verify
block:
- name: Skip test in bootc mode
include_tasks: tasks/skip_if_bootc.yml
- name: Set up test environment
include_role:
name: linux-system-roles.ha_cluster
tasks_from: test_setup.yml
- name: Find first node name
set_fact:
__test_first_node: "{{
(ansible_play_hosts_all | length == 1)
| ternary('localhost', ansible_play_hosts[0]) }}"
- name: Run HA Cluster role
include_tasks: tasks/run_role_with_clear_facts.yml
vars:
__sr_public: true
ha_cluster_cluster_name: test-cluster
ha_cluster_manage_firewall: true
ha_cluster_manage_selinux: true
# Property placement-strategy must be set accordingly. When not set,
# there is an extra warning in the `pcs node|resource utilization`
# result.
ha_cluster_cluster_properties:
- attrs:
- name: placement-strategy
value: utilization
ha_cluster_node_options:
- node_name: "{{ __test_first_node }}"
utilization:
- attrs:
- name: cpu
value: 2
- name: memory
value: 4096
ha_cluster_resource_primitives:
- id: resource1
# wokeignore:rule=dummy
agent: 'ocf:pacemaker:Dummy'
utilization:
- attrs:
- name: cpu
value: 1
- attrs:
- name: memory
value: 1024
# Resource without utilization to ensure that they are optional.
- id: resource2
# wokeignore:rule=dummy
agent: 'ocf:pacemaker:Dummy'
- name: Fetch versions of cluster components
include_tasks: tasks/fetch_versions.yml
- name: Verify node utilization
when:
- '"node.utilization.output-formats" not in __test_pcs_capabilities'
vars:
__test_expected_lines:
- "Node Utilization:"
- " {{ __test_first_node }}: cpu=2 memory=4096"
block:
- name: Fetch node utilization configuration from the cluster
command:
cmd: pcs node utilization
register: __test_pcs_node_utilization_config
changed_when: false
- name: Print real node utilization configuration
debug:
var: __test_pcs_node_utilization_config
- name: Print expected node utilization configuration
debug:
var: __test_expected_lines | list
- name: Check node utilization configuration
assert:
that:
- __test_pcs_node_utilization_config.stdout_lines
== __test_expected_lines | list
- name: Verify node utilization
when:
- '"node.utilization.output-formats" in __test_pcs_capabilities'
vars:
# Only check the first node. The json output contains all nodes,
# but the number of nodes depends on the test environment.
__test_expected_lines: '
{
"description": null,
"id": "1",
"instance_attributes": [],
"score": null,
"type": null,
"uname": "{{ __test_first_node }}",
"utilization": [
{
"id": "nodes-1-utilization",
"nvpairs": [
{
"id": "nodes-1-utilization-cpu",
"name": "cpu",
"value": "2"
},
{
"id": "nodes-1-utilization-memory",
"name": "memory",
"value": "4096"
}
],
"options": {},
"rule": null
}
]
}'
block:
- name: Fetch node utilization configuration from the cluster
command:
cmd: pcs --output-format=json node utilization
register: __test_pcs_node_utilization_config
changed_when: false
- name: Print real node utilization configuration
debug:
var: __test_pcs_node_utilization_config.stdout | from_json
- name: Print expected node utilization configuration
debug:
var: __test_expected_lines | from_json
# yamllint disable rule:line-length
- name: Check node utilization configuration
assert:
that:
- (__test_pcs_node_utilization_config.stdout | from_json)["nodes"][0]
== __test_expected_lines | from_json
# yamllint enable rule:line-length
- name: Verify resource utilization
vars:
__test_expected_lines:
- "Resource Utilization:"
- " resource1: cpu=1"
block:
- name: Fetch resource utilization configuration from the cluster
command:
cmd: pcs resource utilization
register: __test_pcs_resource_utilization_config
changed_when: false
- name: Print real resource utilization configuration
debug:
var: __test_pcs_resource_utilization_config
- name: Print expected resource utilization configuration
debug:
var: __test_expected_lines | list
- name: Check resource utilization configuration
assert:
that:
- __test_pcs_resource_utilization_config.stdout_lines
== __test_expected_lines | list
- name: Check firewall and selinux state
include_tasks: tasks/check_firewall_selinux.yml