This source file includes following definitions.
- setup
- teardown
- bad_args
- primitive_rsc
- group_rsc
- inactive_group_rsc
- group_member_rsc
- inactive_group_member_rsc
- clone_rsc
- inactive_clone_rsc
- clone_instance_rsc
- renamed_rsc
- bundle_rsc
- bundle_replica_rsc
- clone_group_rsc
- clone_group_instance_rsc
- clone_group_member_rsc
1
2
3
4
5
6
7
8
9
10 #include <crm_internal.h>
11
12 #include <crm/common/unittest_internal.h>
13 #include <crm/common/xml.h>
14 #include <crm/pengine/internal.h>
15 #include <crm/pengine/status.h>
16 #include <crm/pengine/pe_types.h>
17
18
19 #define PE__VARIANT_BUNDLE 1
20 #include <lib/pengine/variant.h>
21
22 xmlNode *input = NULL;
23 pe_working_set_t *data_set = NULL;
24
25 pe_node_t *cluster01, *cluster02, *httpd_bundle_0;
26 pe_resource_t *exim_group, *inactive_group, *promotable_clone, *inactive_clone;
27 pe_resource_t *httpd_bundle, *mysql_clone_group;
28
29 static int
30 setup(void **state) {
31 char *path = NULL;
32
33 crm_xml_init();
34
35 path = crm_strdup_printf("%s/crm_mon.xml", getenv("PCMK_CTS_CLI_DIR"));
36 input = filename2xml(path);
37 free(path);
38
39 if (input == NULL) {
40 return 1;
41 }
42
43 data_set = pe_new_working_set();
44
45 if (data_set == NULL) {
46 return 1;
47 }
48
49 pe__set_working_set_flags(data_set, pe_flag_no_counts|pe_flag_no_compat);
50 data_set->input = input;
51
52 cluster_status(data_set);
53
54
55 cluster01 = pe_find_node(data_set->nodes, "cluster01");
56 cluster02 = pe_find_node(data_set->nodes, "cluster02");
57 httpd_bundle_0 = pe_find_node(data_set->nodes, "httpd-bundle-0");
58
59
60 for (GList *iter = data_set->resources; iter != NULL; iter = iter->next) {
61 pe_resource_t *rsc = (pe_resource_t *) iter->data;
62
63 if (strcmp(rsc->id, "exim-group") == 0) {
64 exim_group = rsc;
65 } else if (strcmp(rsc->id, "httpd-bundle") == 0) {
66 httpd_bundle = rsc;
67 } else if (strcmp(rsc->id, "inactive-clone") == 0) {
68 inactive_clone = rsc;
69 } else if (strcmp(rsc->id, "inactive-group") == 0) {
70 inactive_group = rsc;
71 } else if (strcmp(rsc->id, "mysql-clone-group") == 0) {
72 mysql_clone_group = rsc;
73 } else if (strcmp(rsc->id, "promotable-clone") == 0) {
74 promotable_clone = rsc;
75 }
76 }
77
78 return 0;
79 }
80
81 static int
82 teardown(void **state) {
83 pe_free_working_set(data_set);
84
85 return 0;
86 }
87
88 static void
89 bad_args(void **state) {
90 pe_resource_t *rsc = (pe_resource_t *) g_list_first(data_set->resources)->data;
91 char *id = rsc->id;
92 char *name = NULL;
93
94 assert_non_null(rsc);
95
96 assert_null(native_find_rsc(NULL, "dummy", NULL, 0));
97 assert_null(native_find_rsc(rsc, NULL, NULL, 0));
98
99
100 name = crm_strdup_printf("%sX", rsc->id);
101 assert_null(native_find_rsc(rsc, name, NULL, 0));
102 free(name);
103
104 name = crm_strdup_printf("x%s", rsc->id);
105 assert_null(native_find_rsc(rsc, name, NULL, 0));
106 free(name);
107
108 name = g_ascii_strup(rsc->id, -1);
109 assert_null(native_find_rsc(rsc, name, NULL, 0));
110 g_free(name);
111
112
113 rsc->id = NULL;
114 assert_null(native_find_rsc(rsc, id, NULL, 0));
115 rsc->id = id;
116 }
117
118 static void
119 primitive_rsc(void **state) {
120 pe_resource_t *dummy = NULL;
121
122
123 for (GList *iter = data_set->resources; iter != NULL; iter = iter->next) {
124 pe_resource_t *rsc = (pe_resource_t *) iter->data;
125
126 if (strcmp(rsc->id, "dummy") == 0) {
127 dummy = rsc;
128 break;
129 }
130 }
131
132 assert_non_null(dummy);
133
134
135 assert_ptr_equal(dummy, native_find_rsc(dummy, "dummy", NULL, 0));
136 assert_ptr_equal(dummy, native_find_rsc(dummy, "dummy", NULL, pe_find_current));
137
138
139 assert_null(native_find_rsc(dummy, "dummy", NULL, pe_find_clone));
140 assert_null(native_find_rsc(dummy, "dummy", cluster02, pe_find_clone));
141
142
143 assert_null(native_find_rsc(dummy, "dummy", cluster01, pe_find_current));
144
145
146 assert_null(native_find_rsc(dummy, "dummy", cluster02, 0));
147
148
149 assert_ptr_equal(dummy, native_find_rsc(dummy, "dummy", cluster02, pe_find_current));
150 }
151
152 static void
153 group_rsc(void **state) {
154 assert_non_null(exim_group);
155
156
157 assert_ptr_equal(exim_group, native_find_rsc(exim_group, "exim-group", NULL, 0));
158 assert_ptr_equal(exim_group, native_find_rsc(exim_group, "exim-group", NULL, pe_find_current));
159
160
161 assert_null(native_find_rsc(exim_group, "exim-group", NULL, pe_find_clone));
162 assert_null(native_find_rsc(exim_group, "exim-group", cluster01, pe_find_clone));
163
164
165 assert_null(native_find_rsc(exim_group, "exim-group", cluster01, pe_find_current));
166
167
168 assert_null(native_find_rsc(exim_group, "exim-group", cluster01, 0));
169
170
171 assert_ptr_equal(exim_group, native_find_rsc(exim_group, "exim-group", cluster02, pe_find_current));
172 }
173
174 static void
175 inactive_group_rsc(void **state) {
176 assert_non_null(inactive_group);
177
178
179 assert_ptr_equal(inactive_group, native_find_rsc(inactive_group, "inactive-group", NULL, 0));
180 assert_ptr_equal(inactive_group, native_find_rsc(inactive_group, "inactive-group", NULL, pe_find_current));
181 assert_ptr_equal(inactive_group, native_find_rsc(inactive_group, "inactive-group", NULL, pe_find_inactive));
182
183
184 assert_null(native_find_rsc(inactive_group, "inactive-group", NULL, pe_find_clone));
185 assert_null(native_find_rsc(inactive_group, "inactive-group", cluster01, pe_find_clone));
186
187
188 assert_null(native_find_rsc(inactive_group, "inactive-group", cluster01, pe_find_current));
189 assert_null(native_find_rsc(inactive_group, "inactive-group", cluster02, pe_find_current));
190
191
192 assert_ptr_equal(inactive_group, native_find_rsc(inactive_group, "inactive-group", cluster01, pe_find_inactive));
193
194 assert_ptr_equal(inactive_group, native_find_rsc(inactive_group, "inactive-group", cluster02, pe_find_inactive));
195 }
196
197 static void
198 group_member_rsc(void **state) {
199 pe_resource_t *public_ip = NULL;
200
201
202 for (GList *iter = exim_group->children; iter != NULL; iter = iter->next) {
203 pe_resource_t *rsc = (pe_resource_t *) iter->data;
204
205 if (strcmp(rsc->id, "Public-IP") == 0) {
206 public_ip = rsc;
207 break;
208 }
209 }
210
211 assert_non_null(public_ip);
212
213
214 assert_ptr_equal(public_ip, native_find_rsc(public_ip, "Public-IP", NULL, 0));
215 assert_ptr_equal(public_ip, native_find_rsc(public_ip, "Public-IP", NULL, pe_find_current));
216
217
218 assert_null(native_find_rsc(public_ip, "Public-IP", NULL, pe_find_clone));
219 assert_null(native_find_rsc(public_ip, "Public-IP", cluster02, pe_find_clone));
220
221
222 assert_null(native_find_rsc(public_ip, "Public-IP", cluster01, pe_find_current));
223
224
225 assert_null(native_find_rsc(public_ip, "Public-IP", cluster02, 0));
226
227
228 assert_ptr_equal(public_ip, native_find_rsc(public_ip, "Public-IP", cluster02, pe_find_current));
229 }
230
231 static void
232 inactive_group_member_rsc(void **state) {
233 pe_resource_t *inactive_dummy_1 = NULL;
234
235
236 for (GList *iter = inactive_group->children; iter != NULL; iter = iter->next) {
237 pe_resource_t *rsc = (pe_resource_t *) iter->data;
238
239 if (strcmp(rsc->id, "inactive-dummy-1") == 0) {
240 inactive_dummy_1 = rsc;
241 break;
242 }
243 }
244
245 assert_non_null(inactive_dummy_1);
246
247
248 assert_ptr_equal(inactive_dummy_1, native_find_rsc(inactive_dummy_1, "inactive-dummy-1", NULL, 0));
249 assert_ptr_equal(inactive_dummy_1, native_find_rsc(inactive_dummy_1, "inactive-dummy-1", NULL, pe_find_current));
250
251
252 assert_null(native_find_rsc(inactive_dummy_1, "inactive-dummy-1", NULL, pe_find_clone));
253 assert_null(native_find_rsc(inactive_dummy_1, "inactive-dummy-1", cluster01, pe_find_clone));
254
255
256 assert_null(native_find_rsc(inactive_dummy_1, "inactive-dummy-1", cluster01, pe_find_current));
257 assert_null(native_find_rsc(inactive_dummy_1, "inactive-dummy-1", cluster02, pe_find_current));
258
259
260 assert_ptr_equal(inactive_dummy_1, native_find_rsc(inactive_dummy_1, "inactive-dummy-1", cluster01, pe_find_inactive));
261
262 assert_ptr_equal(inactive_dummy_1, native_find_rsc(inactive_dummy_1, "inactive-dummy-1", cluster02, pe_find_inactive));
263 }
264
265 static void
266 clone_rsc(void **state) {
267 assert_non_null(promotable_clone);
268
269
270 assert_ptr_equal(promotable_clone, native_find_rsc(promotable_clone, "promotable-clone", NULL, 0));
271 assert_ptr_equal(promotable_clone, native_find_rsc(promotable_clone, "promotable-clone", NULL, pe_find_current));
272 assert_ptr_equal(promotable_clone, native_find_rsc(promotable_clone, "promotable-clone", NULL, pe_find_clone));
273
274
275 assert_null(native_find_rsc(promotable_clone, "promotable-clone", cluster01, 0));
276
277
278 assert_ptr_equal(promotable_clone, native_find_rsc(promotable_clone, "promotable-clone", cluster01, pe_find_current));
279
280
281 assert_null(native_find_rsc(promotable_clone, "promotable-clone", cluster02, 0));
282
283
284 assert_ptr_equal(promotable_clone, native_find_rsc(promotable_clone, "promotable-clone", cluster02, pe_find_current));
285
286
287 assert_ptr_equal(promotable_clone, native_find_rsc(promotable_clone, "promotable-clone", cluster01, pe_find_clone|pe_find_current));
288 assert_ptr_equal(promotable_clone, native_find_rsc(promotable_clone, "promotable-clone", cluster02, pe_find_clone|pe_find_current));
289 }
290
291 static void
292 inactive_clone_rsc(void **state) {
293 assert_non_null(inactive_clone);
294
295
296 assert_ptr_equal(inactive_clone, native_find_rsc(inactive_clone, "inactive-clone", NULL, 0));
297 assert_ptr_equal(inactive_clone, native_find_rsc(inactive_clone, "inactive-clone", NULL, pe_find_current));
298 assert_ptr_equal(inactive_clone, native_find_rsc(inactive_clone, "inactive-clone", NULL, pe_find_clone));
299 assert_ptr_equal(inactive_clone, native_find_rsc(inactive_clone, "inactive-clone", NULL, pe_find_inactive));
300
301
302 assert_null(native_find_rsc(inactive_clone, "inactive-clone", cluster01, pe_find_current|pe_find_clone));
303 assert_null(native_find_rsc(inactive_clone, "inactive-clone", cluster02, pe_find_current|pe_find_clone));
304
305
306 assert_ptr_equal(inactive_clone, native_find_rsc(inactive_clone, "inactive-clone", cluster01, pe_find_inactive));
307
308 assert_ptr_equal(inactive_clone, native_find_rsc(inactive_clone, "inactive-clone", cluster02, pe_find_inactive));
309 }
310
311 static void
312 clone_instance_rsc(void **state) {
313 pe_resource_t *promotable_0 = NULL;
314 pe_resource_t *promotable_1 = NULL;
315
316
317 for (GList *iter = promotable_clone->children; iter != NULL; iter = iter->next) {
318 pe_resource_t *rsc = (pe_resource_t *) iter->data;
319
320 if (strcmp(rsc->id, "promotable-rsc:0") == 0) {
321 promotable_0 = rsc;
322 } else if (strcmp(rsc->id, "promotable-rsc:1") == 0) {
323 promotable_1 = rsc;
324 }
325 }
326
327 assert_non_null(promotable_0);
328 assert_non_null(promotable_1);
329
330
331 assert_ptr_equal(promotable_0, native_find_rsc(promotable_0, "promotable-rsc:0", NULL, 0));
332 assert_ptr_equal(promotable_0, native_find_rsc(promotable_0, "promotable-rsc:0", NULL, pe_find_current));
333 assert_ptr_equal(promotable_1, native_find_rsc(promotable_1, "promotable-rsc:1", NULL, 0));
334 assert_ptr_equal(promotable_1, native_find_rsc(promotable_1, "promotable-rsc:1", NULL, pe_find_current));
335
336
337 assert_null(native_find_rsc(promotable_0, "promotable-rsc:0", cluster02, 0));
338 assert_null(native_find_rsc(promotable_1, "promotable-rsc:1", cluster01, 0));
339
340
341 assert_ptr_equal(promotable_0, native_find_rsc(promotable_0, "promotable-rsc:0", cluster02, pe_find_current));
342 assert_null(native_find_rsc(promotable_0, "promotable-rsc:0", cluster01, pe_find_current));
343 assert_ptr_equal(promotable_1, native_find_rsc(promotable_1, "promotable-rsc:1", cluster01, pe_find_current));
344 assert_null(native_find_rsc(promotable_1, "promotable-rsc:1", cluster02, pe_find_current));
345
346
347 assert_ptr_equal(promotable_0, native_find_rsc(promotable_0, "promotable-rsc", NULL, pe_find_clone));
348
349
350 assert_ptr_equal(promotable_0, native_find_rsc(promotable_0, "promotable-rsc", NULL, pe_find_any));
351 assert_ptr_equal(promotable_1, native_find_rsc(promotable_1, "promotable-rsc", NULL, pe_find_any));
352
353
354 assert_ptr_equal(promotable_0, native_find_rsc(promotable_0, "promotable-rsc", NULL, pe_find_anon));
355 assert_ptr_equal(promotable_1, native_find_rsc(promotable_1, "promotable-rsc", NULL, pe_find_anon));
356
357
358 assert_ptr_equal(promotable_0, native_find_rsc(promotable_0, "promotable-rsc", cluster02, pe_find_any|pe_find_current));
359 assert_ptr_equal(promotable_0, native_find_rsc(promotable_0, "promotable-rsc", cluster02, pe_find_anon|pe_find_current));
360 assert_null(native_find_rsc(promotable_0, "promotable-rsc", cluster01, pe_find_any|pe_find_current));
361 assert_null(native_find_rsc(promotable_0, "promotable-rsc", cluster01, pe_find_anon|pe_find_current));
362 assert_ptr_equal(promotable_1, native_find_rsc(promotable_1, "promotable-rsc", cluster01, pe_find_any|pe_find_current));
363 assert_ptr_equal(promotable_1, native_find_rsc(promotable_1, "promotable-rsc", cluster01, pe_find_anon|pe_find_current));
364 assert_null(native_find_rsc(promotable_1, "promotable-rsc", cluster02, pe_find_any|pe_find_current));
365 assert_null(native_find_rsc(promotable_1, "promotable-rsc", cluster02, pe_find_anon|pe_find_current));
366
367
368 assert_null(native_find_rsc(promotable_0, "promotable-rsc", NULL, pe_find_current));
369 assert_null(native_find_rsc(promotable_1, "promotable-rsc", NULL, pe_find_current));
370
371
372
373
374
375
376 assert_null(native_find_rsc(promotable_clone, "promotable-rsc:0", cluster02, 0));
377 assert_null(native_find_rsc(promotable_clone, "promotable-rsc:1", cluster01, 0));
378
379
380 assert_ptr_equal(promotable_0, native_find_rsc(promotable_clone, "promotable-rsc:0", cluster02, pe_find_current));
381 assert_ptr_equal(promotable_0, native_find_rsc(promotable_clone, "promotable-rsc", cluster02, pe_find_any|pe_find_current));
382 assert_ptr_equal(promotable_0, native_find_rsc(promotable_clone, "promotable-rsc", cluster02, pe_find_anon|pe_find_current));
383 assert_ptr_equal(promotable_1, native_find_rsc(promotable_clone, "promotable-rsc:1", cluster01, pe_find_current));
384 assert_ptr_equal(promotable_1, native_find_rsc(promotable_clone, "promotable-rsc", cluster01, pe_find_any|pe_find_current));
385 assert_ptr_equal(promotable_1, native_find_rsc(promotable_clone, "promotable-rsc", cluster01, pe_find_anon|pe_find_current));
386 }
387
388 static void
389 renamed_rsc(void **state) {
390 pe_resource_t *promotable_0 = NULL;
391 pe_resource_t *promotable_1 = NULL;
392
393
394 for (GList *iter = promotable_clone->children; iter != NULL; iter = iter->next) {
395 pe_resource_t *rsc = (pe_resource_t *) iter->data;
396
397 if (strcmp(rsc->id, "promotable-rsc:0") == 0) {
398 promotable_0 = rsc;
399 } else if (strcmp(rsc->id, "promotable-rsc:1") == 0) {
400 promotable_1 = rsc;
401 }
402 }
403
404 assert_non_null(promotable_0);
405 assert_non_null(promotable_1);
406
407
408 assert_ptr_equal(promotable_0, native_find_rsc(promotable_0, "promotable-rsc", NULL, pe_find_renamed));
409 assert_ptr_equal(promotable_1, native_find_rsc(promotable_1, "promotable-rsc", NULL, pe_find_renamed));
410 }
411
412 static void
413 bundle_rsc(void **state) {
414 assert_non_null(httpd_bundle);
415
416
417 assert_ptr_equal(httpd_bundle, native_find_rsc(httpd_bundle, "httpd-bundle", NULL, 0));
418 assert_ptr_equal(httpd_bundle, native_find_rsc(httpd_bundle, "httpd-bundle", NULL, pe_find_current));
419
420
421 assert_null(native_find_rsc(httpd_bundle, "httpd-bundle", NULL, pe_find_clone));
422 assert_null(native_find_rsc(httpd_bundle, "httpd-bundle", cluster01, pe_find_clone));
423
424
425 assert_null(native_find_rsc(httpd_bundle, "httpd-bundle", cluster01, 0));
426
427
428 assert_ptr_equal(httpd_bundle, native_find_rsc(httpd_bundle, "httpd-bundle", cluster01, pe_find_current));
429 }
430
431 static void
432 bundle_replica_rsc(void **state) {
433 pe__bundle_variant_data_t *bundle_data = NULL;
434 pe__bundle_replica_t *replica_0 = NULL;
435
436 pe_resource_t *ip_0 = NULL;
437 pe_resource_t *child_0 = NULL;
438 pe_resource_t *container_0 = NULL;
439 pe_resource_t *remote_0 = NULL;
440
441 get_bundle_variant_data(bundle_data, httpd_bundle);
442 replica_0 = (pe__bundle_replica_t *) bundle_data->replicas->data;
443
444 ip_0 = replica_0->ip;
445 child_0 = replica_0->child;
446 container_0 = replica_0->container;
447 remote_0 = replica_0->remote;
448
449 assert_non_null(ip_0);
450 assert_non_null(child_0);
451 assert_non_null(container_0);
452 assert_non_null(remote_0);
453
454
455 assert_ptr_equal(ip_0, native_find_rsc(ip_0, "httpd-bundle-ip-192.168.122.131", NULL, 0));
456 assert_ptr_equal(child_0, native_find_rsc(child_0, "httpd:0", NULL, 0));
457 assert_ptr_equal(container_0, native_find_rsc(container_0, "httpd-bundle-docker-0", NULL, 0));
458 assert_ptr_equal(remote_0, native_find_rsc(remote_0, "httpd-bundle-0", NULL, 0));
459
460
461 assert_null(native_find_rsc(ip_0, "httpd-bundle-ip-192.168.122.131", cluster01, 0));
462 assert_null(native_find_rsc(child_0, "httpd:0", httpd_bundle_0, 0));
463 assert_null(native_find_rsc(container_0, "httpd-bundle-docker-0", cluster01, 0));
464 assert_null(native_find_rsc(remote_0, "httpd-bundle-0", cluster01, 0));
465
466
467 assert_ptr_equal(ip_0, native_find_rsc(ip_0, "httpd-bundle-ip-192.168.122.131", cluster01, pe_find_current));
468 assert_null(native_find_rsc(ip_0, "httpd-bundle-ip-192.168.122.131", cluster02, pe_find_current));
469 assert_null(native_find_rsc(ip_0, "httpd-bundle-ip-192.168.122.131", httpd_bundle_0, pe_find_current));
470 assert_ptr_equal(child_0, native_find_rsc(child_0, "httpd:0", httpd_bundle_0, pe_find_current));
471 assert_null(native_find_rsc(child_0, "httpd:0", cluster01, pe_find_current));
472 assert_null(native_find_rsc(child_0, "httpd:0", cluster02, pe_find_current));
473 assert_ptr_equal(container_0, native_find_rsc(container_0, "httpd-bundle-docker-0", cluster01, pe_find_current));
474 assert_null(native_find_rsc(container_0, "httpd-bundle-docker-0", cluster02, pe_find_current));
475 assert_null(native_find_rsc(container_0, "httpd-bundle-docker-0", httpd_bundle_0, pe_find_current));
476 assert_ptr_equal(remote_0, native_find_rsc(remote_0, "httpd-bundle-0", cluster01, pe_find_current));
477 assert_null(native_find_rsc(remote_0, "httpd-bundle-0", cluster02, pe_find_current));
478 assert_null(native_find_rsc(remote_0, "httpd-bundle-0", httpd_bundle_0, pe_find_current));
479
480
481 assert_ptr_equal(child_0, native_find_rsc(child_0, "httpd", NULL, pe_find_any));
482
483
484 assert_ptr_equal(child_0, native_find_rsc(child_0, "httpd", NULL, pe_find_anon));
485
486
487 assert_ptr_equal(child_0, native_find_rsc(child_0, "httpd", httpd_bundle_0, pe_find_any|pe_find_current));
488 assert_ptr_equal(child_0, native_find_rsc(child_0, "httpd", httpd_bundle_0, pe_find_anon|pe_find_current));
489 assert_null(native_find_rsc(child_0, "httpd", cluster01, pe_find_any|pe_find_current));
490 assert_null(native_find_rsc(child_0, "httpd", cluster01, pe_find_anon|pe_find_current));
491 assert_null(native_find_rsc(child_0, "httpd", cluster02, pe_find_any|pe_find_current));
492 assert_null(native_find_rsc(child_0, "httpd", cluster02, pe_find_anon|pe_find_current));
493
494
495 assert_null(native_find_rsc(child_0, "httpd", NULL, pe_find_current));
496
497
498
499
500
501
502 assert_null(native_find_rsc(httpd_bundle, "httpd-bundle-ip-192.168.122.131", cluster01, 0));
503 assert_null(native_find_rsc(httpd_bundle, "httpd:0", httpd_bundle_0, 0));
504 assert_null(native_find_rsc(httpd_bundle, "httpd-bundle-docker-0", cluster01, 0));
505 assert_null(native_find_rsc(httpd_bundle, "httpd-bundle-0", cluster01, 0));
506
507
508 assert_ptr_equal(ip_0, native_find_rsc(httpd_bundle, "httpd-bundle-ip-192.168.122.131", cluster01, pe_find_current));
509 assert_ptr_equal(child_0, native_find_rsc(httpd_bundle, "httpd:0", httpd_bundle_0, pe_find_current));
510 assert_ptr_equal(container_0, native_find_rsc(httpd_bundle, "httpd-bundle-docker-0", cluster01, pe_find_current));
511 assert_ptr_equal(remote_0, native_find_rsc(httpd_bundle, "httpd-bundle-0", cluster01, pe_find_current));
512 }
513
514 static void
515 clone_group_rsc(void **rsc) {
516 assert_non_null(mysql_clone_group);
517
518
519 assert_ptr_equal(mysql_clone_group, native_find_rsc(mysql_clone_group, "mysql-clone-group", NULL, 0));
520 assert_ptr_equal(mysql_clone_group, native_find_rsc(mysql_clone_group, "mysql-clone-group", NULL, pe_find_current));
521 assert_ptr_equal(mysql_clone_group, native_find_rsc(mysql_clone_group, "mysql-clone-group", NULL, pe_find_clone));
522
523
524 assert_null(native_find_rsc(mysql_clone_group, "mysql-clone-group", cluster01, 0));
525
526
527 assert_ptr_equal(mysql_clone_group, native_find_rsc(mysql_clone_group, "mysql-clone-group", cluster01, pe_find_current));
528
529
530 assert_null(native_find_rsc(mysql_clone_group, "mysql-clone-group", cluster02, 0));
531
532
533 assert_ptr_equal(mysql_clone_group, native_find_rsc(mysql_clone_group, "mysql-clone-group", cluster02, pe_find_current));
534
535
536 assert_ptr_equal(mysql_clone_group, native_find_rsc(mysql_clone_group, "mysql-clone-group", cluster01, pe_find_clone|pe_find_current));
537 assert_ptr_equal(mysql_clone_group, native_find_rsc(mysql_clone_group, "mysql-clone-group", cluster02, pe_find_clone|pe_find_current));
538 }
539
540 static void
541 clone_group_instance_rsc(void **rsc) {
542 pe_resource_t *mysql_group_0 = NULL;
543 pe_resource_t *mysql_group_1 = NULL;
544
545
546 for (GList *iter = mysql_clone_group->children; iter != NULL; iter = iter->next) {
547 pe_resource_t *rsc = (pe_resource_t *) iter->data;
548
549 if (strcmp(rsc->id, "mysql-group:0") == 0) {
550 mysql_group_0 = rsc;
551 } else if (strcmp(rsc->id, "mysql-group:1") == 0) {
552 mysql_group_1 = rsc;
553 }
554 }
555
556 assert_non_null(mysql_group_0);
557 assert_non_null(mysql_group_1);
558
559
560 assert_ptr_equal(mysql_group_0, native_find_rsc(mysql_group_0, "mysql-group:0", NULL, 0));
561 assert_ptr_equal(mysql_group_0, native_find_rsc(mysql_group_0, "mysql-group:0", NULL, pe_find_current));
562 assert_ptr_equal(mysql_group_1, native_find_rsc(mysql_group_1, "mysql-group:1", NULL, 0));
563 assert_ptr_equal(mysql_group_1, native_find_rsc(mysql_group_1, "mysql-group:1", NULL, pe_find_current));
564
565
566 assert_null(native_find_rsc(mysql_group_0, "mysql-group:0", cluster02, 0));
567 assert_null(native_find_rsc(mysql_group_1, "mysql-group:1", cluster01, 0));
568
569
570 assert_ptr_equal(mysql_group_0, native_find_rsc(mysql_group_0, "mysql-group:0", cluster02, pe_find_current));
571 assert_null(native_find_rsc(mysql_group_0, "mysql-group:0", cluster01, pe_find_current));
572 assert_ptr_equal(mysql_group_1, native_find_rsc(mysql_group_1, "mysql-group:1", cluster01, pe_find_current));
573 assert_null(native_find_rsc(mysql_group_1, "mysql-group:1", cluster02, pe_find_current));
574
575
576 assert_ptr_equal(mysql_group_0, native_find_rsc(mysql_group_0, "mysql-group" , NULL, pe_find_clone));
577
578
579 assert_ptr_equal(mysql_group_0, native_find_rsc(mysql_group_0, "mysql-group" , NULL, pe_find_any));
580 assert_ptr_equal(mysql_group_1, native_find_rsc(mysql_group_1, "mysql-group" , NULL, pe_find_any));
581
582
583 assert_ptr_equal(mysql_group_0, native_find_rsc(mysql_group_0, "mysql-group" , NULL, pe_find_anon));
584 assert_ptr_equal(mysql_group_1, native_find_rsc(mysql_group_1, "mysql-group" , NULL, pe_find_anon));
585
586
587 assert_ptr_equal(mysql_group_0, native_find_rsc(mysql_group_0, "mysql-group", cluster02, pe_find_any|pe_find_current));
588 assert_ptr_equal(mysql_group_0, native_find_rsc(mysql_group_0, "mysql-group", cluster02, pe_find_anon|pe_find_current));
589 assert_null(native_find_rsc(mysql_group_0, "mysql-group", cluster01, pe_find_any|pe_find_current));
590 assert_null(native_find_rsc(mysql_group_0, "mysql-group", cluster01, pe_find_anon|pe_find_current));
591 assert_ptr_equal(mysql_group_1, native_find_rsc(mysql_group_1, "mysql-group", cluster01, pe_find_any|pe_find_current));
592 assert_ptr_equal(mysql_group_1, native_find_rsc(mysql_group_1, "mysql-group", cluster01, pe_find_anon|pe_find_current));
593 assert_null(native_find_rsc(mysql_group_1, "mysql-group", cluster02, pe_find_any|pe_find_current));
594 assert_null(native_find_rsc(mysql_group_1, "mysql-group", cluster02, pe_find_anon|pe_find_current));
595
596
597 assert_null(native_find_rsc(mysql_group_0, "mysql-group", NULL, pe_find_current));
598 assert_null(native_find_rsc(mysql_group_1, "mysql-group", NULL, pe_find_current));
599
600
601
602
603
604
605 assert_null(native_find_rsc(mysql_clone_group, "mysql-group:0", cluster02, 0));
606 assert_null(native_find_rsc(mysql_clone_group, "mysql-group:1", cluster01, 0));
607
608
609 assert_ptr_equal(mysql_group_0, native_find_rsc(mysql_clone_group, "mysql-group:0", cluster02, pe_find_current));
610 assert_ptr_equal(mysql_group_0, native_find_rsc(mysql_clone_group, "mysql-group", cluster02, pe_find_any|pe_find_current));
611 assert_ptr_equal(mysql_group_0, native_find_rsc(mysql_clone_group, "mysql-group", cluster02, pe_find_anon|pe_find_current));
612 assert_ptr_equal(mysql_group_1, native_find_rsc(mysql_clone_group, "mysql-group:1", cluster01, pe_find_current));
613 assert_ptr_equal(mysql_group_1, native_find_rsc(mysql_clone_group, "mysql-group", cluster01, pe_find_any|pe_find_current));
614 assert_ptr_equal(mysql_group_1, native_find_rsc(mysql_clone_group, "mysql-group", cluster01, pe_find_anon|pe_find_current));
615 }
616
617 static void
618 clone_group_member_rsc(void **state) {
619 pe_resource_t *mysql_proxy = NULL;
620
621
622 for (GList *iter = mysql_clone_group->children; iter != NULL; iter = iter->next) {
623 pe_resource_t *rsc = (pe_resource_t *) iter->data;
624
625 if (strcmp(rsc->id, "mysql-group:0") == 0) {
626 for (GList *iter2 = rsc->children; iter2 != NULL; iter2 = iter2->next) {
627 pe_resource_t *child = (pe_resource_t *) iter2->data;
628
629 if (strcmp(child->id, "mysql-proxy:0") == 0) {
630 mysql_proxy = child;
631 break;
632 }
633 }
634
635 break;
636 }
637 }
638
639 assert_non_null(mysql_proxy);
640
641
642 assert_ptr_equal(mysql_proxy, native_find_rsc(mysql_proxy, "mysql-proxy:0", NULL, 0));
643 assert_ptr_equal(mysql_proxy, native_find_rsc(mysql_proxy, "mysql-proxy:0", NULL, pe_find_current));
644
645
646 assert_ptr_equal(mysql_proxy, native_find_rsc(mysql_proxy, "mysql-proxy:0", NULL, pe_find_clone));
647 assert_ptr_equal(mysql_proxy, native_find_rsc(mysql_proxy, "mysql-proxy:0", cluster02, pe_find_clone|pe_find_current));
648
649
650 assert_null(native_find_rsc(mysql_proxy, "mysql-proxy:0", cluster01, pe_find_current));
651
652
653 assert_null(native_find_rsc(mysql_proxy, "mysql-proxy:0", cluster02, 0));
654
655
656 assert_ptr_equal(mysql_proxy, native_find_rsc(mysql_proxy, "mysql-proxy:0", cluster02, pe_find_current));
657 }
658
659
660
661
662 PCMK__UNIT_TEST(setup, teardown,
663 cmocka_unit_test(bad_args),
664 cmocka_unit_test(primitive_rsc),
665 cmocka_unit_test(group_rsc),
666 cmocka_unit_test(inactive_group_rsc),
667 cmocka_unit_test(group_member_rsc),
668 cmocka_unit_test(inactive_group_member_rsc),
669 cmocka_unit_test(clone_rsc),
670 cmocka_unit_test(inactive_clone_rsc),
671 cmocka_unit_test(clone_instance_rsc),
672 cmocka_unit_test(renamed_rsc),
673 cmocka_unit_test(bundle_rsc),
674 cmocka_unit_test(bundle_replica_rsc),
675 cmocka_unit_test(clone_group_rsc),
676 cmocka_unit_test(clone_group_instance_rsc),
677 cmocka_unit_test(clone_group_member_rsc))