forked from GithubBackups/healthchecks
Check.get_status() returns "up" also during grace period
This commit is contained in:
parent
89d37f8202
commit
ce23d65ebf
@ -85,7 +85,7 @@ class Check(models.Model):
|
||||
|
||||
now = timezone.now()
|
||||
|
||||
if self.last_ping + self.timeout > now:
|
||||
if self.last_ping + self.timeout + self.grace > now:
|
||||
return "up"
|
||||
|
||||
return "down"
|
||||
|
@ -1,5 +1,7 @@
|
||||
from django.test import TestCase
|
||||
from datetime import timedelta
|
||||
|
||||
from django.test import TestCase
|
||||
from django.utils import timezone
|
||||
from hc.api.models import Check
|
||||
|
||||
|
||||
@ -17,3 +19,11 @@ class CheckModelTestCase(TestCase):
|
||||
def test_in_grace_period_handles_new_check(self):
|
||||
check = Check()
|
||||
self.assertFalse(check.in_grace_period())
|
||||
|
||||
def test_status_works_with_grace_period(self):
|
||||
check = Check()
|
||||
check.status = "up"
|
||||
check.last_ping = timezone.now() - timedelta(days=1, minutes=30)
|
||||
|
||||
self.assertTrue(check.in_grace_period())
|
||||
self.assertEqual(check.get_status(), "up")
|
||||
|
@ -1,11 +1,10 @@
|
||||
from datetime import timedelta
|
||||
|
||||
from django.utils import timezone
|
||||
from mock import patch
|
||||
|
||||
from hc.api.management.commands.sendalerts import Command
|
||||
from hc.api.models import Check
|
||||
from hc.test import BaseTestCase
|
||||
from mock import patch
|
||||
|
||||
|
||||
class SendAlertsTestCase(BaseTestCase):
|
||||
|
@ -49,10 +49,10 @@
|
||||
<td>
|
||||
{% if check.get_status == "new" %}
|
||||
<span class="badge new">NEW</span>
|
||||
{% elif check.get_status == "up" %}
|
||||
<span class="badge up">UP</span>
|
||||
{% elif check.in_grace_period %}
|
||||
<span class="badge grace">LATE</span>
|
||||
{% elif check.get_status == "up" %}
|
||||
<span class="badge up">UP</span>
|
||||
{% elif check.get_status == "down" %}
|
||||
<span class="badge down">DOWN</span>
|
||||
{% endif %}
|
||||
|
@ -46,10 +46,10 @@
|
||||
<td>
|
||||
{% if check.get_status == "new" %}
|
||||
<span class="badge new">NEW</span>
|
||||
{% elif check.get_status == "up" %}
|
||||
<span class="badge up">UP</span>
|
||||
{% elif check.in_grace_period %}
|
||||
<span class="badge grace">LATE</span>
|
||||
{% elif check.get_status == "up" %}
|
||||
<span class="badge up">UP</span>
|
||||
{% elif check.get_status == "down" %}
|
||||
<span class="badge down">DOWN</span>
|
||||
{% endif %}
|
||||
|
@ -16,10 +16,10 @@
|
||||
<td class="indicator-cell">
|
||||
{% if check.get_status == "new" %}
|
||||
<span class="glyphicon glyphicon-question-sign new"></span>
|
||||
{% elif check.get_status == "up" %}
|
||||
<span class="glyphicon glyphicon-ok-sign up"></span>
|
||||
{% elif check.in_grace_period %}
|
||||
<span class="glyphicon glyphicon-exclamation-sign grace"></span>
|
||||
{% elif check.get_status == "up" %}
|
||||
<span class="glyphicon glyphicon-ok-sign up"></span>
|
||||
{% elif check.get_status == "down" %}
|
||||
<span class="glyphicon glyphicon-exclamation-sign down"></span>
|
||||
{% endif %}
|
||||
|
@ -25,10 +25,10 @@
|
||||
<td>
|
||||
{% if check.get_status == "new" %}
|
||||
<span class="label label-default">NEW</span>
|
||||
{% elif check.get_status == "up" %}
|
||||
<span class="label label-success">UP</span>
|
||||
{% elif check.in_grace_period %}
|
||||
<span class="label label-warning">LATE</span>
|
||||
{% elif check.get_status == "up" %}
|
||||
<span class="label label-success">UP</span>
|
||||
{% elif check.get_status == "down" %}
|
||||
<span class="label label-danger">DOWN</span>
|
||||
{% endif %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user