Quick attempt at Prometheus (#1848)

Close https://github.com/zalando/patroni/issues/318
This commit is contained in:
Mark Mercado
2021-03-04 12:37:29 +01:00
committed by GitHub
parent b341ab2e2f
commit 09f2f579d7
5 changed files with 97 additions and 12 deletions
+4 -2
View File
@@ -1,3 +1,4 @@
import datetime
import mock # for the mock.call method, importing it without a namespace breaks python3
import os
import psutil
@@ -522,8 +523,9 @@ class TestPostgresql(BaseTestPostgresql):
self.assertEqual(self.p.get_major_version(), 0)
def test_postmaster_start_time(self):
with patch.object(MockCursor, "fetchone", Mock(return_value=('foo', True, '', '', '', '', False))):
self.assertEqual(self.p.postmaster_start_time(), 'foo')
now = datetime.datetime.now()
with patch.object(MockCursor, "fetchone", Mock(return_value=(now, True, '', '', '', '', False))):
self.assertEqual(self.p.postmaster_start_time(), now.isoformat(sep=' '))
t = Thread(target=self.p.postmaster_start_time)
t.start()
t.join()