Debian Codegraph @

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

raw
1 # Copyright (c) Ansible project
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 anchors:
6 # version commands (version > 5.18 → adds -B flag to status/summary commands)
7 version_526: &version_526
8 command: [/testbin/monit, -V]
9 environ: {check_rc: true}
10 rc: 0
11 out: "This is monit version 5.26.0\n"
12 err: ''
13 version_518: &version_518
14 command: [/testbin/monit, -V]
15 environ: {check_rc: true}
16 rc: 0
17 out: "This is monit version 5.18.0\n"
18 err: ''
19 version_1218: &version_1218
20 command: [/testbin/monit, -V]
21 environ: {check_rc: true}
22 rc: 0
23 out: "This is monit version 12.18\n"
24 err: ''
25 version_5181: &version_5181
26 command: [/testbin/monit, -V]
27 environ: {check_rc: true}
28 rc: 0
29 out: "This is monit version 5.18.1\n"
30 err: ''
31 version_5112: &version_5112
32 command: [/testbin/monit, -V]
33 environ: {check_rc: true}
34 rc: 0
35 out: "This is monit version 5.1.12\n"
36 err: ''
37
38 # summary commands (presence check)
39 summary_present_526: &summary_present_526
40 command: [/testbin/monit, summary, -B]
41 environ: {check_rc: true}
42 rc: 0
43 out: "processX\n"
44 err: ''
45 summary_not_present_526: &summary_not_present_526
46 command: [/testbin/monit, summary, -B]
47 environ: {check_rc: true}
48 rc: 0
49 out: "other_process\n"
50 err: ''
51 summary_present_518: &summary_present_518
52 command: [/testbin/monit, summary]
53 environ: {check_rc: true}
54 rc: 0
55 out: "processX\n"
56 err: ''
57
58 # status commands with -B (version > 5.18)
59 status_ok_526: &status_ok_526
60 command: [/testbin/monit, status, -B, processX]
61 environ: {check_rc: true}
62 rc: 0
63 out: "Process 'processX'\n status OK\n"
64 err: ''
65 status_not_monitored_526: &status_not_monitored_526
66 command: [/testbin/monit, status, -B, processX]
67 environ: {check_rc: true}
68 rc: 0
69 out: "Process 'processX'\n status Not monitored\n"
70 err: ''
71
72 # status commands without -B (version <= 5.18)
73 status_ok_no_b: &status_ok_no_b
74 command: [/testbin/monit, status, processX]
75 environ: {check_rc: true}
76 rc: 0
77 out: "Process 'processX'\n status OK\n"
78 err: ''
79 status_not_monitored_no_b: &status_not_monitored_no_b
80 command: [/testbin/monit, status, processX]
81 environ: {check_rc: true}
82 rc: 0
83 out: "Process 'processX'\n status Not monitored\n"
84 err: ''
85
86 # status text variants for parse_status coverage (with -B)
87 status_ok_raw_526: &status_ok_raw_526
88 command: [/testbin/monit, status, -B, processX]
89 environ: {check_rc: true}
90 rc: 0
91 out: "Process 'processX'\n status ok\n"
92 err: ''
93 status_running_526: &status_running_526
94 command: [/testbin/monit, status, -B, processX]
95 environ: {check_rc: true}
96 rc: 0
97 out: "Process 'processX'\n status Running\n"
98 err: ''
99 status_not_monitored_raw_526: &status_not_monitored_raw_526
100 command: [/testbin/monit, status, -B, processX]
101 environ: {check_rc: true}
102 rc: 0
103 out: "Process 'processX'\n status not_monitored\n"
104 err: ''
105 status_missing_raw_526: &status_missing_raw_526
106 command: [/testbin/monit, status, -B, processX]
107 environ: {check_rc: true}
108 rc: 0
109 out: "Process 'processX'\n status missing\n"
110 err: ''
111 status_initializing_526: &status_initializing_526
112 command: [/testbin/monit, status, -B, processX]
113 environ: {check_rc: true}
114 rc: 0
115 out: "Process 'processX'\n status initializing\n"
116 err: ''
117 status_does_not_exist_raw_526: &status_does_not_exist_raw_526
118 command: [/testbin/monit, status, -B, processX]
119 environ: {check_rc: true}
120 rc: 0
121 out: "Process 'processX'\n status does_not_exist\n"
122 err: ''
123 status_does_not_exist_text_526: &status_does_not_exist_text_526
124 command: [/testbin/monit, status, -B, processX]
125 environ: {check_rc: true}
126 rc: 0
127 out: "Process 'processX'\n status Does not exist\n"
128 err: ''
129 status_exec_failed_raw_526: &status_exec_failed_raw_526
130 command: [/testbin/monit, status, -B, processX]
131 environ: {check_rc: true}
132 rc: 0
133 out: "Process 'processX'\n status execution_failed\n"
134 err: ''
135 status_exec_failed_pipe_526: &status_exec_failed_pipe_526
136 command: [/testbin/monit, status, -B, processX]
137 environ: {check_rc: true}
138 rc: 0
139 out: "Process 'processX'\n status Execution failed | Does not exist\n"
140 err: ''
141 status_unknown_526: &status_unknown_526
142 command: [/testbin/monit, status, -B, processX]
143 environ: {check_rc: true}
144 rc: 0
145 out: "Process 'processX'\n status Some Unknown Status\n"
146 err: ''
147 status_start_pending_526: &status_start_pending_526
148 command: [/testbin/monit, status, -B, processX]
149 environ: {check_rc: true}
150 rc: 0
151 out: "Process 'processX'\n status Not Monitored - start pending\n"
152 err: ''
153 status_stop_pending_526: &status_stop_pending_526
154 command: [/testbin/monit, status, -B, processX]
155 environ: {check_rc: true}
156 rc: 0
157 out: "Process 'processX'\n status Monitored - stop pending\n"
158 err: ''
159 status_restart_pending_526: &status_restart_pending_526
160 command: [/testbin/monit, status, -B, processX]
161 environ: {check_rc: true}
162 rc: 0
163 out: "Process 'processX'\n status Monitored - restart pending\n"
164 err: ''
165 status_monitor_pending_526: &status_monitor_pending_526
166 command: [/testbin/monit, status, -B, processX]
167 environ: {check_rc: true}
168 rc: 0
169 out: "Process 'processX'\n status Not Monitored - monitor pending\n"
170 err: ''
171 status_wrong_name_526: &status_wrong_name_526
172 command: [/testbin/monit, status, -B, processX]
173 environ: {check_rc: true}
174 rc: 0
175 out: "Process 'otherProcess'\n status OK\n"
176 err: ''
177
178 test_cases:
179 # ------------------------------------------------------------------ no-change cases
180 - id: state_present_already_present
181 input:
182 name: processX
183 state: present
184 output:
185 changed: false
186 name: processX
187 state: present
188 mocks:
189 run_command:
190 - *version_526
191 - *summary_present_526
192
193 - id: state_present_already_present_old_monit
194 input:
195 name: processX
196 state: present
197 output:
198 changed: false
199 name: processX
200 state: present
201 mocks:
202 run_command:
203 - *version_518
204 - *summary_present_518
205
206 - id: state_started_already_running
207 # main(): is_process_present → wait_for_pending (get_status) → is_process_running (get_status)
208 # running=True, state in [started, monitored] → exit changed=False
209 input:
210 name: processX
211 state: started
212 output:
213 changed: false
214 name: processX
215 state: started
216 mocks:
217 run_command:
218 - *version_526
219 - *summary_present_526
220 - *status_ok_526 # wait_for_monit_to_stop_pending
221 - *status_ok_526 # is_process_running
222
223 - id: state_monitored_already_running
224 input:
225 name: processX
226 state: monitored
227 output:
228 changed: false
229 name: processX
230 state: monitored
231 mocks:
232 run_command:
233 - *version_526
234 - *summary_present_526
235 - *status_ok_526
236 - *status_ok_526
237
238 # ------------------------------------------------------------------ state changes
239 - id: state_stopped_currently_running
240 # change_state: get_status → stop → wait_for_status_change (status changes on 1st check)
241 input:
242 name: processX
243 state: stopped
244 output:
245 changed: true
246 name: processX
247 monit_version: "5.26.0"
248 state: stopped
249 mocks:
250 run_command:
251 - *version_526
252 - *summary_present_526
253 - *status_ok_526 # wait_for_monit_to_stop_pending
254 - *status_ok_526 # is_process_running (running=True)
255 - *status_ok_526 # change_state: current_status = get_status()
256 - command: [/testbin/monit, stop, processX]
257 environ: {check_rc: true}
258 rc: 0
259 out: ''
260 err: ''
261 - *status_not_monitored_526 # wait_for_status_change: status changed → done
262
263 - id: state_started_not_running
264 # process is not running → monit.start() → status changes to OK on 1st check
265 input:
266 name: processX
267 state: started
268 output:
269 changed: true
270 name: processX
271 monit_version: "5.26.0"
272 state: started
273 mocks:
274 run_command:
275 - *version_526
276 - *summary_present_526
277 - *status_not_monitored_526 # wait_for_monit_to_stop_pending
278 - *status_not_monitored_526 # is_process_running (running=False)
279 - *status_not_monitored_526 # change_state: current_status = get_status()
280 - command: [/testbin/monit, start, processX]
281 environ: {check_rc: true}
282 rc: 0
283 out: ''
284 err: ''
285 - *status_ok_526 # wait_for_status_change: status changed → done
286
287 - id: state_unmonitored_currently_running
288 input:
289 name: processX
290 state: unmonitored
291 output:
292 changed: true
293 name: processX
294 monit_version: "5.26.0"
295 state: unmonitored
296 mocks:
297 run_command:
298 - *version_526
299 - *summary_present_526
300 - *status_ok_526 # wait_for_monit_to_stop_pending
301 - *status_ok_526 # is_process_running (running=True)
302 - *status_ok_526 # change_state: current_status = get_status()
303 - command: [/testbin/monit, unmonitor, processX]
304 environ: {check_rc: true}
305 rc: 0
306 out: ''
307 err: ''
308 - *status_not_monitored_526 # wait_for_status_change: status changed → done
309
310 - id: state_monitored_not_running
311 # process not running → monit.monitor() → status changes to OK (invert_expected=True → success)
312 input:
313 name: processX
314 state: monitored
315 output:
316 changed: true
317 name: processX
318 monit_version: "5.26.0"
319 state: monitored
320 mocks:
321 run_command:
322 - *version_526
323 - *summary_present_526
324 - *status_not_monitored_526 # wait_for_monit_to_stop_pending
325 - *status_not_monitored_526 # is_process_running (running=False)
326 - *status_not_monitored_526 # change_state: current_status = get_status()
327 - command: [/testbin/monit, monitor, processX]
328 environ: {check_rc: true}
329 rc: 0
330 out: ''
331 err: ''
332 - *status_ok_526 # wait_for_status_change: changed → done; match inverted → success
333
334 - id: state_restarted
335 # restart works regardless of running state; process not running → restart → becomes OK
336 input:
337 name: processX
338 state: restarted
339 output:
340 changed: true
341 name: processX
342 monit_version: "5.26.0"
343 state: restarted
344 mocks:
345 run_command:
346 - *version_526
347 - *summary_present_526
348 - *status_not_monitored_526 # wait_for_monit_to_stop_pending
349 - *status_not_monitored_526 # is_process_running (running=False)
350 - *status_not_monitored_526 # change_state: current_status = get_status()
351 - command: [/testbin/monit, restart, processX]
352 environ: {check_rc: true}
353 rc: 0
354 out: ''
355 err: ''
356 - *status_ok_526 # wait_for_status_change: changed → done; OK == OK → success
357
358 # ------------------------------------------------------------------ reload
359 - id: state_reloaded
360 # reload exits before any presence/status checks; version check happens in __init__
361 input:
362 name: processX
363 state: reloaded
364 output:
365 changed: true
366 state: reloaded
367 mocks:
368 run_command:
369 - *version_526
370 - command: [/testbin/monit, reload]
371 environ: {}
372 rc: 0
373 out: ''
374 err: ''
375
376 # ------------------------------------------------------------------ present (not yet)
377 - id: state_present_not_yet_present
378 # not present in summary → Monit.present(): reload + summary check (present on 1st try)
379 input:
380 name: processX
381 state: present
382 output:
383 changed: true
384 name: processX
385 monit_version: "5.26.0"
386 state: present
387 mocks:
388 run_command:
389 - *version_526
390 - *summary_not_present_526 # initial presence check → not present
391 - command: [/testbin/monit, reload, processX]
392 environ: {check_rc: true}
393 rc: 0
394 out: ''
395 err: ''
396 - *summary_present_526 # while loop: present on first check → exit
397
398 # ------------------------------------------------------------------ failure cases
399 - id: state_reloaded_fail
400 # reload returns rc=1 → fail_json("monit reload failed"); version check happens in __init__
401 input:
402 name: processX
403 state: reloaded
404 output:
405 failed: true
406 mocks:
407 run_command:
408 - *version_526
409 - command: [/testbin/monit, reload]
410 environ: {}
411 rc: 1
412 out: "stdout"
413 err: "stderr"
414
415 - id: state_started_pending_timeout
416 # timeout=0 + status=MISSING (empty output) → wait_for_monit_to_stop_pending times out
417 input:
418 name: processX
419 state: started
420 timeout: 0
421 output:
422 failed: true
423 mocks:
424 run_command:
425 - *version_526
426 - *summary_present_526
427 - command: [/testbin/monit, status, -B, processX]
428 environ: {check_rc: true}
429 rc: 0
430 out: ''
431 err: ''
432
433 - id: state_stopped_status_change_on_retry
434 # same as state_stopped_currently_running but status is unchanged on the first check
435 # in wait_for_status_change; changes only on the second check (one retry loop)
436 input:
437 name: processX
438 state: stopped
439 output:
440 changed: true
441 name: processX
442 monit_version: "5.26.0"
443 state: stopped
444 mocks:
445 run_command:
446 - *version_526
447 - *summary_present_526
448 - *status_ok_526 # wait_for_monit_to_stop_pending
449 - *status_ok_526 # is_process_running (running=True)
450 - *status_ok_526 # change_state: current_status = get_status()
451 - command: [/testbin/monit, stop, processX]
452 environ: {check_rc: true}
453 rc: 0
454 out: ''
455 err: ''
456 - *status_ok_526 # wait_for_status_change: initial (same → enters loop)
457 - *status_not_monitored_526 # loop_count=1, validate=False → changed!
458
459 # ------------------------------------------------------------------ check mode
460 - id: state_stopped_check_mode
461 # check mode: presence + pending + running checks happen, then exit_if_check_mode fires
462 flags:
463 check: true
464 input:
465 name: processX
466 state: stopped
467 output:
468 changed: true
469 mocks:
470 run_command:
471 - *version_526
472 - *summary_present_526
473 - *status_ok_526 # wait_for_monit_to_stop_pending
474 - *status_ok_526 # is_process_running (running=True) → exit_if_check_mode
475
476 # ------------------------------------------------------------------ parse_status coverage
477 # Each case targets a specific status string → parsed Status → verifiable module behavior.
478 # "ok", "running" → OK → state=started, already running → changed=false (4 commands)
479 # "not_monitored_raw" → NOT_MONITORED → start → changed=true (7 commands)
480 # in waiting_status (missing, initializing, does_not_exist) → timeout=0 → fail (3 commands)
481 # EXECUTION_FAILED → not running → special fast path in wait_for_status_change (7 commands)
482 # pending → is_pending=True → timeout=0 → fail (3 commands)
483
484 - id: parse_status_ok_raw
485 # "ok" (raw enum value, lowercase) → Status("OK") → running → no change
486 input:
487 name: processX
488 state: started
489 output:
490 changed: false
491 state: started
492 mocks:
493 run_command:
494 - *version_526
495 - *summary_present_526
496 - *status_ok_raw_526
497 - *status_ok_raw_526
498
499 - id: parse_status_running
500 # "Running" → Status("OK") via the RUNNING→OK alias → running → no change
501 input:
502 name: processX
503 state: started
504 output:
505 changed: false
506 state: started
507 mocks:
508 run_command:
509 - *version_526
510 - *summary_present_526
511 - *status_running_526
512 - *status_running_526
513
514 - id: parse_status_not_monitored_raw
515 # "not_monitored" (raw, underscore) → Status("NOT_MONITORED") → not running → start
516 input:
517 name: processX
518 state: started
519 output:
520 changed: true
521 state: started
522 mocks:
523 run_command:
524 - *version_526
525 - *summary_present_526
526 - *status_not_monitored_raw_526 # wait_for_monit_to_stop_pending
527 - *status_not_monitored_raw_526 # is_process_running (False)
528 - *status_not_monitored_raw_526 # change_state: current_status
529 - command: [/testbin/monit, start, processX]
530 environ: {check_rc: true}
531 rc: 0
532 out: ''
533 err: ''
534 - *status_ok_526
535
536 - id: parse_status_missing_raw
537 # "missing" (raw enum value) → Status("MISSING") → in waiting_status → timeout
538 input:
539 name: processX
540 state: started
541 timeout: 0
542 output:
543 failed: true
544 mocks:
545 run_command:
546 - *version_526
547 - *summary_present_526
548 - *status_missing_raw_526
549
550 - id: parse_status_wrong_name
551 # process name not found in output → Status("MISSING") → timeout
552 input:
553 name: processX
554 state: started
555 timeout: 0
556 output:
557 failed: true
558 mocks:
559 run_command:
560 - *version_526
561 - *summary_present_526
562 - *status_wrong_name_526
563
564 - id: parse_status_initializing
565 # "initializing" → Status("INITIALIZING") → in waiting_status → timeout
566 input:
567 name: processX
568 state: started
569 timeout: 0
570 output:
571 failed: true
572 mocks:
573 run_command:
574 - *version_526
575 - *summary_present_526
576 - *status_initializing_526
577
578 - id: parse_status_does_not_exist_raw
579 # "does_not_exist" (raw) → Status("DOES_NOT_EXIST") → in waiting_status → timeout
580 input:
581 name: processX
582 state: started
583 timeout: 0
584 output:
585 failed: true
586 mocks:
587 run_command:
588 - *version_526
589 - *summary_present_526
590 - *status_does_not_exist_raw_526
591
592 - id: parse_status_does_not_exist_text
593 # "Does not exist" → DOES_NOT_EXIST (via space→underscore normalisation) → timeout
594 input:
595 name: processX
596 state: started
597 timeout: 0
598 output:
599 failed: true
600 mocks:
601 run_command:
602 - *version_526
603 - *summary_present_526
604 - *status_does_not_exist_text_526
605
606 - id: parse_status_exec_failed_raw
607 # "execution_failed" → EXECUTION_FAILED → not running, but wait_for_status_change
608 # returns immediately (special case: current_status.value == EXECUTION_FAILED)
609 input:
610 name: processX
611 state: started
612 output:
613 changed: true
614 state: started
615 mocks:
616 run_command:
617 - *version_526
618 - *summary_present_526
619 - *status_exec_failed_raw_526 # wait_for_monit_to_stop_pending (not in waiting_status)
620 - *status_exec_failed_raw_526 # is_process_running (False)
621 - *status_exec_failed_raw_526 # change_state: current_status
622 - command: [/testbin/monit, start, processX]
623 environ: {check_rc: true}
624 rc: 0
625 out: ''
626 err: ''
627 - *status_ok_526 # wait_for_status_change returns immediately (EXECUTION_FAILED)
628
629 - id: parse_status_exec_failed_pipe
630 # "Execution failed | Does not exist" → EXECUTION_FAILED (regex stops before |)
631 input:
632 name: processX
633 state: started
634 output:
635 changed: true
636 state: started
637 mocks:
638 run_command:
639 - *version_526
640 - *summary_present_526
641 - *status_exec_failed_pipe_526
642 - *status_exec_failed_pipe_526
643 - *status_exec_failed_pipe_526
644 - command: [/testbin/monit, start, processX]
645 environ: {check_rc: true}
646 rc: 0
647 out: ''
648 err: ''
649 - *status_ok_526
650
651 - id: parse_status_unknown
652 # "Some Unknown Status" → EXECUTION_FAILED (via module.warn + fallback)
653 input:
654 name: processX
655 state: started
656 output:
657 changed: true
658 state: started
659 mocks:
660 run_command:
661 - *version_526
662 - *summary_present_526
663 - *status_unknown_526
664 - *status_unknown_526
665 - *status_unknown_526
666 - command: [/testbin/monit, start, processX]
667 environ: {check_rc: true}
668 rc: 0
669 out: ''
670 err: ''
671 - *status_ok_526
672
673 - id: parse_status_start_pending
674 # "Not Monitored - start pending" → Status("OK", is_pending=True) → timeout
675 input:
676 name: processX
677 state: started
678 timeout: 0
679 output:
680 failed: true
681 mocks:
682 run_command:
683 - *version_526
684 - *summary_present_526
685 - *status_start_pending_526
686
687 - id: parse_status_stop_pending
688 # "Monitored - stop pending" → Status("NOT_MONITORED", is_pending=True) → timeout
689 input:
690 name: processX
691 state: started
692 timeout: 0
693 output:
694 failed: true
695 mocks:
696 run_command:
697 - *version_526
698 - *summary_present_526
699 - *status_stop_pending_526
700
701 - id: parse_status_restart_pending
702 # "Monitored - restart pending" → Status("OK", is_pending=True) → timeout
703 input:
704 name: processX
705 state: started
706 timeout: 0
707 output:
708 failed: true
709 mocks:
710 run_command:
711 - *version_526
712 - *summary_present_526
713 - *status_restart_pending_526
714
715 - id: parse_status_monitor_pending
716 # "Not Monitored - monitor pending" → Status("OK", is_pending=True) → timeout
717 input:
718 name: processX
719 state: started
720 timeout: 0
721 output:
722 failed: true
723 mocks:
724 run_command:
725 - *version_526
726 - *summary_present_526
727 - *status_monitor_pending_526
728
729 # ------------------------------------------------------------------ parse_service_types coverage
730 # Each recognised service type: process name found → status OK → running → changed=false
731 # "Unsupported" is not in MONIT_SERVICES → MISSING → timeout
732
733 - id: parse_service_file
734 input:
735 name: processX
736 state: started
737 output:
738 changed: false
739 state: started
740 mocks:
741 run_command:
742 - *version_526
743 - *summary_present_526
744 - command: [/testbin/monit, status, -B, processX]
745 environ: {check_rc: true}
746 rc: 0
747 out: "File 'processX'\n status OK\n"
748 err: ''
749 - command: [/testbin/monit, status, -B, processX]
750 environ: {check_rc: true}
751 rc: 0
752 out: "File 'processX'\n status OK\n"
753 err: ''
754
755 - id: parse_service_fifo
756 input:
757 name: processX
758 state: started
759 output:
760 changed: false
761 state: started
762 mocks:
763 run_command:
764 - *version_526
765 - *summary_present_526
766 - command: [/testbin/monit, status, -B, processX]
767 environ: {check_rc: true}
768 rc: 0
769 out: "Fifo 'processX'\n status OK\n"
770 err: ''
771 - command: [/testbin/monit, status, -B, processX]
772 environ: {check_rc: true}
773 rc: 0
774 out: "Fifo 'processX'\n status OK\n"
775 err: ''
776
777 - id: parse_service_filesystem
778 input:
779 name: processX
780 state: started
781 output:
782 changed: false
783 state: started
784 mocks:
785 run_command:
786 - *version_526
787 - *summary_present_526
788 - command: [/testbin/monit, status, -B, processX]
789 environ: {check_rc: true}
790 rc: 0
791 out: "Filesystem 'processX'\n status OK\n"
792 err: ''
793 - command: [/testbin/monit, status, -B, processX]
794 environ: {check_rc: true}
795 rc: 0
796 out: "Filesystem 'processX'\n status OK\n"
797 err: ''
798
799 - id: parse_service_directory
800 input:
801 name: processX
802 state: started
803 output:
804 changed: false
805 state: started
806 mocks:
807 run_command:
808 - *version_526
809 - *summary_present_526
810 - command: [/testbin/monit, status, -B, processX]
811 environ: {check_rc: true}
812 rc: 0
813 out: "Directory 'processX'\n status OK\n"
814 err: ''
815 - command: [/testbin/monit, status, -B, processX]
816 environ: {check_rc: true}
817 rc: 0
818 out: "Directory 'processX'\n status OK\n"
819 err: ''
820
821 - id: parse_service_remote_host
822 input:
823 name: processX
824 state: started
825 output:
826 changed: false
827 state: started
828 mocks:
829 run_command:
830 - *version_526
831 - *summary_present_526
832 - command: [/testbin/monit, status, -B, processX]
833 environ: {check_rc: true}
834 rc: 0
835 out: "Remote host 'processX'\n status OK\n"
836 err: ''
837 - command: [/testbin/monit, status, -B, processX]
838 environ: {check_rc: true}
839 rc: 0
840 out: "Remote host 'processX'\n status OK\n"
841 err: ''
842
843 - id: parse_service_system
844 input:
845 name: processX
846 state: started
847 output:
848 changed: false
849 state: started
850 mocks:
851 run_command:
852 - *version_526
853 - *summary_present_526
854 - command: [/testbin/monit, status, -B, processX]
855 environ: {check_rc: true}
856 rc: 0
857 out: "System 'processX'\n status OK\n"
858 err: ''
859 - command: [/testbin/monit, status, -B, processX]
860 environ: {check_rc: true}
861 rc: 0
862 out: "System 'processX'\n status OK\n"
863 err: ''
864
865 - id: parse_service_program
866 input:
867 name: processX
868 state: started
869 output:
870 changed: false
871 state: started
872 mocks:
873 run_command:
874 - *version_526
875 - *summary_present_526
876 - command: [/testbin/monit, status, -B, processX]
877 environ: {check_rc: true}
878 rc: 0
879 out: "Program 'processX'\n status OK\n"
880 err: ''
881 - command: [/testbin/monit, status, -B, processX]
882 environ: {check_rc: true}
883 rc: 0
884 out: "Program 'processX'\n status OK\n"
885 err: ''
886
887 - id: parse_service_network
888 input:
889 name: processX
890 state: started
891 output:
892 changed: false
893 state: started
894 mocks:
895 run_command:
896 - *version_526
897 - *summary_present_526
898 - command: [/testbin/monit, status, -B, processX]
899 environ: {check_rc: true}
900 rc: 0
901 out: "Network 'processX'\n status OK\n"
902 err: ''
903 - command: [/testbin/monit, status, -B, processX]
904 environ: {check_rc: true}
905 rc: 0
906 out: "Network 'processX'\n status OK\n"
907 err: ''
908
909 - id: parse_service_unsupported
910 # "Unsupported" not in MONIT_SERVICES → _parse_status returns MISSING → timeout
911 input:
912 name: processX
913 state: started
914 timeout: 0
915 output:
916 failed: true
917 mocks:
918 run_command:
919 - *version_526
920 - *summary_present_526
921 - command: [/testbin/monit, status, -B, processX]
922 environ: {check_rc: true}
923 rc: 0
924 out: "Unsupported 'processX'\n status OK\n"
925 err: ''
926
927 # ------------------------------------------------------------------ parse_version coverage
928 # state=stopped (running process) exercises exit_success() which includes monit_version.
929 # Commands with/without -B reveal whether the version tuple was parsed correctly.
930
931 - id: parse_version_1218
932 # "12.18" → (12, 18) > (5, 18) → -B added; monit_version="12.18" in output
933 input:
934 name: processX
935 state: stopped
936 output:
937 changed: true
938 monit_version: "12.18"
939 state: stopped
940 mocks:
941 run_command:
942 - *version_1218
943 - *summary_present_526 # -B because (12,18) > (5,18)
944 - *status_ok_526
945 - *status_ok_526
946 - *status_ok_526
947 - command: [/testbin/monit, stop, processX]
948 environ: {check_rc: true}
949 rc: 0
950 out: ''
951 err: ''
952 - *status_not_monitored_526
953
954 - id: parse_version_5181
955 # "5.18.1" → (5, 18) not > (5, 18) → no -B; monit_version="5.18.1" in output
956 input:
957 name: processX
958 state: stopped
959 output:
960 changed: true
961 monit_version: "5.18.1"
962 state: stopped
963 mocks:
964 run_command:
965 - *version_5181
966 - *summary_present_518 # no -B because (5,18) == (5,18)
967 - *status_ok_no_b
968 - *status_ok_no_b
969 - *status_ok_no_b
970 - command: [/testbin/monit, stop, processX]
971 environ: {check_rc: true}
972 rc: 0
973 out: ''
974 err: ''
975 - *status_not_monitored_no_b
976
977 - id: parse_version_5112
978 # "5.1.12" → (5, 1) not > (5, 18) → no -B; monit_version="5.1.12" in output
979 input:
980 name: processX
981 state: stopped
982 output:
983 changed: true
984 monit_version: "5.1.12"
985 state: stopped
986 mocks:
987 run_command:
988 - *version_5112
989 - *summary_present_518 # no -B because (5,1) < (5,18)
990 - *status_ok_no_b
991 - *status_ok_no_b
992 - *status_ok_no_b
993 - command: [/testbin/monit, stop, processX]
994 environ: {check_rc: true}
995 rc: 0
996 out: ''
997 err: ''
998 - *status_not_monitored_no_b