示例#1
0
 def test_group(self):
     obj = lib.ResourceRelationsFetcher(
         fixture_cib(
             """
         <group id="g1">
           <primitive id="d1" class="c" provider="pcmk" type="Dummy"/>
           <primitive id="d2" class="c" provider="pcmk" type="Dummy"/>
         </group>
         """,
             "",
         ))
     expected = (
         {
             "d1":
             RelationEntityDto(
                 "d1",
                 ResourceRelationType.RSC_PRIMITIVE,
                 ["outer:g1"],
                 fixture_dummy_metadata("d1"),
             ),
             "d2":
             RelationEntityDto(
                 "d2",
                 ResourceRelationType.RSC_PRIMITIVE,
                 ["outer:g1"],
                 fixture_dummy_metadata("d2"),
             ),
             "g1":
             RelationEntityDto(
                 "g1",
                 ResourceRelationType.RSC_GROUP,
                 ["inner:g1"],
                 {"id": "g1"},
             ),
         },
         {
             "inner:g1":
             RelationEntityDto(
                 "inner:g1",
                 ResourceRelationType.INNER_RESOURCES,
                 ["d1", "d2"],
                 {"id": "g1"},
             ),
             "outer:g1":
             RelationEntityDto(
                 "outer:g1",
                 ResourceRelationType.OUTER_RESOURCE,
                 ["g1"],
                 {"id": "g1"},
             ),
         },
     )
     for res in ("d1", "d2", "g1"):
         with self.subTest(resource=res):
             self.assertEqual(expected, obj.get_relations(res))
示例#2
0
 def test_ordering_constraint(self):
     obj = lib.ResourceRelationsFetcher(
         fixture_cib(
             """
         <primitive id="d1" class="c" provider="pcmk" type="Dummy"/>
         <primitive id="d2" class="c" provider="pcmk" type="Dummy"/>
         """,
             """
         <rsc_order first="d1" first-action="start"
             id="order-d1-d2-mandatory" then="d2" then-action="start"
             kind="Mandatory"/>
         """,
         ))
     expected = (
         {
             "d1":
             RelationEntityDto(
                 "d1",
                 ResourceRelationType.RSC_PRIMITIVE,
                 ["order-d1-d2-mandatory"],
                 fixture_dummy_metadata("d1"),
             ),
             "d2":
             RelationEntityDto(
                 "d2",
                 ResourceRelationType.RSC_PRIMITIVE,
                 ["order-d1-d2-mandatory"],
                 fixture_dummy_metadata("d2"),
             ),
         },
         {
             "order-d1-d2-mandatory":
             RelationEntityDto(
                 "order-d1-d2-mandatory",
                 ResourceRelationType.ORDER,
                 members=["d1", "d2"],
                 metadata={
                     "id": "order-d1-d2-mandatory",
                     "first": "d1",
                     "first-action": "start",
                     "then": "d2",
                     "then-action": "start",
                     "kind": "Mandatory",
                 },
             ),
         },
     )
     for res in ("d1", "d2"):
         with self.subTest(resource=res):
             self.assertEqual(expected, obj.get_relations(res))
示例#3
0
 def _test_wrapper(self, wrapper_tag):
     obj = lib.ResourceRelationsFetcher(
         fixture_cib(
             f"""
         <{wrapper_tag} id="w1">
           <primitive id="d1" class="c" provider="pcmk" type="Dummy"/>
         </{wrapper_tag}>
         """,
             "",
         ))
     expected = (
         {
             "d1":
             RelationEntityDto(
                 "d1",
                 "primitive",
                 ["outer:w1"],
                 fixture_dummy_metadata("d1"),
             ),
             "w1":
             RelationEntityDto("w1", wrapper_tag, ["inner:w1"],
                               {"id": "w1"}),
         },
         {
             "inner:w1":
             RelationEntityDto(
                 "inner:w1",
                 ResourceRelationType.INNER_RESOURCES,
                 ["d1"],
                 {"id": "w1"},
             ),
             "outer:w1":
             RelationEntityDto(
                 "outer:w1",
                 ResourceRelationType.OUTER_RESOURCE,
                 ["w1"],
                 {"id": "w1"},
             ),
         },
     )
     for res in ("d1", "w1"):
         with self.subTest(resource=res):
             self.assertEqual(expected, obj.get_relations(res))
示例#4
0
 def test_ordering_set_constraint(self):
     obj = lib.ResourceRelationsFetcher(
         fixture_cib(
             """
         <primitive id="d1" class="c" provider="pcmk" type="Dummy"/>
         <primitive id="d2" class="c" provider="pcmk" type="Dummy"/>
         <primitive id="d3" class="c" provider="pcmk" type="Dummy"/>
         <primitive id="d4" class="c" provider="pcmk" type="Dummy"/>
         <primitive id="d5" class="c" provider="pcmk" type="Dummy"/>
         <primitive id="d6" class="c" provider="pcmk" type="Dummy"/>
         """,
             """
         <rsc_order kind="Serialize" symmetrical="true"
             id="pcs_rsc_order_set_1">
           <resource_set sequential="true" require-all="true" action="start"
               id="pcs_rsc_set_1">
             <resource_ref id="d1"/>
             <resource_ref id="d3"/>
             <resource_ref id="d2"/>
           </resource_set>
           <resource_set action="stop" sequential="false"
               require-all="false" id="pcs_rsc_set_2">
             <resource_ref id="d6"/>
             <resource_ref id="d5"/>
             <resource_ref id="d4"/>
           </resource_set>
         </rsc_order>
         """,
         ))
     rsc_entity = lambda _id: RelationEntityDto(
         _id,
         ResourceRelationType.RSC_PRIMITIVE,
         ["pcs_rsc_order_set_1"],
         fixture_dummy_metadata(_id),
     )
     res_list = ("d1", "d2", "d3", "d4", "d5", "d6")
     expected = (
         {_id: rsc_entity(_id)
          for _id in res_list},
         {
             "pcs_rsc_order_set_1":
             RelationEntityDto(
                 "pcs_rsc_order_set_1",
                 ResourceRelationType.ORDER_SET,
                 members=["d1", "d2", "d3", "d4", "d5", "d6"],
                 metadata={
                     "id":
                     "pcs_rsc_order_set_1",
                     "sets": [
                         {
                             "id": "pcs_rsc_set_1",
                             "metadata": {
                                 "id": "pcs_rsc_set_1",
                                 "sequential": "true",
                                 "require-all": "true",
                                 "action": "start",
                             },
                             "members": ["d1", "d3", "d2"],
                         },
                         {
                             "id": "pcs_rsc_set_2",
                             "metadata": {
                                 "id": "pcs_rsc_set_2",
                                 "sequential": "false",
                                 "require-all": "false",
                                 "action": "stop",
                             },
                             "members": ["d6", "d5", "d4"],
                         },
                     ],
                     "kind":
                     "Serialize",
                     "symmetrical":
                     "true",
                 },
             ),
         },
     )
     for res in res_list:
         with self.subTest(resource=res):
             self.assertEqual(expected, obj.get_relations(res))