| Adam Israel | 3377928 | 2016-10-05 09:08:16 -0700 | [diff] [blame] | 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('layer-netutils') |
| 13 | self.d.expose('layer-netutils') |
| 14 | |
| 15 | self.d.setup(timeout=900) |
| 16 | self.d.sentry.wait() |
| 17 | |
| 18 | self.unit = self.d.sentry['layer-netutils'][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 |