예제 #1
0
 def add_error(self, error, cause=None):
     if isinstance(error, HealthCheckException):
         pass
     elif isinstance(error, str):
         msg = error
         error = HealthCheckException(msg)
     else:
         msg = _("unknown error")
         error = HealthCheckException(msg)
     if isinstance(cause, BaseException):
         logger.exception(str(error))
     else:
         logger.error(str(error))
     self.errors.append(error)
예제 #2
0
 def check_status(self):
     info = redis_client.info()
     if not(info):
         raise HealthCheckException("redis")
     # The test code goes here.
     # You can use `self.add_error` or
     # raise a `HealthCheckException`,
     # similar to Django's form validation.
     pass
예제 #3
0
    def check_status(self):
        """Define the functionality of the health check."""
        from dashboard.utils import get_ipfs
        try:
            ipfs_connection = get_ipfs(host='https://ipfs.infura.io', port=5001)
        except IPFSCantConnectException:
            ipfs_connection = None

        if not ipfs_connection:
            raise HealthCheckException('Infura IPFS Unreachable')
예제 #4
0
    def check_status(self):
        """Define the functionality of the health check."""
        from dashboard.utils import get_ipfs
        try:
            ipfs_connection = get_ipfs()
        except IPFSCantConnectException:
            ipfs_connection = None

        if not ipfs_connection:
            raise HealthCheckException('Default IPFS Unreachable')
예제 #5
0
    def check_status(self):
        """Define the functionality of the health check."""
        from git.utils import get_current_ratelimit
        gh_ratelimit = get_current_ratelimit()

        is_core_ok = gh_ratelimit.core.remaining >= 500  # Limit is 5000
        is_graphql_ok = gh_ratelimit.graphql.remaining >= 500  # Limit is 5000
        is_search_ok = gh_ratelimit.search.remaining >= 5  # Limit is 30

        if not is_core_ok or not is_graphql_ok or not is_search_ok:
            raise HealthCheckException('Github Ratelimiting Danger Zone')
예제 #6
0
    def test_add_error(self):
        ht = BaseHealthCheckBackend()
        e = HealthCheckException('foo')
        ht.add_error(e)
        assert ht.errors[0] is e

        ht = BaseHealthCheckBackend()
        ht.add_error('bar')
        assert isinstance(ht.errors[0], HealthCheckException)
        assert str(ht.errors[0]) == 'unknown error: bar'

        ht = BaseHealthCheckBackend()
        ht.add_error(type)
        assert isinstance(ht.errors[0], HealthCheckException)
        assert str(ht.errors[0]) == 'unknown error: unknown error'
예제 #7
0
 def check_status(self):
     raise HealthCheckException('error')
예제 #8
0
 def check_status(self):
     """Define the functionality of the health check."""
     ipfs_connection = get_ipfs()
     if not ipfs_connection:
         raise HealthCheckException('IPFS Unreachable')
예제 #9
0
 def add_checker(self, checker):
     if not isinstance(checker, BaseBackendChecker):
         raise HealthCheckException("checker should be instance of BaseBackendChecker") 
     if checker.name in self._checkers:
         raise HealthCheckException("duplicate checker!")
     self._checkers[checker.name] = checker
 def check_status(self):
     try:
         send_mail(EMAIL_SUBJECT, EMAIL_MESSAGE, EMAIL_FROM, EMAIL_TO)
     except SMTPException as message:
         raise HealthCheckException(message)