def test_paramCheck_Unknown_2(self):
     """
     矛盾チェック count
     """
     checker = _Jvm(self.java_bin, self.temp_dir, self.name, self.interval)
     ret = checker.setCountWarning(20)
     ret = checker.setCountCritical(10)
     self.assertEqual(ret, _Jvm.STATE_UNKNOWN)
 def test_paramCheck_OK_1(self):
     """
     矛盾しないチェック time
     """
     checker = _Jvm(self.java_bin, self.temp_dir, self.name, self.interval)
     ret = checker.setTimeWarning(10)
     ret = checker.setTimeCritical(20)
     self.assertEqual(ret, _Jvm.STATE_OK)
 def test_paramCheckGC_2(self):
     """
     GC時間 Warning
     """
     checker = _Jvm(self.java_bin, self.temp_dir, self.name, self.interval)
     self._initJstatLog(checker)
     checker.setTimeWarning(200)
     checker.setTimeCritical(201)
     checker.setCountWarning(11)
     checker.setCountCritical(12)
     self.assertEqual(checker.checkGc(), _Jvm.STATE_WARNING)
    def test_parseGcUtil_1(self):
        """
        パーサーチェック
        """

        data = """Timestamp         S0     S1     E      O      P     YGC     YGCT    FGC    FGCT     GCT   
18276.7  78.11   0.00  68.34  61.65  60.03   2342   33.595    16    0.166   33.762"""
        checker = _Jvm(self.java_bin, self.temp_dir, self.name, self.interval)
        ret = checker._parseGcUtil(data)
        self.assertEqual(ret["S1"], 0)
        self.assertEqual(ret["GCT"], 33.762)
 def test_paramCheckGC_3(self):
     """
     GC回数 Critical
     """
     checker = _Jvm(self.java_bin, self.temp_dir, self.name, self.interval)
     self._initJstatLog(checker)
     checker.setTimeWarning(301)
     checker.setTimeCritical(302)
     checker.setCountWarning(4)
     checker.setCountCritical(5)
     self.assertEqual(checker.checkGc(), _Jvm.STATE_CRITICAL)
    def test_getOldStat_1(self):
        """
        過去データ取得: 初期状態
        """
        self._clearJstatLog()
        checker = _Jvm(self.java_bin, self.temp_dir, self.name, self.interval)
        checker.current_stat = self.baseJstatData
        checker.pid = self.baseJstatData["pid"]

        ret = checker._getOldStat()
        self.assertEqual(ret, None)

        history1 = checker._loadJson(self.history1_filename)
        history2 = checker._loadJson(self.history1_filename)
        self.assertEqual(history1, self.baseJstatData)
        self.assertEqual(history2, self.baseJstatData)
    def test_getOldStat_4(self):
        """
        過去データ取得: 1回目計測終了時間
        """
        self._clearJstatLog()
        checker = _Jvm(self.java_bin, self.temp_dir, self.name, self.interval)
        checker.current_stat = self.baseJstatData
        checker.pid = self.baseJstatData["pid"]

        save_data = copy.deepcopy(self.baseJstatData)
        save_data["Timestamp"] = self.baseJstatData["Timestamp"] - self.interval * 2 + 1
        checker._saveJson(self.history1_filename, save_data)
        checker._saveJson(self.history2_filename, save_data)

        ret = checker._getOldStat()
        self.assertEqual(ret, save_data)

        history1 = checker._loadJson(self.history1_filename)
        history2 = checker._loadJson(self.history2_filename)
        self.assertEqual(history1, save_data)
        self.assertEqual(history2, self.baseJstatData)
    def test_getOldStat_F(self):
        """
        過去データ取得: データ古過ぎ&データ新し過ぎ 逆パターン
        """
        self._clearJstatLog()
        checker = _Jvm(self.java_bin, self.temp_dir, self.name, self.interval)
        checker.current_stat = self.baseJstatData
        checker.pid = self.baseJstatData["pid"]

        save_data1 = copy.deepcopy(self.baseJstatData)
        save_data1["Timestamp"] = self.baseJstatData["Timestamp"] - self.interval * 2
        checker._saveJson(self.history1_filename, save_data1)

        save_data2 = copy.deepcopy(self.baseJstatData)
        save_data2["Timestamp"] = self.baseJstatData["Timestamp"] - self.interval + 1
        checker._saveJson(self.history2_filename, save_data2)

        ret = checker._getOldStat()
        self.assertEqual(ret, None)

        history1 = checker._loadJson(self.history1_filename)
        history2 = checker._loadJson(self.history2_filename)
        self.assertEqual(history1, save_data1)
        self.assertEqual(history2, save_data2)