Example #1
0
 def test_multiple_alerts(self):
     self.config.env.push_cib(remove=[
         "./configuration/alerts/alert[@id='alert1']",
         "./configuration/alerts/alert[@id='alert3']",
         "./configuration/alerts/alert[@id='alert4']",
     ])
     cmd_alert.remove_alert(self.env_assist.get_env(),
                            ["alert1", "alert3", "alert4"])
Example #2
0
 def test_one_alert(self):
     self.config.env.push_cib(
         remove="./configuration/alerts/alert[@id='alert2']"
     )
     cmd_alert.remove_alert(
         self.env_assist.get_env(),
         ["alert2"]
     )
Example #3
0
 def test_one_alert(self):
     self.config.env.push_cib(
         remove="./configuration/alerts/alert[@id='alert2']"
     )
     cmd_alert.remove_alert(
         self.env_assist.get_env(),
         ["alert2"]
     )
Example #4
0
 def test_success(self):
     cmd_alert.remove_alert(self.mock_env, "alert")
     assert_xml_equal(
         """
             <cib validate-with="pacemaker-2.5">
                 <configuration>
                     <alerts>
                         <alert id="alert-1" path="/path"/>
                     </alerts>
                 </configuration>
             </cib>
         """, self.mock_env._get_cib_xml())
Example #5
0
 def test_multiple_alerts(self):
     self.config.env.push_cib(
         remove=[
             "./configuration/alerts/alert[@id='alert1']",
             "./configuration/alerts/alert[@id='alert3']",
             "./configuration/alerts/alert[@id='alert4']",
         ]
     )
     cmd_alert.remove_alert(
         self.env_assist.get_env(),
         ["alert1", "alert3", "alert4"]
     )
Example #6
0
 def test_multiple_alerts(self):
     cmd_alert.remove_alert(self.mock_env, ["alert1", "alert3", "alert4"])
     assert_xml_equal(
         """
             <cib validate-with="pacemaker-2.5">
                 <configuration>
                     <alerts>
                         <alert id="alert2" path="/path"/>
                     </alerts>
                 </configuration>
             </cib>
         """, self.mock_env._get_cib_xml())
     self.assertEqual([], self.mock_rep.report_item_list)
Example #7
0
 def test_success(self):
     cmd_alert.remove_alert(self.mock_env, "alert")
     assert_xml_equal(
         """
             <cib validate-with="pacemaker-2.5">
                 <configuration>
                     <alerts>
                         <alert id="alert-1" path="/path"/>
                     </alerts>
                 </configuration>
             </cib>
         """,
         self.mock_env._get_cib_xml()
     )
Example #8
0
 def test_multiple_alerts(self):
     cmd_alert.remove_alert(self.mock_env, ["alert1", "alert3", "alert4"])
     assert_xml_equal(
         """
             <cib validate-with="pacemaker-2.5">
                 <configuration>
                     <alerts>
                         <alert id="alert2" path="/path"/>
                     </alerts>
                 </configuration>
             </cib>
         """,
         self.mock_env._get_cib_xml()
     )
     self.assertEqual([], self.mock_rep.report_item_list)
Example #9
0
 def test_alerts_dont_exist(self):
     self.env_assist.assert_raise_library_error(
         lambda: cmd_alert.remove_alert(
             self.env_assist.get_env(),
             ["unknown1", "alert1", "unknown2", "alert2"]
         ),
         [
             (
                 Severities.ERROR,
                 report_codes.ID_NOT_FOUND,
                 {
                     "context_type": "alerts",
                     "context_id": "",
                     "id": "unknown1",
                     "expected_types": ["alert"],
                 },
                 None
             ),
             (
                 Severities.ERROR,
                 report_codes.ID_NOT_FOUND,
                 {
                     "context_type": "alerts",
                     "context_id": "",
                     "id": "unknown2",
                     "expected_types": ["alert"],
                 },
                 None
             ),
         ],
         expected_in_processor=True
     )
Example #10
0
 def test_alerts_dont_exist(self):
     self.env_assist.assert_raise_library_error(
         lambda: cmd_alert.remove_alert(
             self.env_assist.get_env(),
             ["unknown1", "alert1", "unknown2", "alert2"],
         ))
     self.env_assist.assert_reports([
         (
             Severities.ERROR,
             report_codes.ID_NOT_FOUND,
             {
                 "context_type": "alerts",
                 "context_id": "",
                 "id": "unknown1",
                 "expected_types": ["alert"],
             },
             None,
         ),
         (
             Severities.ERROR,
             report_codes.ID_NOT_FOUND,
             {
                 "context_type": "alerts",
                 "context_id": "",
                 "id": "unknown2",
                 "expected_types": ["alert"],
             },
             None,
         ),
     ])
Example #11
0
 def test_not_existing_alert(self):
     assert_raise_library_error(
         lambda: cmd_alert.remove_alert(self.mock_env, "unknown"),
         (
             Severities.ERROR,
             report_codes.CIB_ALERT_NOT_FOUND,
             {"alert": "unknown"}
         )
     )
Example #12
0
 def test_failure(self):
     report_list = [(Severities.ERROR, report_codes.ID_NOT_FOUND, {
         "id": "unknown"
     }), (Severities.ERROR, report_codes.ID_NOT_FOUND, {
         "id": "unknown2"
     })]
     assert_raise_library_error(
         lambda: cmd_alert.remove_alert(
             self.mock_env, ["unknown", "alert1", "unknown2", "alert2"]),
         *report_list)
     assert_report_item_list_equal(self.mock_rep.report_item_list,
                                   report_list)
Example #13
0
 def test_alerts_dont_exist(self):
     self.env_assist.assert_raise_library_error(
         lambda: cmd_alert.remove_alert(self.env_assist.get_env(
         ), ["unknown1", "alert1", "unknown2", "alert2"]), [
             (Severities.ERROR, report_codes.ID_NOT_FOUND, {
                 "context_type": "alerts",
                 "context_id": "",
                 "id": "unknown1",
                 "id_description": "alert",
             }, None),
             (Severities.ERROR, report_codes.ID_NOT_FOUND, {
                 "context_type": "alerts",
                 "context_id": "",
                 "id": "unknown2",
                 "id_description": "alert",
             }, None),
         ],
         expected_in_processor=True)
Example #14
0
 def test_failure(self):
     report_list = [
         (
             Severities.ERROR,
             report_codes.ID_NOT_FOUND,
             {"id": "unknown"}
         ),
         (
             Severities.ERROR,
             report_codes.ID_NOT_FOUND,
             {"id": "unknown2"}
         )
     ]
     assert_raise_library_error(
         lambda: cmd_alert.remove_alert(
             self.mock_env, ["unknown", "alert1", "unknown2", "alert2"]
         ),
         *report_list
     )
     assert_report_item_list_equal(
         self.mock_rep.report_item_list, report_list
     )
Example #15
0
 def test_no_alert(self):
     self.config.env.push_cib()
     cmd_alert.remove_alert(self.env_assist.get_env(), [])
Example #16
0
 def test_no_alert(self):
     self.config.env.push_cib()
     cmd_alert.remove_alert(
         self.env_assist.get_env(),
         []
     )
Example #17
0
 def test_not_existing_alert(self):
     assert_raise_library_error(
         lambda: cmd_alert.remove_alert(self.mock_env, "unknown"),
         (Severities.ERROR, report_codes.CIB_ALERT_NOT_FOUND, {
             "alert": "unknown"
         }))