Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 def get_healthz_config(cls):
     try:
         return ChecksConfig.read(cls.HEALTH_FILE, config_type=".json")
     except:
         return
Exemplo n.º 5
0
 def test_get_interval(self):
     config = ChecksConfig()
     assert config.get_interval(1) == 1
     assert config.get_interval() == ChecksConfig.INTERVAL