~charmers/charms/trusty/ethercalc/trunk

« back to all changes in this revision

Viewing changes to tests/10-deploy

  • Committer: Joe Liau
  • Date: 2015-09-27 02:39:25 UTC
  • Revision ID: joseph@liau.ca-20150927023925-ituu9931q808zp8t
Added string test to 10-deploy; removed hardcode of port 8000 in website-relation-joined; removed config.yaml; removed upgrade-charm hook;

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
            raise
23
23
        cls.unit = cls.deployment.sentry.unit['ethercalc/0']
24
24
 
25
 
    def test_case(self):
26
 
        # Now you can use self.deployment.sentry.unit[UNIT] to address each of
27
 
        # the units and perform more in-depth steps.  You can also reference
28
 
        # the first unit as self.unit.
29
 
        # There are three test statuses that can be triggered with
30
 
        # amulet.raise_status():
31
 
        #   - amulet.PASS
32
 
        #   - amulet.FAIL
33
 
        #   - amulet.SKIP
34
 
        # Each unit has the following methods:
35
 
        #   - .info - An array of the information of that unit from Juju
36
 
        #   - .file(PATH) - Get the details of a file on that unit
37
 
        #   - .file_contents(PATH) - Get plain text output of PATH file from that unit
38
 
        #   - .directory(PATH) - Get details of directory
39
 
        #   - .directory_contents(PATH) - List files and folders in PATH on that unit
40
 
        #   - .relation(relation, service:rel) - Get relation data from return service
41
 
        #          add tests here to confirm service is up and working properly
42
 
        # For example, to confirm that it has a functioning HTTP server:
43
 
        #     page = requests.get('http://{}'.format(self.unit.info['public-address']))
44
 
        #     page.raise_for_status()
45
 
        # More information on writing Amulet tests can be found at:
46
 
        #     https://juju.ubuntu.com/docs/tools-amulet.html
 
25
      def test_website(self):
 
26
        ''' Test that ethercalc responds to HTTP get requests. '''
 
27
        # Get the address for ethercalc.
 
28
        server = self.ethercalc_unit.info['public-address']
 
29
        port = '8000'
 
30
        # Create a URL to the ethercalc unit.
 
31
        url = 'http://{0}:{1}'.format(server, port)
 
32
        response = requests.get(url)
 
33
        response.raise_for_status()
 
34
        if 'EtherCalc' not in str(response.content):
 
35
            message = 'EtherCalc was not in the HTTP response from {0}'
 
36
            amulet.raise_status(amulet.FAIL, msg=message.format(url))
 
37
        # Get the address for haproxy.
 
38
        server = self.haproxy_unit.info['public-address']
 
39
        port = '80'
 
40
        # Create a URL to the haproxy unit
 
41
        url = 'http://{0}:{1}'.format(server, port)
 
42
        response = requests.get(url)
 
43
        response.raise_for_status()
 
44
        if 'EtherCalc' not in str(response.content):
 
45
            message = 'EtherCalc was not in the HTTP response from {0}'
 
46
            amulet.raise_status(amulet.FAIL, msg=message.format(url))
47
47
        pass
48
48
 
49
49