]>
git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/mgr/test_prometheus.py
867d5cd5d6d6d38d2fe2af785bd3c3b14b575397
1 from tasks
.mgr
.mgr_test_case
import MgrTestCase
8 log
= logging
.getLogger(__name__
)
11 class TestPrometheus(MgrTestCase
):
15 super(TestPrometheus
, self
).setUp()
18 def test_file_sd_command(self
):
19 self
._assign
_ports
("prometheus", "server_port")
20 self
._load
_module
("prometheus")
22 result
= json
.loads(self
.mgr_cluster
.mon_manager
.raw_cluster_cmd(
23 "prometheus", "file_sd_config"))
24 mgr_map
= self
.mgr_cluster
.get_mgr_map()
25 self
.assertEqual(len(result
[0]['targets']), len(mgr_map
['standbys']) + 1)
29 def test_standby(self
):
30 self
._assign
_ports
("prometheus", "server_port")
31 self
._load
_module
("prometheus")
33 original_active
= self
.mgr_cluster
.get_active_id()
35 original_uri
= self
._get
_uri
("prometheus")
36 log
.info("Originally running at {0}".format(original_uri
))
38 self
.mgr_cluster
.mgr_fail(original_active
)
40 failed_over_uri
= self
._get
_uri
("prometheus")
41 log
.info("After failover running at {0}".format(failed_over_uri
))
43 self
.assertNotEqual(original_uri
, failed_over_uri
)
45 # The original active daemon should have come back up as a standby
46 # and serve some html under "/" and an empty answer under /metrics
47 r
= requests
.get(original_uri
, allow_redirects
=False)
48 self
.assertEqual(r
.status_code
, 200)
49 r
= requests
.get(original_uri
+ "metrics", allow_redirects
=False)
50 self
.assertEqual(r
.status_code
, 200)
51 self
.assertEqual(r
.headers
["content-type"], "text/plain;charset=utf-8")
54 self
._assign
_ports
("prometheus", "server_port")
55 self
._load
_module
("prometheus")
57 base_uri
= self
._get
_uri
("prometheus")
59 # This is a very simple smoke test to check that the module can
60 # give us a 200 response to requests. We're not testing that
61 # the content is correct or even renders!
71 r
= requests
.get(base_uri
+ url
, allow_redirects
=False)
72 if r
.status_code
!= 200:
75 log
.info("{0}: {1} ({2} bytes)".format(
76 url
, r
.status_code
, len(r
.content
)
79 self
.assertListEqual(failures
, [])