2 # Copyright 2021 Canonical Ltd.
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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
16 # For those usages not covered by the Apache License, Version 2.0 please
17 # contact: legal@canonical.com
19 # To get in touch with the maintainers, please contact:
20 # osm-charmers@lists.launchpad.net
24 import zaza
.model
as model
25 import requests
as http
28 def get_prometheus_uri():
29 ip
= model
.get_status().applications
["prometheus-k8s"]["public-address"]
31 return "http://{}:{}".format(ip
, port
)
34 class BasicDeployment(unittest
.TestCase
):
35 def test_get_prometheus_uri(self
):
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)
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)
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)
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)
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)