Debian Codegraph @

ansible_collections/community/general/tests/unit/plugins/modules/test_pacemaker_resource.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_missing_input
10 input: {}
11 output:
12 failed: true
13 msg: "state is present but all of the following are missing: resource_type, name"
14 - id: test_present_minimal_input_resource_not_exist
15 input:
16 state: present
17 name: virtual-ip
18 resource_type:
19 resource_name: IPaddr2
20 resource_option:
21 - "ip=[192.168.2.1]"
22 output:
23 changed: true
24 previous_value: null
25 value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
26 mocks:
27 run_command:
28 - command: [/testbin/pcs, resource, status, virtual-ip]
29 environ: *env-def
30 rc: 1
31 out: ""
32 err: "Error: resource or tag id 'virtual-ip' not found"
33 - command: [/testbin/pcs, property, config]
34 environ: *env-def
35 rc: 1
36 out: |
37 Cluster Properties: cib-bootstrap-options
38 cluster-infrastructure=corosync
39 cluster-name=hacluster
40 dc-version=2.1.9-1.fc41-7188dbf
41 have-watchdog=false
42 err: ""
43 - command: [/testbin/pcs, resource, create, virtual-ip, IPaddr2, "ip=[192.168.2.1]"]
44 environ: *env-def
45 rc: 0
46 out: "Assumed agent name 'ocf:heartbeat:IPaddr2' (deduced from 'IPAddr2')"
47 err: ""
48 - command: [/testbin/pcs, property, config]
49 environ: *env-def
50 rc: 1
51 out: |
52 Cluster Properties: cib-bootstrap-options
53 cluster-infrastructure=corosync
54 cluster-name=hacluster
55 dc-version=2.1.9-1.fc41-7188dbf
56 have-watchdog=false
57 err: ""
58 - command: [/testbin/pcs, resource, status, virtual-ip]
59 environ: *env-def
60 rc: 0
61 out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
62 err: ""
63 - command: [/testbin/pcs, resource, status, virtual-ip]
64 environ: *env-def
65 rc: 0
66 out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
67 err: ""
68 - id: test_present_filled_input_resource_not_exist
69 input:
70 state: present
71 name: virtual-ip
72 resource_type:
73 resource_name: IPaddr2
74 resource_standard: ocf
75 resource_provider: heartbeat
76 resource_option:
77 - "ip=[192.168.2.1]"
78 resource_operation:
79 - operation_action: start
80 operation_option:
81 - timeout=1200
82 - operation_action: stop
83 operation_option:
84 - timeout=1200
85 - operation_action: monitor
86 operation_option:
87 - timeout=1200
88 resource_meta:
89 - test_meta1=123
90 - test_meta2=456
91 resource_argument:
92 argument_action: group
93 argument_option:
94 - test_group
95 resource_clone_ids:
96 - test_clone
97 resource_clone_meta:
98 - test_clone_meta1=789
99 wait: 200
100 output:
101 changed: true
102 previous_value: null
103 value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
104 mocks:
105 run_command:
106 - command: [/testbin/pcs, resource, status, virtual-ip]
107 environ: *env-def
108 rc: 1
109 out: ""
110 err: "Error: resource or tag id 'virtual-ip' not found"
111 - command: [/testbin/pcs, property, config]
112 environ: *env-def
113 rc: 1
114 out: |
115 Cluster Properties: cib-bootstrap-options
116 cluster-infrastructure=corosync
117 cluster-name=hacluster
118 dc-version=2.1.9-1.fc41-7188dbf
119 have-watchdog=false
120 err: ""
121 - command: [/testbin/pcs, resource, create, virtual-ip, ocf:heartbeat:IPaddr2, "ip=[192.168.2.1]", op, start, timeout=1200, op, stop, timeout=1200, op, monitor, timeout=1200, meta, test_meta1=123, meta, test_meta2=456, --group, test_group, clone, test_clone, test_clone_meta1=789]
122 environ: *env-def
123 rc: 0
124 out: "Assumed agent name 'ocf:heartbeat:IPaddr2'"
125 err: ""
126 - command: [/testbin/pcs, property, config]
127 environ: *env-def
128 rc: 1
129 out: |
130 Cluster Properties: cib-bootstrap-options
131 cluster-infrastructure=corosync
132 cluster-name=hacluster
133 dc-version=2.1.9-1.fc41-7188dbf
134 have-watchdog=false
135 err: ""
136 - command: [/testbin/pcs, resource, status, virtual-ip]
137 environ: *env-def
138 rc: 0
139 out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
140 err: ""
141 - command: [/testbin/pcs, resource, status, virtual-ip]
142 environ: *env-def
143 rc: 0
144 out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
145 err: ""
146 - id: test_present_minimal_input_resource_exists
147 input:
148 state: present
149 name: virtual-ip
150 resource_type:
151 resource_name: IPaddr2
152 resource_option:
153 - "ip=[192.168.2.1]"
154 output:
155 changed: false
156 previous_value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
157 value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
158 mocks:
159 run_command:
160 - command: [/testbin/pcs, resource, status, virtual-ip]
161 environ: *env-def
162 rc: 0
163 out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
164 err: ""
165 - command: [/testbin/pcs, property, config]
166 environ: *env-def
167 rc: 1
168 out: |
169 Cluster Properties: cib-bootstrap-options
170 cluster-infrastructure=corosync
171 cluster-name=hacluster
172 dc-version=2.1.9-1.fc41-7188dbf
173 have-watchdog=false
174 err: ""
175 - command: [/testbin/pcs, resource, create, virtual-ip, IPaddr2, "ip=[192.168.2.1]"]
176 environ: *env-def
177 rc: 1
178 out: ""
179 err: "Error: 'virtual-ip' already exists\n"
180 - command: [/testbin/pcs, property, config]
181 environ: *env-def
182 rc: 1
183 out: |
184 Cluster Properties: cib-bootstrap-options
185 cluster-infrastructure=corosync
186 cluster-name=hacluster
187 dc-version=2.1.9-1.fc41-7188dbf
188 have-watchdog=false
189 err: ""
190 - command: [/testbin/pcs, resource, status, virtual-ip]
191 environ: *env-def
192 rc: 0
193 out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
194 err: ""
195 - command: [/testbin/pcs, resource, status, virtual-ip]
196 environ: *env-def
197 rc: 0
198 out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
199 err: ""
200 - id: test_present_minimal_input_resource_maintenance_mode
201 input:
202 state: present
203 name: virtual-ip
204 resource_type:
205 resource_name: IPaddr2
206 resource_option:
207 - "ip=[192.168.2.1]"
208 output:
209 changed: true
210 previous_value: null
211 value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Stopped"
212 mocks:
213 run_command:
214 - command: [/testbin/pcs, resource, status, virtual-ip]
215 environ: *env-def
216 rc: 1
217 out: ""
218 err: ""
219 - command: [/testbin/pcs, property, config]
220 environ: *env-def
221 rc: 0
222 out: |
223 Cluster Properties: cib-bootstrap-options
224 cluster-infrastructure=corosync
225 cluster-name=hacluster
226 dc-version=2.1.9-1.fc41-7188dbf
227 have-watchdog=false
228 maintenance-mode=true
229 err: ""
230 - command: [/testbin/pcs, resource, create, virtual-ip, IPaddr2, "ip=[192.168.2.1]"]
231 environ: *env-def
232 rc: 0
233 out: ""
234 err: ""
235 - command: [/testbin/pcs, property, config]
236 environ: *env-def
237 rc: 0
238 out: |
239 Cluster Properties: cib-bootstrap-options
240 cluster-infrastructure=corosync
241 cluster-name=hacluster
242 dc-version=2.1.9-1.fc41-7188dbf
243 have-watchdog=false
244 maintenance-mode=true
245 err: ""
246 - command: [/testbin/pcs, resource, status, virtual-ip]
247 environ: *env-def
248 rc: 0
249 out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Stopped"
250 err: ""
251 - id: test_present_minimal_input_resource_maintenance_mode_version_change
252 input:
253 state: present
254 name: virtual-ip
255 resource_type:
256 resource_name: IPaddr2
257 resource_option:
258 - "ip=[192.168.2.1]"
259 output:
260 changed: true
261 previous_value: null
262 value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Stopped"
263 mocks:
264 run_command:
265 - command: [/testbin/pcs, resource, status, virtual-ip]
266 environ: *env-def
267 rc: 1
268 out: ""
269 err: ""
270 - command: [/testbin/pcs, property, config]
271 environ: *env-def
272 rc: 0
273 out: |
274 Cluster Properties: cib-bootstrap-options
275 cluster-infrastructure: corosync
276 cluster-name: hacluster
277 dc-version: 2.1.9-1.fc41-7188dbf
278 have-watchdog: false
279 maintenance-mode: true
280 err: ""
281 - command: [/testbin/pcs, resource, create, virtual-ip, IPaddr2, "ip=[192.168.2.1]"]
282 environ: *env-def
283 rc: 0
284 out: ""
285 err: ""
286 - command: [/testbin/pcs, property, config]
287 environ: *env-def
288 rc: 0
289 out: |
290 Cluster Properties: cib-bootstrap-options
291 cluster-infrastructure: corosync
292 cluster-name: hacluster
293 dc-version: 2.1.9-1.fc41-7188dbf
294 have-watchdog: false
295 maintenance-mode: true
296 err: ""
297 - command: [/testbin/pcs, resource, status, virtual-ip]
298 environ: *env-def
299 rc: 0
300 out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Stopped"
301 err: ""
302 - id: test_absent_minimal_input_resource_not_exist
303 input:
304 state: absent
305 name: virtual-ip
306 output:
307 changed: false
308 previous_value: null
309 value: null
310 mocks:
311 run_command:
312 - command: [/testbin/pcs, resource, status, virtual-ip]
313 environ: *env-def
314 rc: 1
315 out: ""
316 err: "Error: resource or tag id 'virtual-ip' not found"
317 - command: [/testbin/pcs, property, config]
318 environ: *env-def
319 rc: 1
320 out: |
321 Cluster Properties: cib-bootstrap-options
322 cluster-infrastructure=corosync
323 cluster-name=hacluster
324 dc-version=2.1.9-1.fc41-7188dbf
325 have-watchdog=false
326 err: ""
327 - command: [/testbin/pcs, resource, remove, virtual-ip]
328 environ: *env-def
329 rc: 1
330 out: ""
331 err: "Error: Resource 'virtual-ip' does not exist.\n"
332 - command: [/testbin/pcs, resource, status, virtual-ip]
333 environ: *env-def
334 rc: 1
335 out: ""
336 err: "Error: resource or tag id 'virtual-ip' not found"
337 - id: test_absent_minimal_input_resource_exists
338 input:
339 state: absent
340 name: virtual-ip
341 output:
342 changed: true
343 previous_value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
344 value: null
345 mocks:
346 run_command:
347 - command: [/testbin/pcs, resource, status, virtual-ip]
348 environ: *env-def
349 rc: 0
350 out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
351 err: ""
352 - command: [/testbin/pcs, property, config]
353 environ: *env-def
354 rc: 1
355 out: |
356 Cluster Properties: cib-bootstrap-options
357 cluster-infrastructure=corosync
358 cluster-name=hacluster
359 dc-version=2.1.9-1.fc41-7188dbf
360 have-watchdog=false
361 err: ""
362 - command: [/testbin/pcs, resource, remove, virtual-ip]
363 environ: *env-def
364 rc: 0
365 out: ""
366 err: "Attempting to stop: virtual-ip... Stopped\n"
367 - command: [/testbin/pcs, resource, status, virtual-ip]
368 environ: *env-def
369 rc: 1
370 out: ""
371 err: "Error: resource or tag id 'virtual-ip' not found"
372 - id: test_absent_minimal_input_maintenance_mode
373 input:
374 state: absent
375 name: virtual-ip
376 output:
377 changed: true
378 previous_value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
379 value: null
380 mocks:
381 run_command:
382 - command: [/testbin/pcs, resource, status, virtual-ip]
383 environ: *env-def
384 rc: 0
385 out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
386 err: ""
387 - command: [/testbin/pcs, property, config]
388 environ: *env-def
389 rc: 0
390 out: |
391 Cluster Properties: cib-bootstrap-options
392 cluster-infrastructure=corosync
393 cluster-name=hacluster
394 dc-version=2.1.9-1.fc41-7188dbf
395 have-watchdog=false
396 maintenance-mode=true
397 err: ""
398 - command: [/testbin/pcs, resource, remove, virtual-ip, --force]
399 environ: *env-def
400 rc: 0
401 out: ""
402 err: "Deleting Resource (and group) - virtual-ip"
403 - command: [/testbin/pcs, resource, status, virtual-ip]
404 environ: *env-def
405 rc: 1
406 out: ""
407 err: "Error: resource or tag id 'virtual-ip' not found"
408 - id: test_enabled_minimal_input_resource_not_exists
409 input:
410 state: enabled
411 name: virtual-ip
412 output:
413 failed: true
414 msg: "pcs failed with error (rc=1): bundle/clone/group/resource/tag 'virtual-ip' does not exist"
415 mocks:
416 run_command:
417 - command: [/testbin/pcs, resource, status, virtual-ip]
418 environ: *env-def
419 rc: 1
420 out: ""
421 err: "Error: resource or tag id 'virtual-ip' not found"
422 - command: [/testbin/pcs, resource, enable, virtual-ip]
423 environ: *env-def
424 rc: 1
425 out: ""
426 err: "bundle/clone/group/resource/tag 'virtual-ip' does not exist"
427 - id: test_enabled_minimal_input_resource_exists
428 input:
429 state: enabled
430 name: virtual-ip
431 output:
432 changed: true
433 previous_value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Stopped (disabled)"
434 value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Starting"
435 mocks:
436 run_command:
437 - command: [/testbin/pcs, resource, status, virtual-ip]
438 environ: *env-def
439 rc: 0
440 out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Stopped (disabled)"
441 err: ""
442 - command: [/testbin/pcs, resource, enable, virtual-ip]
443 environ: *env-def
444 rc: 0
445 out: ""
446 err: ""
447 - command: [/testbin/pcs, resource, status, virtual-ip]
448 environ: *env-def
449 rc: 0
450 out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Starting"
451 err: ""
452 - id: test_disable_minimal_input_resource_not_exists
453 input:
454 state: disabled
455 name: virtual-ip
456 output:
457 failed: true
458 msg: "pcs failed with error (rc=1): bundle/clone/group/resource/tag 'virtual-ip' does not exist"
459 mocks:
460 run_command:
461 - command: [/testbin/pcs, resource, status, virtual-ip]
462 environ: *env-def
463 rc: 1
464 out: ""
465 err: "Error: resource or tag id 'virtual-ip' not found"
466 - command: [/testbin/pcs, resource, disable, virtual-ip]
467 environ: *env-def
468 rc: 1
469 out: ""
470 err: "bundle/clone/group/resource/tag 'virtual-ip' does not exist"
471 - id: test_disable_minimal_input_resource_exists
472 input:
473 state: disabled
474 name: virtual-ip
475 output:
476 changed: true
477 previous_value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
478 value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Stopped (disabled)"
479 mocks:
480 run_command:
481 - command: [/testbin/pcs, resource, status, virtual-ip]
482 environ: *env-def
483 rc: 0
484 out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
485 err: ""
486 - command: [/testbin/pcs, resource, disable, virtual-ip]
487 environ: *env-def
488 rc: 0
489 out: ""
490 err: ""
491 - command: [/testbin/pcs, resource, status, virtual-ip]
492 environ: *env-def
493 rc: 0
494 out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Stopped (disabled)"
495 err: ""
496 - id: test_cleanup_minimal_input_initial_resources_not_exist
497 input:
498 state: cleanup
499 output:
500 changed: false
501 previous_value: "NO resources configured"
502 value: "NO resources configured"
503 mocks:
504 run_command:
505 - command: [/testbin/pcs, resource, status]
506 environ: *env-def
507 rc: 0
508 out: "NO resources configured"
509 err: ""
510 - command: [/testbin/pcs, resource, cleanup]
511 environ: *env-def
512 rc: 0
513 out: "Cleaned up all resources on all nodes"
514 err: ""
515 - command: [/testbin/pcs, resource, status]
516 environ: *env-def
517 rc: 0
518 out: "NO resources configured"
519 err: ""
520 - id: test_cleanup_minimal_input_initial_resources_exists
521 input:
522 state: cleanup
523 output:
524 changed: true
525 previous_value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
526 value: "NO resources configured"
527 mocks:
528 run_command:
529 - command: [/testbin/pcs, resource, status]
530 environ: *env-def
531 rc: 0
532 out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
533 err: ""
534 - command: [/testbin/pcs, resource, cleanup]
535 environ: *env-def
536 rc: 0
537 out: "Cleaned up all resources on all nodes"
538 err: ""
539 - command: [/testbin/pcs, resource, status]
540 environ: *env-def
541 rc: 0
542 out: "NO resources configured"
543 err: ""
544 - id: test_cleanup_specific_minimal_input_initial_resources_exists
545 input:
546 state: cleanup
547 name: virtual-ip
548 output:
549 changed: true
550 previous_value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
551 value: "NO resources configured"
552 mocks:
553 run_command:
554 - command: [/testbin/pcs, resource, status, virtual-ip]
555 environ: *env-def
556 rc: 0
557 out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
558 err: ""
559 - command: [/testbin/pcs, resource, cleanup, virtual-ip]
560 environ: *env-def
561 rc: 0
562 out: "Cleaned up virtual-ip on X"
563 err: ""
564 - command: [/testbin/pcs, resource, status, virtual-ip]
565 environ: *env-def
566 rc: 0
567 out: "NO resources configured"
568 err: ""
569 - id: test_clone_minimal_input_resource_not_exist
570 input:
571 state: cloned
572 name: virtual-ip
573 output:
574 failed: true
575 msg: "pcs failed with error (rc=1): Error: unable to find group or resource: virtual-ip"
576 mocks:
577 run_command:
578 - command: [/testbin/pcs, resource, status, virtual-ip]
579 environ: *env-def
580 rc: 1
581 out: ""
582 err: "Error: resource or tag id 'virtual-ip' not found"
583 - command: [/testbin/pcs, property, config]
584 environ: *env-def
585 rc: 1
586 out: |
587 Cluster Properties: cib-bootstrap-options
588 cluster-infrastructure=corosync
589 cluster-name=hacluster
590 dc-version=2.1.9-1.fc41-7188dbf
591 have-watchdog=false
592 err: ""
593 - command: [/testbin/pcs, resource, clone, virtual-ip]
594 environ: *env-def
595 rc: 1
596 out: ""
597 err: "Error: unable to find group or resource: virtual-ip"
598 - id: test_clone_filled_input_resource_exists
599 input:
600 state: cloned
601 name: virtual-ip
602 resource_clone_ids:
603 - test_clone
604 resource_clone_meta:
605 - test_clone_meta1=789
606 wait: 200
607 output:
608 changed: true
609 previous_value: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
610 value: " * Clone Set: virtual-ip-clone [virtual-ip]\t(ocf:heartbeat:IPAddr2):\t Started"
611 mocks:
612 run_command:
613 - command: [/testbin/pcs, resource, status, virtual-ip]
614 environ: *env-def
615 rc: 0
616 out: " * virtual-ip\t(ocf:heartbeat:IPAddr2):\t Started"
617 err: ""
618 - command: [/testbin/pcs, property, config]
619 environ: *env-def
620 rc: 1
621 out: |
622 Cluster Properties: cib-bootstrap-options
623 cluster-infrastructure=corosync
624 cluster-name=hacluster
625 dc-version=2.1.9-1.fc41-7188dbf
626 have-watchdog=false
627 err: ""
628 - command: [/testbin/pcs, resource, clone, virtual-ip, test_clone, meta, test_clone_meta1=789]
629 environ: *env-def
630 rc: 0
631 out: ""
632 err: ""
633 - command: [/testbin/pcs, property, config]
634 environ: *env-def
635 rc: 1
636 out: |
637 Cluster Properties: cib-bootstrap-options
638 cluster-infrastructure=corosync
639 cluster-name=hacluster
640 dc-version=2.1.9-1.fc41-7188dbf
641 have-watchdog=false
642 err: ""
643 - command: [/testbin/pcs, resource, status, virtual-ip]
644 environ: *env-def
645 rc: 0
646 out: " * Clone Set: virtual-ip-clone [virtual-ip]\t(ocf:heartbeat:IPAddr2):\t Started"
647 err: ""
648 - command: [/testbin/pcs, resource, status, virtual-ip]
649 environ: *env-def
650 rc: 0
651 out: " * Clone Set: virtual-ip-clone [virtual-ip]\t(ocf:heartbeat:IPAddr2):\t Started"
652 err: ""