def test_disk_space_check_fails_when_less_than_2_percent_space_is_available(self, stat_mock):
        stat_mock.return_value.f_bavail = 2 * 1024
        stat_mock.return_value.f_blocks = 100 * 1024
        stat_mock.return_value.f_frsize = 1024

        result = healthchecks.check_disk()
        self.assertDictContainsSubset({"status": "unhealthy", "available_percent": 2.0}, result)
    def test_disk_space_check_reports_on_available_and_total_space(self, stat_mock):
        stat_mock.return_value.f_bavail = 50 * 1024
        stat_mock.return_value.f_blocks = 100 * 1024
        stat_mock.return_value.f_frsize = 1024

        result = healthchecks.check_disk()
        self.assertDictContainsSubset({"available_percent": 50.0, "available_mb": 50.0, "total_mb": 100.0}, result)
Ejemplo n.º 3
0
def healthcheck():
    response = {
        "disk": healthchecks.check_disk(),
        "Backend API test": healthchecks.check_backend_api()
    }
    ok = all(item["status"] == healthchecks.HEALTHY
             for _key, item in response.iteritems())
    result = jsonify(response)
    result.status_code = 200 if ok else 503
    return result
    def test_disk_space_check_fails_when_less_than_2_percent_space_is_available(
            self, stat_mock):
        stat_mock.return_value.f_bavail = 2 * 1024
        stat_mock.return_value.f_blocks = 100 * 1024
        stat_mock.return_value.f_frsize = 1024

        result = healthchecks.check_disk()
        self.assertDictContainsSubset(
            {
                "status": "unhealthy",
                "available_percent": 2.0
            }, result)
    def test_disk_space_check_reports_on_available_and_total_space(
            self, stat_mock):
        stat_mock.return_value.f_bavail = 50 * 1024
        stat_mock.return_value.f_blocks = 100 * 1024
        stat_mock.return_value.f_frsize = 1024

        result = healthchecks.check_disk()
        self.assertDictContainsSubset(
            {
                "available_percent": 50.0,
                "available_mb": 50.0,
                "total_mb": 100.0
            }, result)
Ejemplo n.º 6
0
def healthcheck():
    response = {"disk": healthchecks.check_disk(), "Backend API test": healthchecks.check_backend_api()}
    ok = all(item["status"] == healthchecks.HEALTHY for _key, item in response.iteritems())
    result = jsonify(response)
    result.status_code = 200 if ok else 503
    return result