~rcj/charms/precise/nrpe/trunk

« back to all changes in this revision

Viewing changes to tests/99-autogen

  • Committer: Matt Bruzek
  • Date: 2014-11-06 21:21:58 UTC
  • mto: This revision was merged to the branch mainline in revision 34.
  • Revision ID: matthew.bruzek@canonical.com-20141106212158-0v6k3p3dzszbizns
Adding tests to this charm

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python3
 
2
 
 
3
import amulet
 
4
import requests
 
5
import unittest
 
6
 
 
7
 
 
8
class TestDeployment(unittest.TestCase):
 
9
    @classmethod
 
10
    def setUpClass(cls):
 
11
        cls.deployment = amulet.Deployment(series='precise')
 
12
 
 
13
        cls.deployment.add('nrpe')
 
14
        cls.deployment.add('nagios')
 
15
        cls.deployment.add('mysql')
 
16
        cls.deployment.add('ubuntu')
 
17
        cls.deployment.relate('nrpe:monitors', 'nagios')
 
18
        cls.deployment.relate('nrpe:local-monitors', 'mysql:local-monitors')
 
19
        cls.deployment.relate('nrpe:general-info', 'ubuntu:juju-info')
 
20
 
 
21
        try:
 
22
            cls.deployment.setup(timeout=900)
 
23
            cls.deployment.sentry.wait()
 
24
        except amulet.helpers.TimeoutError:
 
25
            amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
 
26
        except:
 
27
            raise
 
28
 
 
29
    def test_case(self):
 
30
        # Now you can use self.deployment.sentry.unit[UNIT] to address each of
 
31
        # the units and perform more in-depth steps.  You can also reference
 
32
        # the first unit as self.unit.
 
33
        # There are three test statuses that can be triggered with
 
34
        # amulet.raise_status():
 
35
        #   - amulet.PASS
 
36
        #   - amulet.FAIL
 
37
        #   - amulet.SKIP
 
38
        # Each unit has the following methods:
 
39
        #   - .info - An array of the information of that unit from Juju
 
40
        #   - .file(PATH) - Get the details of a file on that unit
 
41
        #   - .file_contents(PATH) - Get plain text output of PATH file from that unit
 
42
        #   - .directory(PATH) - Get details of directory
 
43
        #   - .directory_contents(PATH) - List files and folders in PATH on that unit
 
44
        #   - .relation(relation, service:rel) - Get relation data from return service
 
45
        #          add tests here to confirm service is up and working properly
 
46
        # For example, to confirm that it has a functioning HTTP server:
 
47
        #     page = requests.get('http://{}'.format(self.unit.info['public-address']))
 
48
        #     page.raise_for_status()
 
49
        # More information on writing Amulet tests can be found at:
 
50
        #     https://juju.ubuntu.com/docs/tools-amulet.html
 
51
        pass
 
52
 
 
53
 
 
54
if __name__ == '__main__':
 
55
    unittest.main()