pacemaker  2.1.8-3980678f03
Scalable High-Availability cluster resource manager
pcmk_xe_mask_probe_failure_test.c
Go to the documentation of this file.
1 /*
2  * Copyright 2021-2024 the Pacemaker project contributors
3  *
4  * The version control history for this file may have further details.
5  *
6  * This source code is licensed under the GNU General Public License version 2
7  * or later (GPLv2+) WITHOUT ANY WARRANTY.
8  */
9 
10 #include <crm_internal.h>
11 
13 
14 static void
15 op_is_not_probe_test(void **state) {
16  xmlNode *node = NULL;
17 
18  /* Not worth testing this thoroughly since it's just a duplicate of whether
19  * pcmk_op_is_probe works or not.
20  */
21 
24  "=\"" PCMK_ACTION_START "\" "
25  PCMK_META_INTERVAL "=\"0\"/>");
26  assert_false(pcmk_xe_mask_probe_failure(node));
27  free_xml(node);
28 }
29 
30 static void
31 op_does_not_have_right_values_test(void **state) {
32  xmlNode *node = NULL;
33  char *s = NULL;
34 
37  "=\"" PCMK_ACTION_MONITOR "\" "
38  PCMK_META_INTERVAL "=\"0\"/>");
39  assert_false(pcmk_xe_mask_probe_failure(node));
40  free_xml(node);
41 
44  PCMK_META_INTERVAL "=\"0\" "
45  PCMK__XA_RC_CODE "=\"%d\" "
46  PCMK__XA_OP_STATUS "=\"\"/>",
47  PCMK_OCF_OK);
48  node = pcmk__xml_parse(s);
49  assert_false(pcmk_xe_mask_probe_failure(node));
50  free(s);
51  free_xml(node);
52 }
53 
54 static void
55 check_values_test(void **state) {
56  xmlNode *node = NULL;
57  char *s = NULL;
58 
59  /* PCMK_EXEC_NOT_SUPPORTED */
62  PCMK_META_INTERVAL "=\"0\" "
63  PCMK__XA_RC_CODE "=\"%d\" "
64  PCMK__XA_OP_STATUS "=\"%d\"/>",
66  node = pcmk__xml_parse(s);
67  assert_false(pcmk_xe_mask_probe_failure(node));
68  free(s);
69  free_xml(node);
70 
73  PCMK_META_INTERVAL "=\"0\" "
74  PCMK__XA_RC_CODE "=\"%d\" "
75  PCMK__XA_OP_STATUS "=\"%d\"/>",
77  node = pcmk__xml_parse(s);
78  assert_true(pcmk_xe_mask_probe_failure(node));
79  free(s);
80  free_xml(node);
81 
82  /* PCMK_EXEC_DONE */
85  PCMK_META_INTERVAL "=\"0\" "
86  PCMK__XA_RC_CODE "=\"%d\" "
87  PCMK__XA_OP_STATUS "=\"%d\"/>",
89  node = pcmk__xml_parse(s);
90  assert_false(pcmk_xe_mask_probe_failure(node));
91  free(s);
92  free_xml(node);
93 
96  PCMK_META_INTERVAL "=\"0\" "
97  PCMK__XA_RC_CODE "=\"%d\" "
98  PCMK__XA_OP_STATUS "=\"%d\"/>",
100  node = pcmk__xml_parse(s);
101  assert_true(pcmk_xe_mask_probe_failure(node));
102  free(s);
103  free_xml(node);
104 
107  PCMK_META_INTERVAL "=\"0\" "
108  PCMK__XA_RC_CODE "=\"%d\" "
109  PCMK__XA_OP_STATUS "=\"%d\"/>",
111  node = pcmk__xml_parse(s);
112  assert_true(pcmk_xe_mask_probe_failure(node));
113  free(s);
114  free_xml(node);
115 
118  PCMK_META_INTERVAL "=\"0\" "
119  PCMK__XA_RC_CODE "=\"%d\" "
120  PCMK__XA_OP_STATUS "=\"%d\"/>",
122  node = pcmk__xml_parse(s);
123  assert_false(pcmk_xe_mask_probe_failure(node));
124  free(s);
125  free_xml(node);
126 
129  PCMK_META_INTERVAL "=\"0\" "
130  PCMK__XA_RC_CODE "=\"%d\" "
131  PCMK__XA_OP_STATUS "=\"%d\"/>",
133  node = pcmk__xml_parse(s);
134  assert_false(pcmk_xe_mask_probe_failure(node));
135  free(s);
136  free_xml(node);
137 
138  /* PCMK_EXEC_NOT_INSTALLED */
141  PCMK_META_INTERVAL "=\"0\" "
142  PCMK__XA_RC_CODE "=\"%d\" "
143  PCMK__XA_OP_STATUS "=\"%d\"/>",
145  node = pcmk__xml_parse(s);
146  assert_true(pcmk_xe_mask_probe_failure(node));
147  free(s);
148  free_xml(node);
149 
152  PCMK_META_INTERVAL "=\"0\" "
153  PCMK__XA_RC_CODE "=\"%d\" "
154  PCMK__XA_OP_STATUS "=\"%d\"/>",
156  node = pcmk__xml_parse(s);
157  assert_true(pcmk_xe_mask_probe_failure(node));
158  free(s);
159  free_xml(node);
160 
161  /* PCMK_EXEC_ERROR */
164  PCMK_META_INTERVAL "=\"0\" "
165  PCMK__XA_RC_CODE "=\"%d\" "
166  PCMK__XA_OP_STATUS "=\"%d\"/>",
168  node = pcmk__xml_parse(s);
169  assert_false(pcmk_xe_mask_probe_failure(node));
170  free(s);
171  free_xml(node);
172 
175  PCMK_META_INTERVAL "=\"0\" "
176  PCMK__XA_RC_CODE "=\"%d\" "
177  PCMK__XA_OP_STATUS "=\"%d\"/>",
179  node = pcmk__xml_parse(s);
180  assert_true(pcmk_xe_mask_probe_failure(node));
181  free(s);
182  free_xml(node);
183 
186  PCMK_META_INTERVAL "=\"0\" "
187  PCMK__XA_RC_CODE "=\"%d\" "
188  PCMK__XA_OP_STATUS "=\"%d\"/>",
190  node = pcmk__xml_parse(s);
191  assert_true(pcmk_xe_mask_probe_failure(node));
192  free(s);
193  free_xml(node);
194 
197  PCMK_META_INTERVAL "=\"0\" "
198  PCMK__XA_RC_CODE "=\"%d\" "
199  PCMK__XA_OP_STATUS "=\"%d\"/>",
201  node = pcmk__xml_parse(s);
202  assert_false(pcmk_xe_mask_probe_failure(node));
203  free(s);
204  free_xml(node);
205 
208  PCMK_META_INTERVAL "=\"0\" "
209  PCMK__XA_RC_CODE "=\"%d\" "
210  PCMK__XA_OP_STATUS "=\"%d\"/>",
212  node = pcmk__xml_parse(s);
213  assert_false(pcmk_xe_mask_probe_failure(node));
214  free(s);
215  free_xml(node);
216 
217  /* PCMK_EXEC_ERROR_HARD */
220  PCMK_META_INTERVAL "=\"0\" "
221  PCMK__XA_RC_CODE "=\"%d\" "
222  PCMK__XA_OP_STATUS "=\"%d\"/>",
224  node = pcmk__xml_parse(s);
225  assert_false(pcmk_xe_mask_probe_failure(node));
226  free(s);
227  free_xml(node);
228 
231  PCMK_META_INTERVAL "=\"0\" "
232  PCMK__XA_RC_CODE "=\"%d\" "
233  PCMK__XA_OP_STATUS "=\"%d\"/>",
235  node = pcmk__xml_parse(s);
236  assert_true(pcmk_xe_mask_probe_failure(node));
237  free(s);
238  free_xml(node);
239 
242  PCMK_META_INTERVAL "=\"0\" "
243  PCMK__XA_RC_CODE "=\"%d\" "
244  PCMK__XA_OP_STATUS "=\"%d\"/>",
246  node = pcmk__xml_parse(s);
247  assert_true(pcmk_xe_mask_probe_failure(node));
248  free(s);
249  free_xml(node);
250 
253  PCMK_META_INTERVAL "=\"0\" "
254  PCMK__XA_RC_CODE "=\"%d\" "
255  PCMK__XA_OP_STATUS "=\"%d\"/>",
257  node = pcmk__xml_parse(s);
258  assert_false(pcmk_xe_mask_probe_failure(node));
259  free(s);
260  free_xml(node);
261 
264  PCMK_META_INTERVAL "=\"0\" "
265  PCMK__XA_RC_CODE "=\"%d\" "
266  PCMK__XA_OP_STATUS "=\"%d\"/>",
268  node = pcmk__xml_parse(s);
269  assert_false(pcmk_xe_mask_probe_failure(node));
270  free(s);
271  free_xml(node);
272 
273  /* PCMK_EXEC_ERROR_FATAL */
276  PCMK_META_INTERVAL "=\"0\" "
277  PCMK__XA_RC_CODE "=\"%d\" "
278  PCMK__XA_OP_STATUS "=\"%d\"/>",
280  node = pcmk__xml_parse(s);
281  assert_false(pcmk_xe_mask_probe_failure(node));
282  free(s);
283  free_xml(node);
284 
287  PCMK_META_INTERVAL "=\"0\" "
288  PCMK__XA_RC_CODE "=\"%d\" "
289  PCMK__XA_OP_STATUS "=\"%d\"/>",
291  node = pcmk__xml_parse(s);
292  assert_true(pcmk_xe_mask_probe_failure(node));
293  free(s);
294  free_xml(node);
295 
298  PCMK_META_INTERVAL "=\"0\" "
299  PCMK__XA_RC_CODE "=\"%d\" "
300  PCMK__XA_OP_STATUS "=\"%d\"/>",
302  node = pcmk__xml_parse(s);
303  assert_true(pcmk_xe_mask_probe_failure(node));
304  free(s);
305  free_xml(node);
306 
309  PCMK_META_INTERVAL "=\"0\" "
310  PCMK__XA_RC_CODE "=\"%d\" "
311  PCMK__XA_OP_STATUS "=\"%d\"/>",
313  node = pcmk__xml_parse(s);
314  assert_false(pcmk_xe_mask_probe_failure(node));
315  free(s);
316  free_xml(node);
317 
320  PCMK_META_INTERVAL "=\"0\" "
321  PCMK__XA_RC_CODE "=\"%d\" "
322  PCMK__XA_OP_STATUS "=\"%d\"/>",
324  node = pcmk__xml_parse(s);
325  assert_false(pcmk_xe_mask_probe_failure(node));
326  free(s);
327  free_xml(node);
328 }
329 
331  cmocka_unit_test(op_is_not_probe_test),
332  cmocka_unit_test(op_does_not_have_right_values_test),
333  cmocka_unit_test(check_values_test))
#define PCMK__XA_RC_CODE
#define PCMK_ACTION_MONITOR
Definition: actions.h:60
Service safely stopped.
Definition: results.h:190
#define PCMK__UNIT_TEST(group_setup, group_teardown,...)
Execution failed, do not retry on node.
Definition: results.h:338
#define PCMK_XA_OPERATION
Definition: xml_names.h:344
Parameter invalid (in local context)
Definition: results.h:183
Parameter invalid (inherently)
Definition: results.h:187
bool pcmk_xe_mask_probe_failure(const xmlNode *xml_op)
Check whether an action history entry represents a maskable probe.
Definition: probes.c:69
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
#define PCMK_ACTION_START
Definition: actions.h:72
int pcmk__xml_test_setup_group(void **state)
Definition: unittest.c:74
Action completed, result is known.
Definition: results.h:333
Execution failed, do not retry anywhere.
Definition: results.h:339
void free_xml(xmlNode *child)
Definition: xml.c:867
Dependencies not available locally.
Definition: results.h:186
xmlNode * pcmk__xml_parse(const char *input)
Definition: xml_io.c:244
#define PCMK_META_INTERVAL
Definition: options.h:91
Agent does not implement requested action.
Definition: results.h:336
#define PCMK__XE_LRM_RSC_OP
Success.
Definition: results.h:178
#define PCMK__XA_OP_STATUS
Agent or dependency not available locally.
Definition: results.h:340
Execution failed, may be retried.
Definition: results.h:337