예제 #1
0
    def test_should_check(self):
        config = ChecksConfig(last_check=now())
        assert config.should_check(-1) is False
        assert config.should_check(0) is True

        config.last_check = now() - timedelta(seconds=10000)
        assert config.should_check(-1) is False
        assert config.should_check() is True
        assert config.should_check(100) is True
        assert config.should_check(100000) is False
예제 #2
0
 def test_get_interval(self):
     config = ChecksConfig()
     assert config.get_interval(1) == 1
     assert config.get_interval(-1) == -1
     assert config.get_interval(-2) == -2
     assert config.get_interval() == ChecksConfig.INTERVAL
     os.environ[POLYAXON_KEYS_INTERVALS_COMPATIBILITY_CHECK] = "-1"
     assert config.get_interval() == -1
     os.environ[POLYAXON_KEYS_INTERVALS_COMPATIBILITY_CHECK] = "-2"
     assert config.get_interval() == ChecksConfig.INTERVAL
     os.environ[POLYAXON_KEYS_INTERVALS_COMPATIBILITY_CHECK] = "1"
     assert config.get_interval() == ChecksConfig.INTERVAL
     os.environ[POLYAXON_KEYS_INTERVALS_COMPATIBILITY_CHECK] = str(
         ChecksConfig.INTERVAL + 1)
     assert config.get_interval() == ChecksConfig.INTERVAL + 1
예제 #3
0
파일: base.py 프로젝트: yueyedeai/polyaxon
 def ping(cls):
     ChecksConfig.init_file(cls.HEALTH_FILE)
     config = cls.get_healthz_config()
     if config:
         config.last_check = now()
         config.write(cls.HEALTH_FILE)
예제 #4
0
파일: base.py 프로젝트: yueyedeai/polyaxon
 def get_healthz_config(cls):
     try:
         return ChecksConfig.read(cls.HEALTH_FILE, config_type=".json")
     except:
         return
예제 #5
0
 def test_get_interval(self):
     config = ChecksConfig()
     assert config.get_interval(1) == 1
     assert config.get_interval() == ChecksConfig.INTERVAL