コード例 #1
0
ファイル: TestHaplib.py プロジェクト: saruvitz-life/hatohol
 def test_create(self):
     arm_info = haplib.ArmInfo()
     self.assertEquals("", arm_info.last_status)
     self.assertEquals("", arm_info.failure_reason)
     self.assertEquals("", arm_info.last_success_time)
     self.assertEquals("", arm_info.last_failure_time)
     self.assertEquals(0, arm_info.num_success)
     self.assertEquals(0, arm_info.num_failure)
コード例 #2
0
ファイル: TestHaplib.py プロジェクト: saruvitz-life/hatohol
 def test_log_status(self):
     poller = haplib.BasePoller(sender=self.sender, process_id="test")
     log_time = testutils.get_priv_attr(poller, "__next_log_status_time")
     poller.log_status(haplib.ArmInfo())
     # check if the next time is update
     new_time = testutils.get_priv_attr(poller, "__next_log_status_time")
     self.assertGreater(new_time, log_time)
     # call again soon. __new_log_status_time should not be updated.
     new_time2 = testutils.get_priv_attr(poller, "__next_log_status_time")
     self.assertEquals(new_time2, new_time)
コード例 #3
0
ファイル: TestHaplib.py プロジェクト: saruvitz-life/hatohol
 def test_success(self):
     arm_info = haplib.ArmInfo()
     time0 = float(hapcommon.get_current_hatohol_time())
     arm_info.success()
     time1 = float(hapcommon.get_current_hatohol_time())
     self.assertEquals(arm_info.last_status, "OK")
     self.assertEquals(arm_info.num_success, 1)
     arm_info_time = float(arm_info.last_success_time)
     self.assertGreaterEqual(arm_info_time, time0)
     self.assertGreaterEqual(time1, arm_info_time)
コード例 #4
0
ファイル: TestHaplib.py プロジェクト: saruvitz-life/hatohol
 def test_poll_in_block(self):
     poll_in_try_block = testutils.get_priv_attr(self.poller,
                                                 "__poll_in_try_block")
     arm_info = haplib.ArmInfo()
     self.poller.set_dispatch_queue(DummyQueue())
     self.poller._HapiProcessor__reply_queue = DummyQueue()
     org_q = self.poller._BasePoller__command_queue._CommandQueue__q
     self.poller._BasePoller__command_queue._CommandQueue__q =\
                                                     DummyCommandQueue()
     testutils.assertNotRaises(poll_in_try_block, arm_info)
     self.poller._BasePoller__command_queue._CommandQueue__q = org_q
コード例 #5
0
ファイル: TestHaplib.py プロジェクト: saruvitz-life/hatohol
 def test_fail(self):
     arm_info = haplib.ArmInfo()
     time0 = float(hapcommon.get_current_hatohol_time())
     arm_info.fail("Reason")
     time1 = float(hapcommon.get_current_hatohol_time())
     self.assertEquals(arm_info.last_status, "NG")
     self.assertEquals(arm_info.failure_reason, "Reason")
     self.assertEquals(arm_info.num_failure, 1)
     arm_info_time = float(arm_info.last_failure_time)
     self.assertGreaterEqual(arm_info_time, time0)
     self.assertGreaterEqual(time1, arm_info_time)
コード例 #6
0
ファイル: TestHaplib.py プロジェクト: saruvitz-life/hatohol
    def test_get_summary(self):
        arm_info = haplib.ArmInfo()
        arm_info.last_status = "OK"
        arm_info.failure_reason = "ABC DEF"
        arm_info.last_success_time = "20150709141523.123"
        arm_info.last_failure_time = "20150701235500.789"
        arm_info.num_success = 512
        arm_info.num_failure = 1024

        expect =  "LastStat: OK, NumSuccess: 512 (20150709141523.123), " \
                  "NumFailure: 1024 (20150701235500.789): " \
                  "FailureReason: ABC DEF"
        self.assertEquals(arm_info.get_summary(), expect)
コード例 #7
0
    def __init__(self, *args, **kwargs):
        haplib.BaseMainPlugin.__init__(self)

        self.__manager = None
        self.__default_host = "UNKNOWN"
        self.__default_type = "UNKNOWN"
        self.__default_status = "UNKNOWN"
        self.__default_severity = "UNKNOWN"

        self.__message_key = "message"
        self.__host_key = "host"
        self.__type_key = "type"
        self.__severity_key = "severity"
        self.__status_key = "status"

        self.__arm_info = haplib.ArmInfo()
コード例 #8
0
ファイル: TestHaplib.py プロジェクト: saruvitz-life/hatohol
 def test_put_arm_info(self):
     hapiproc, connector = self.__create_test_instance(ConnectorForTest)
     hapiproc.get_reply_queue().put(True)
     testutils.assertNotRaises(hapiproc.put_arm_info, haplib.ArmInfo())