Commit 4acb179f authored by Łukasz Nowak's avatar Łukasz Nowak

promise: Treat elapsed_time = 0 specially in check_surykatka_json

It means that the server didn't reply at all.
parent 9974ad80
......@@ -214,7 +214,9 @@ class RunPromise(GenericPromise):
if maximum_elapsed_time:
if 'total_seconds' in entry:
maximum_elapsed_time = float(maximum_elapsed_time)
if entry['total_seconds'] > maximum_elapsed_time:
if entry['total_seconds'] == 0.:
appendError('IP %s failed to reply' % (entry['ip']))
elif entry['total_seconds'] > maximum_elapsed_time:
appendError(
'IP %s replied in %.2fs which is longer than '
'maximum %.2fs' %
......
......@@ -355,7 +355,7 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
"ip": "127.0.0.2",
"status_code": 302,
"url": "https://www.erp5.com/",
"total_seconds": 4
"total_seconds": 0
},
{
"date": "Wed, 11 Dec 2019 09:35:28 -0000",
......@@ -387,11 +387,11 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
self.assertFailedMessage(
self.getPromiseResult(self.promise_name),
"https://www.erp5.com/ : elapsed_time: ERROR IP 127.0.0.1 replied in "
"6.00s which is longer than maximum 5.00s http_query: OK status code "
"302 on IPs 127.0.0.1 127.0.0.2 ssl_certificate: OK Certificate will "
"expire on Mon, 13 Jul 2020 12:00:00 -0000, which is more than 15 "
"days, UTC now is Fri, 27 Dec 2019 15:11:12 -0000 elapsed_time: OK IP "
"127.0.0.2 replied in 4.00s which is shorter than maximum 5.00s"
"6.00s which is longer than maximum 5.00s elapsed_time: ERROR IP "
"127.0.0.2 failed to reply http_query: OK status code 302 on IPs "
"127.0.0.1 127.0.0.2 ssl_certificate: OK Certificate will expire on "
"Mon, 13 Jul 2020 12:00:00 -0000, which is more than 15 days, UTC now "
"is Fri, 27 Dec 2019 15:11:12 -0000"
)
def test_maximum_elapsed_time_no_total_seconds(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment