root/lib/common/tests/actions/pcmk_xe_mask_probe_failure_test.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. op_is_not_probe_test
  2. op_does_not_have_right_values_test
  3. check_values_test

   1 /*
   2  * Copyright 2021 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 
  12 #include <crm/common/unittest_internal.h>
  13 
  14 static void
  15 op_is_not_probe_test(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  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 
  22     node = string2xml("<lrm_rsc_op operation=\"start\" interval=\"0\"/>");
  23     assert_false(pcmk_xe_mask_probe_failure(node));
  24     free_xml(node);
  25 }
  26 
  27 static void
  28 op_does_not_have_right_values_test(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  29     xmlNode *node = NULL;
  30 
  31     node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\"/>");
  32     assert_false(pcmk_xe_mask_probe_failure(node));
  33     free_xml(node);
  34 
  35     node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"0\" op-status=\"\"/>");
  36     assert_false(pcmk_xe_mask_probe_failure(node));
  37     free_xml(node);
  38 }
  39 
  40 static void
  41 check_values_test(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  42     xmlNode *node = NULL;
  43 
  44     /* PCMK_EXEC_NOT_SUPPORTED */
  45     node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"0\" op-status=\"3\"/>");
  46     assert_false(pcmk_xe_mask_probe_failure(node));
  47     free_xml(node);
  48 
  49     node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"5\" op-status=\"3\"/>");
  50     assert_true(pcmk_xe_mask_probe_failure(node));
  51     free_xml(node);
  52 
  53     /* PCMK_EXEC_DONE */
  54     node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"0\" op-status=\"0\"/>");
  55     assert_false(pcmk_xe_mask_probe_failure(node));
  56     free_xml(node);
  57 
  58     node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"2\" op-status=\"0\"/>");
  59     assert_true(pcmk_xe_mask_probe_failure(node));
  60     free_xml(node);
  61 
  62     node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"5\" op-status=\"0\"/>");
  63     assert_true(pcmk_xe_mask_probe_failure(node));
  64     free_xml(node);
  65 
  66     node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"6\" op-status=\"0\"/>");
  67     assert_false(pcmk_xe_mask_probe_failure(node));
  68     free_xml(node);
  69 
  70     node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"7\" op-status=\"0\"/>");
  71     assert_false(pcmk_xe_mask_probe_failure(node));
  72     free_xml(node);
  73 
  74     /* PCMK_EXEC_NOT_INSTALLED */
  75     node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"0\" op-status=\"7\"/>");
  76     assert_true(pcmk_xe_mask_probe_failure(node));
  77     free_xml(node);
  78 
  79     node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"5\" op-status=\"7\"/>");
  80     assert_true(pcmk_xe_mask_probe_failure(node));
  81     free_xml(node);
  82 
  83     /* PCMK_EXEC_ERROR */
  84     node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"0\" op-status=\"4\"/>");
  85     assert_false(pcmk_xe_mask_probe_failure(node));
  86     free_xml(node);
  87 
  88     node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"2\" op-status=\"4\"/>");
  89     assert_true(pcmk_xe_mask_probe_failure(node));
  90     free_xml(node);
  91 
  92     node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"5\" op-status=\"4\"/>");
  93     assert_true(pcmk_xe_mask_probe_failure(node));
  94     free_xml(node);
  95 
  96     node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"6\" op-status=\"4\"/>");
  97     assert_false(pcmk_xe_mask_probe_failure(node));
  98     free_xml(node);
  99 
 100     node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"7\" op-status=\"4\"/>");
 101     assert_false(pcmk_xe_mask_probe_failure(node));
 102     free_xml(node);
 103 
 104     /* PCMK_EXEC_ERROR_HARD */
 105     node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"0\" op-status=\"5\"/>");
 106     assert_false(pcmk_xe_mask_probe_failure(node));
 107     free_xml(node);
 108 
 109     node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"2\" op-status=\"5\"/>");
 110     assert_true(pcmk_xe_mask_probe_failure(node));
 111     free_xml(node);
 112 
 113     node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"5\" op-status=\"5\"/>");
 114     assert_true(pcmk_xe_mask_probe_failure(node));
 115     free_xml(node);
 116 
 117     node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"6\" op-status=\"5\"/>");
 118     assert_false(pcmk_xe_mask_probe_failure(node));
 119     free_xml(node);
 120 
 121     node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"7\" op-status=\"5\"/>");
 122     assert_false(pcmk_xe_mask_probe_failure(node));
 123     free_xml(node);
 124 
 125     /* PCMK_EXEC_ERROR_FATAL */
 126     node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"0\" op-status=\"6\"/>");
 127     assert_false(pcmk_xe_mask_probe_failure(node));
 128     free_xml(node);
 129 
 130     node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"2\" op-status=\"6\"/>");
 131     assert_true(pcmk_xe_mask_probe_failure(node));
 132     free_xml(node);
 133 
 134     node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"5\" op-status=\"6\"/>");
 135     assert_true(pcmk_xe_mask_probe_failure(node));
 136     free_xml(node);
 137 
 138     node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"6\" op-status=\"6\"/>");
 139     assert_false(pcmk_xe_mask_probe_failure(node));
 140     free_xml(node);
 141 
 142     node = string2xml("<lrm_rsc_op operation=\"monitor\" interval=\"0\" rc-code=\"7\" op-status=\"6\"/>");
 143     assert_false(pcmk_xe_mask_probe_failure(node));
 144     free_xml(node);
 145 }
 146 
 147 PCMK__UNIT_TEST(NULL, NULL,
 148                 cmocka_unit_test(op_is_not_probe_test),
 149                 cmocka_unit_test(op_does_not_have_right_values_test),
 150                 cmocka_unit_test(check_values_test))

/* [previous][next][first][last][top][bottom][index][help] */