Integration test for metrics + bug fix
[osm/N2VC.git] / tests / charms / layers / metrics-ci / tests / 10-deploy
1 #!/usr/bin/python3
2
3 import amulet
4 import requests
5 import unittest
6
7
8 class TestCharm(unittest.TestCase):
9     def setUp(self):
10         self.d = amulet.Deployment()
11
12         self.d.add('metrics-demo')
13         self.d.expose('metrics-demo')
14
15         self.d.setup(timeout=900)
16         self.d.sentry.wait()
17
18         self.unit = self.d.sentry['metrics-demo'][0]
19
20     def test_service(self):
21         # test we can access over http
22         page = requests.get('http://{}'.format(self.unit.info['public-address']))
23         self.assertEqual(page.status_code, 200)
24         # Now you can use self.d.sentry[SERVICE][UNIT] to address each of the units and perform
25         # more in-depth steps. Each self.d.sentry[SERVICE][UNIT] has the following methods:
26         # - .info - An array of the information of that unit from Juju
27         # - .file(PATH) - Get the details of a file on that unit
28         # - .file_contents(PATH) - Get plain text output of PATH file from that unit
29         # - .directory(PATH) - Get details of directory
30         # - .directory_contents(PATH) - List files and folders in PATH on that unit
31         # - .relation(relation, service:rel) - Get relation data from return service
32
33         
34 if __name__ == '__main__':
35     unittest.main()