Debian Codegraph @

ansible_collections/community/general/tests/unit/plugins/modules/test_pacemaker_cluster.yaml

raw
1 # Copyright (c) Dexter Le ([email protected])
2 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
3 # SPDX-License-Identifier: GPL-3.0-or-later
4
5 ---
6 anchors:
7 environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: false}
8 test_cases:
9 - id: test_online_minimal_input_initial_online_all_no_maintenance
10 input:
11 state: online
12 output:
13 changed: false
14 previous_value: ' * Online: [ pc1, pc2, pc3 ]'
15 value: ' * Online: [ pc1, pc2, pc3 ]'
16 mocks:
17 run_command:
18 - command: [/testbin/pcs, cluster, status]
19 environ: *env-def
20 rc: 0
21 out: ' * Online: [ pc1, pc2, pc3 ]'
22 err: ""
23 - command: [/testbin/pcs, cluster, start, --all, --wait=300]
24 environ: *env-def
25 rc: 0
26 out: "Starting Cluster..."
27 err: ""
28 - command: [/testbin/pcs, property, config]
29 environ: *env-def
30 rc: 1
31 out: |
32 Cluster Properties: cib-bootstrap-options
33 cluster-infrastructure=corosync
34 cluster-name=hacluster
35 dc-version=2.1.9-1.fc41-7188dbf
36 have-watchdog=false
37 err: ""
38 - command: [/testbin/pcs, cluster, status]
39 environ: *env-def
40 rc: 0
41 out: ' * Online: [ pc1, pc2, pc3 ]'
42 err: ""
43 - id: test_online_minimal_input_initial_offline_all_maintenance
44 input:
45 state: online
46 output:
47 changed: true
48 previous_value: 'Error: cluster is not currently running on this node'
49 value: ' * Online: [ pc1, pc2, pc3 ]'
50 mocks:
51 run_command:
52 - command: [/testbin/pcs, cluster, status]
53 environ: *env-def
54 rc: 1
55 out: 'Error: cluster is not currently running on this node'
56 err: ""
57 - command: [/testbin/pcs, cluster, start, --all, --wait=300]
58 environ: *env-def
59 rc: 0
60 out: "Starting Cluster..."
61 err: ""
62 - command: [/testbin/pcs, property, config]
63 environ: *env-def
64 rc: 0
65 out: |
66 Cluster Properties: cib-bootstrap-options
67 cluster-infrastructure=corosync
68 cluster-name=hacluster
69 dc-version=2.1.9-1.fc41-7188dbf
70 have-watchdog=false
71 maintenance-mode=true
72 err: ""
73 - command: [/testbin/pcs, property, set, maintenance-mode=false]
74 environ: *env-def
75 rc: 0
76 out: ""
77 err: ""
78 - command: [/testbin/pcs, cluster, status]
79 environ: *env-def
80 rc: 0
81 out: ' * Online: [ pc1, pc2, pc3 ]'
82 err: ""
83 - id: test_online_minimal_input_initial_offline_single_nonlocal_no_maintenance
84 input:
85 state: online
86 name: pc2
87 output:
88 changed: true
89 previous_value: '* Node pc2: UNCLEAN (offline)\n * Online: [ pc1, pc3 ]'
90 value: ' * Online: [ pc1, pc2, pc3 ]'
91 mocks:
92 run_command:
93 - command: [/testbin/pcs, cluster, status]
94 environ: *env-def
95 rc: 0
96 out: '* Node pc2: UNCLEAN (offline)\n * Online: [ pc1, pc3 ]'
97 err: ""
98 - command: [/testbin/pcs, cluster, start, pc2, --wait=300]
99 environ: *env-def
100 rc: 0
101 out: "Starting Cluster..."
102 err: ""
103 - command: [/testbin/pcs, property, config]
104 environ: *env-def
105 rc: 1
106 out: |
107 Cluster Properties: cib-bootstrap-options
108 cluster-infrastructure=corosync
109 cluster-name=hacluster
110 dc-version=2.1.9-1.fc41-7188dbf
111 have-watchdog=false
112 err: ""
113 - command: [/testbin/pcs, cluster, status]
114 environ: *env-def
115 rc: 0
116 out: ' * Online: [ pc1, pc2, pc3 ]'
117 err: ""
118 - id: test_online_minimal_input_initial_offline_single_local_no_maintenance
119 input:
120 state: online
121 name: pc1
122 output:
123 changed: true
124 previous_value: 'Error: cluster is not currently running on this node'
125 value: ' * Online: [ pc1, pc2, pc3 ]'
126 mocks:
127 run_command:
128 - command: [/testbin/pcs, cluster, status]
129 environ: *env-def
130 rc: 1
131 out: 'Error: cluster is not currently running on this node'
132 err: ""
133 - command: [/testbin/pcs, cluster, start, pc1, --wait=300]
134 environ: *env-def
135 rc: 0
136 out: "Starting Cluster..."
137 err: ""
138 - command: [/testbin/pcs, property, config]
139 environ: *env-def
140 rc: 1
141 out: |
142 Cluster Properties: cib-bootstrap-options
143 cluster-infrastructure=corosync
144 cluster-name=hacluster
145 dc-version=2.1.9-1.fc41-7188dbf
146 have-watchdog=false
147 err: ""
148 - command: [/testbin/pcs, cluster, status]
149 environ: *env-def
150 rc: 0
151 out: ' * Online: [ pc1, pc2, pc3 ]'
152 err: ""
153 - id: test_offline_minimal_input_initial_online_all
154 input:
155 state: offline
156 output:
157 changed: true
158 previous_value: ' * Online: [ pc1, pc2, pc3 ]'
159 value: 'Error: cluster is not currently running on this node'
160 mocks:
161 run_command:
162 - command: [/testbin/pcs, cluster, status]
163 environ: *env-def
164 rc: 0
165 out: ' * Online: [ pc1, pc2, pc3 ]'
166 err: ""
167 - command: [/testbin/pcs, cluster, stop, --all, --wait=300]
168 environ: *env-def
169 rc: 0
170 out: "Stopping Cluster..."
171 err: ""
172 - command: [/testbin/pcs, cluster, status]
173 environ: *env-def
174 rc: 1
175 out: 'Error: cluster is not currently running on this node'
176 err: ""
177 - id: test_offline_minimal_input_initial_offline_all
178 input:
179 state: offline
180 output:
181 changed: false
182 previous_value: 'Error: cluster is not currently running on this node'
183 value: 'Error: cluster is not currently running on this node'
184 mocks:
185 run_command:
186 - command: [/testbin/pcs, cluster, status]
187 environ: *env-def
188 rc: 1
189 out: 'Error: cluster is not currently running on this node'
190 err: ""
191 - command: [/testbin/pcs, cluster, stop, --all, --wait=300]
192 environ: *env-def
193 rc: 0
194 out: "Stopping Cluster..."
195 err: ""
196 - command: [/testbin/pcs, cluster, status]
197 environ: *env-def
198 rc: 1
199 out: 'Error: cluster is not currently running on this node'
200 err: ""
201 - id: test_offline_minimal_input_initial_offline_single_nonlocal
202 input:
203 state: offline
204 name: pc3
205 output:
206 changed: true
207 previous_value: '* Node pc2: UNCLEAN (offline)\n * Online: [ pc1, pc3 ]'
208 value: '* Node pc2: UNCLEAN (offline)\n* Node pc3: UNCLEAN (offline)\n * Online: [ pc1 ]'
209 mocks:
210 run_command:
211 - command: [/testbin/pcs, cluster, status]
212 environ: *env-def
213 rc: 0
214 out: '* Node pc2: UNCLEAN (offline)\n * Online: [ pc1, pc3 ]'
215 err: ""
216 - command: [/testbin/pcs, cluster, stop, pc3, --wait=300]
217 environ: *env-def
218 rc: 0
219 out: "Stopping Cluster..."
220 err: ""
221 - command: [/testbin/pcs, cluster, status]
222 environ: *env-def
223 rc: 0
224 out: '* Node pc2: UNCLEAN (offline)\n* Node pc3: UNCLEAN (offline)\n * Online: [ pc1 ]'
225 err: ""
226 - id: test_restart_minimal_input_initial_online_all_no_maintenance
227 input:
228 state: restart
229 output:
230 changed: false
231 previous_value: ' * Online: [ pc1, pc2, pc3 ]'
232 value: ' * Online: [ pc1, pc2, pc3 ]'
233 mocks:
234 run_command:
235 - command: [/testbin/pcs, cluster, status]
236 environ: *env-def
237 rc: 0
238 out: ' * Online: [ pc1, pc2, pc3 ]'
239 err: ""
240 - command: [/testbin/pcs, cluster, stop, --all, --wait=300]
241 environ: *env-def
242 rc: 0
243 out: "Stopping Cluster..."
244 err: ""
245 - command: [/testbin/pcs, cluster, start, --all, --wait=300]
246 environ: *env-def
247 rc: 0
248 out: "Starting Cluster..."
249 err: ""
250 - command: [/testbin/pcs, property, config]
251 environ: *env-def
252 rc: 1
253 out: |
254 Cluster Properties: cib-bootstrap-options
255 cluster-infrastructure=corosync
256 cluster-name=hacluster
257 dc-version=2.1.9-1.fc41-7188dbf
258 have-watchdog=false
259 err: ""
260 - command: [/testbin/pcs, cluster, status]
261 environ: *env-def
262 rc: 0
263 out: ' * Online: [ pc1, pc2, pc3 ]'
264 err: ""
265 - id: test_restart_minimal_input_initial_offline_all_no_maintenance
266 input:
267 state: restart
268 output:
269 changed: true
270 previous_value: 'Error: cluster is not currently running on this node'
271 value: ' * Online: [ pc1, pc2, pc3 ]'
272 mocks:
273 run_command:
274 - command: [/testbin/pcs, cluster, status]
275 environ: *env-def
276 rc: 1
277 out: 'Error: cluster is not currently running on this node'
278 err: ""
279 - command: [/testbin/pcs, cluster, stop, --all, --wait=300]
280 environ: *env-def
281 rc: 0
282 out: "Stopping Cluster..."
283 err: ""
284 - command: [/testbin/pcs, cluster, start, --all, --wait=300]
285 environ: *env-def
286 rc: 0
287 out: "Starting Cluster..."
288 err: ""
289 - command: [/testbin/pcs, property, config]
290 environ: *env-def
291 rc: 1
292 out: |
293 Cluster Properties: cib-bootstrap-options
294 cluster-infrastructure=corosync
295 cluster-name=hacluster
296 dc-version=2.1.9-1.fc41-7188dbf
297 have-watchdog=false
298 err: ""
299 - command: [/testbin/pcs, cluster, status]
300 environ: *env-def
301 rc: 0
302 out: ' * Online: [ pc1, pc2, pc3 ]'
303 err: ""
304 - id: test_restart_minimal_input_initial_offline_all_maintenance
305 input:
306 state: restart
307 output:
308 changed: true
309 previous_value: 'Error: cluster is not currently running on this node'
310 value: ' * Online: [ pc1, pc2, pc3 ]'
311 mocks:
312 run_command:
313 - command: [/testbin/pcs, cluster, status]
314 environ: *env-def
315 rc: 1
316 out: 'Error: cluster is not currently running on this node'
317 err: ""
318 - command: [/testbin/pcs, cluster, stop, --all, --wait=300]
319 environ: *env-def
320 rc: 0
321 out: "Stopping Cluster..."
322 err: ""
323 - command: [/testbin/pcs, cluster, start, --all, --wait=300]
324 environ: *env-def
325 rc: 0
326 out: "Starting Cluster..."
327 err: ""
328 - command: [/testbin/pcs, property, config]
329 environ: *env-def
330 rc: 0
331 out: |
332 Cluster Properties: cib-bootstrap-options
333 cluster-infrastructure=corosync
334 cluster-name=hacluster
335 dc-version=2.1.9-1.fc41-7188dbf
336 have-watchdog=false
337 maintenance-mode=true
338 err: ""
339 - command: [/testbin/pcs, property, set, maintenance-mode=false]
340 environ: *env-def
341 rc: 0
342 out: ""
343 err: ""
344 - command: [/testbin/pcs, cluster, status]
345 environ: *env-def
346 rc: 0
347 out: ' * Online: [ pc1, pc2, pc3 ]'
348 err: ""
349 - id: test_maintenance_minimal_input_initial_online
350 input:
351 state: maintenance
352 output:
353 changed: true
354 previous_value: 'maintenance-mode=false (default)'
355 value: 'maintenance-mode=true'
356 mocks:
357 run_command:
358 - command: [/testbin/pcs, property, config, maintenance-mode]
359 environ: *env-def
360 rc: 0
361 out: 'maintenance-mode=false (default)'
362 err: ""
363 - command: [/testbin/pcs, property, set, maintenance-mode=true]
364 environ: *env-def
365 rc: 0
366 out: ""
367 err: ""
368 - command: [/testbin/pcs, property, config, maintenance-mode]
369 environ: *env-def
370 rc: 0
371 out: 'maintenance-mode=true'
372 err: ""
373 - id: test_maintenance_minimal_input_initial_online_version_change
374 input:
375 state: maintenance
376 output:
377 changed: true
378 previous_value: 'maintenance-mode: false'
379 value: 'maintenance-mode: true'
380 mocks:
381 run_command:
382 - command: [/testbin/pcs, property, config, maintenance-mode]
383 environ: *env-def
384 rc: 0
385 out: 'maintenance-mode: false'
386 err: ""
387 - command: [/testbin/pcs, property, set, maintenance-mode=true]
388 environ: *env-def
389 rc: 0
390 out: ""
391 err: ""
392 - command: [/testbin/pcs, property, config, maintenance-mode]
393 environ: *env-def
394 rc: 0
395 out: 'maintenance-mode: true'
396 err: ""
397 - id: test_maintenance_minimal_input_initial_offline
398 input:
399 state: maintenance
400 output:
401 failed: true
402 msg: "pcs failed with error (rc=1): Error: unable to get cib"
403 mocks:
404 run_command:
405 - command: [/testbin/pcs, property, config, maintenance-mode]
406 environ: *env-def
407 rc: 1
408 out: ""
409 err: "Error: unable to get cib"
410 - command: [/testbin/pcs, property, set, maintenance-mode=true]
411 environ: *env-def
412 rc: 1
413 out: ""
414 err: "Error: unable to get cib"
415 - id: test_maintenance_minimal_input_initial_maintenance
416 input:
417 state: maintenance
418 output:
419 changed: false
420 previous_value: 'maintenance-mode=true'
421 value: 'maintenance-mode=true'
422 mocks:
423 run_command:
424 - command: [/testbin/pcs, property, config, maintenance-mode]
425 environ: *env-def
426 rc: 0
427 out: 'maintenance-mode=true'
428 err: ""
429 - command: [/testbin/pcs, property, set, maintenance-mode=true]
430 environ: *env-def
431 rc: 0
432 out: ""
433 err: ""
434 - command: [/testbin/pcs, property, config, maintenance-mode]
435 environ: *env-def
436 rc: 0
437 out: 'maintenance-mode=true'
438 err: ""
439 - id: test_cleanup_minimal_input_initial_resources_not_exist
440 input:
441 state: cleanup
442 output:
443 changed: false
444 previous_value: "NO resources configured"
445 value: "NO resources configured"
446 mocks:
447 run_command:
448 - command: [/testbin/pcs, resource, status]
449 environ: *env-def
450 rc: 0
451 out: "NO resources configured"
452 err: ""
453 - command: [/testbin/pcs, resource, cleanup]
454 environ: *env-def
455 rc: 0
456 out: "Cleaned up all resources on all nodes"
457 err: ""
458 - command: [/testbin/pcs, resource, status]
459 environ: *env-def
460 rc: 0
461 out: "NO resources configured"
462 err: ""
463 - id: test_cleanup_minimal_input_initial_resources_exists
464 input:
465 state: cleanup
466 output:
467 changed: true
468 previous_value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
469 value: "NO resources configured"
470 mocks:
471 run_command:
472 - command: [/testbin/pcs, resource, status]
473 environ: *env-def
474 rc: 0
475 out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
476 err: ""
477 - command: [/testbin/pcs, resource, cleanup]
478 environ: *env-def
479 rc: 0
480 out: "Cleaned up all resources on all nodes"
481 err: ""
482 - command: [/testbin/pcs, resource, status]
483 environ: *env-def
484 rc: 0
485 out: "NO resources configured"
486 err: ""
487 - id: test_cleanup_specific_minimal_input_initial_resources_exists
488 input:
489 state: cleanup
490 name: virtual-ip
491 output:
492 changed: true
493 previous_value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
494 value: "NO resources configured"
495 mocks:
496 run_command:
497 - command: [/testbin/pcs, resource, status, virtual-ip]
498 environ: *env-def
499 rc: 0
500 out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
501 err: ""
502 - command: [/testbin/pcs, resource, cleanup, virtual-ip]
503 environ: *env-def
504 rc: 0
505 out: "Cleaned up virtual-ip on X"
506 err: ""
507 - command: [/testbin/pcs, resource, status, virtual-ip]
508 environ: *env-def
509 rc: 0
510 out: "NO resources configured"
511 err: ""