~ibmcharmers/charms/xenial/layer-ibm-was-base/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python3

import amulet
import re
import requests
import unittest

seconds_to_wait = 20000


class TestDeploy(unittest.TestCase):
    """
    Deployment test for the IBM WAS Base charm.
    """
    def setUp(self):
        self.d = amulet.Deployment(series='trusty')
        self.d.add('ibm-was-base', 'cs:~ibmcharmers/xenial/ibm-was-base')
        self.d.setup(seconds_to_wait)
        self.d.sentry.wait(seconds_to_wait)

    def test_deploy_with_placeholder_resource(self):
        # The status message when using placeholder resources will include the
        # string "ibm_was_base_installer resource". If we see that, the test is
        # successful.
        sentry_re = re.compile('ibm_was_base_installer resource')
        self.d.sentry.wait_for_messages({"ibm-was-base": sentry_re})

    def test_was_base_deployed(self):
        self.assertTrue(self.d.deployed)
        unit = self.d.sentry['ibm-was-base'][0]
        state_was_base = unit.info['agent-state']
        print('WAS Base Server is %s' % state_was_base)
        url = 'http://%s:9060/ibm/console' % unit.info['public-address']
        https_url = 'https://%s:9043/ibm/console' % unit.info['public-address']
        response = requests.get(url, verify=False)
        response = requests.get(https_url, verify=False)
        # Raise an exception if the url was not a valid web page.
        response.raise_for_status()


if __name__ == '__main__':
    unittest.main()