blob: 5adfb244cc511c67909b40801f38f0d61c1646bd [file] [log] [blame]
sousaedu89f86a32021-01-15 16:59:14 +00001#!/usr/bin/python3
2# Copyright 2021 Canonical Ltd.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15#
16# For those usages not covered by the Apache License, Version 2.0 please
17# contact: legal@canonical.com
18#
19# To get in touch with the maintainers, please contact:
20# osm-charmers@lists.launchpad.net
21##
22
23import unittest
24import zaza.model as model
25import requests as http
26
27
28def get_prometheus_uri():
29 ip = model.get_status().applications["prometheus-k8s"]["public-address"]
30 port = 9090
31 return "http://{}:{}".format(ip, port)
32
33
34class BasicDeployment(unittest.TestCase):
35 def test_get_prometheus_uri(self):
36 get_prometheus_uri()
37
38 def test_prometheus_get_series(self):
39 prometheus_uri = get_prometheus_uri()
40 body = http.get("{}/api/v1/series?match[]=up".format(prometheus_uri))
41 self.assertEqual(body.status_code, 200)
42
43 def test_prometheus_get_labels(self):
44 prometheus_uri = get_prometheus_uri()
45 body = http.get("{}/api/v1/labels".format(prometheus_uri))
46 self.assertEqual(body.status_code, 200)
47
48 def test_prometheus_get_targets(self):
49 prometheus_uri = get_prometheus_uri()
50 body = http.get("{}/api/v1/targets".format(prometheus_uri))
51 self.assertEqual(body.status_code, 200)
52
53 def test_prometheus_get_alerts(self):
54 prometheus_uri = get_prometheus_uri()
55 body = http.get("{}/api/v1/alerts".format(prometheus_uri))
56 self.assertEqual(body.status_code, 200)
57
58 def test_prometheus_get_status_config(self):
59 prometheus_uri = get_prometheus_uri()
60 body = http.get("{}/api/v1/status/config".format(prometheus_uri))
61 self.assertEqual(body.status_code, 200)