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()
|
now = timezone.now()
|
||||||
|
|
||||||
if self.last_ping + self.timeout > now:
|
if self.last_ping + self.timeout + self.grace > now:
|
||||||
return "up"
|
return "up"
|
||||||
|
|
||||||
return "down"
|
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
|
from hc.api.models import Check
|
||||||
|
|
||||||
|
|
||||||
@ -17,3 +19,11 @@ class CheckModelTestCase(TestCase):
|
|||||||
def test_in_grace_period_handles_new_check(self):
|
def test_in_grace_period_handles_new_check(self):
|
||||||
check = Check()
|
check = Check()
|
||||||
self.assertFalse(check.in_grace_period())
|
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 datetime import timedelta
|
||||||
|
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from mock import patch
|
|
||||||
|
|
||||||
from hc.api.management.commands.sendalerts import Command
|
from hc.api.management.commands.sendalerts import Command
|
||||||
from hc.api.models import Check
|
from hc.api.models import Check
|
||||||
from hc.test import BaseTestCase
|
from hc.test import BaseTestCase
|
||||||
|
from mock import patch
|
||||||
|
|
||||||
|
|
||||||
class SendAlertsTestCase(BaseTestCase):
|
class SendAlertsTestCase(BaseTestCase):
|
||||||
|
@ -49,10 +49,10 @@
|
|||||||
<td>
|
<td>
|
||||||
{% if check.get_status == "new" %}
|
{% if check.get_status == "new" %}
|
||||||
<span class="badge new">NEW</span>
|
<span class="badge new">NEW</span>
|
||||||
{% elif check.get_status == "up" %}
|
|
||||||
<span class="badge up">UP</span>
|
|
||||||
{% elif check.in_grace_period %}
|
{% elif check.in_grace_period %}
|
||||||
<span class="badge grace">LATE</span>
|
<span class="badge grace">LATE</span>
|
||||||
|
{% elif check.get_status == "up" %}
|
||||||
|
<span class="badge up">UP</span>
|
||||||
{% elif check.get_status == "down" %}
|
{% elif check.get_status == "down" %}
|
||||||
<span class="badge down">DOWN</span>
|
<span class="badge down">DOWN</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -46,10 +46,10 @@
|
|||||||
<td>
|
<td>
|
||||||
{% if check.get_status == "new" %}
|
{% if check.get_status == "new" %}
|
||||||
<span class="badge new">NEW</span>
|
<span class="badge new">NEW</span>
|
||||||
{% elif check.get_status == "up" %}
|
|
||||||
<span class="badge up">UP</span>
|
|
||||||
{% elif check.in_grace_period %}
|
{% elif check.in_grace_period %}
|
||||||
<span class="badge grace">LATE</span>
|
<span class="badge grace">LATE</span>
|
||||||
|
{% elif check.get_status == "up" %}
|
||||||
|
<span class="badge up">UP</span>
|
||||||
{% elif check.get_status == "down" %}
|
{% elif check.get_status == "down" %}
|
||||||
<span class="badge down">DOWN</span>
|
<span class="badge down">DOWN</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -16,10 +16,10 @@
|
|||||||
<td class="indicator-cell">
|
<td class="indicator-cell">
|
||||||
{% if check.get_status == "new" %}
|
{% if check.get_status == "new" %}
|
||||||
<span class="glyphicon glyphicon-question-sign new"></span>
|
<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 %}
|
{% elif check.in_grace_period %}
|
||||||
<span class="glyphicon glyphicon-exclamation-sign grace"></span>
|
<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" %}
|
{% elif check.get_status == "down" %}
|
||||||
<span class="glyphicon glyphicon-exclamation-sign down"></span>
|
<span class="glyphicon glyphicon-exclamation-sign down"></span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -25,10 +25,10 @@
|
|||||||
<td>
|
<td>
|
||||||
{% if check.get_status == "new" %}
|
{% if check.get_status == "new" %}
|
||||||
<span class="label label-default">NEW</span>
|
<span class="label label-default">NEW</span>
|
||||||
{% elif check.get_status == "up" %}
|
|
||||||
<span class="label label-success">UP</span>
|
|
||||||
{% elif check.in_grace_period %}
|
{% elif check.in_grace_period %}
|
||||||
<span class="label label-warning">LATE</span>
|
<span class="label label-warning">LATE</span>
|
||||||
|
{% elif check.get_status == "up" %}
|
||||||
|
<span class="label label-success">UP</span>
|
||||||
{% elif check.get_status == "down" %}
|
{% elif check.get_status == "down" %}
|
||||||
<span class="label label-danger">DOWN</span>
|
<span class="label label-danger">DOWN</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user