~ibmcharmers/charms/trusty/layer-ibm-dsm-enterprise/devel

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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/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 DMS charm.
    """
    def setUp(self):
        self.d = amulet.Deployment(series='trusty')
        self.d.add('ibm-dsm-enterprise',
                   'cs:~ibmcharmers/trusty/ibm-dsm-enterprise')
        self.d.add('ibm-db2', 'cs:~ibmcharmers/trusty/ibm-db2')
        self.d.relate('ibm-dsm-base-enterprise:ibm-dsm-db2', 'ibm-db2:db')
        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_nd_installer resource". If we see that, the test is
        # successful.
        sentry_re1 = re.compile('ibm_dsm_installer resource')
        sentry_re2 = re.compile('ibm_dsm_license resource')
        self.d.sentry.wait_for_messages({"ibm-dsm-enterprise": sentry_re1})
        self.d.sentry.wait_for_messages({"ibm-dsm-enterprise": sentry_re2})

    def test_ibm_dsm_deployed(self):
        self.assertTrue(self.d.deployed)
        unit = self.d.sentry['ibm-dsm-enterprise'][0]
        state_ibm_dsm_enterprise = unit.info['agent-state']
        print('IBM DSM is %s' % state_ibm_dsm_enterprise)
        url = 'http://%s:11080/ibm/console' % unit.info['public-address']
        httpsurl = 'https://%s:11081/ibm/console' % unit.info['public-address']
        response = requests.get(url, verify=False)
        response = requests.get(httpsurl, verify=False)
        # Raise an exception if the url was not a valid web page.
        response.raise_for_status()

    def test_ibm_dsm_db2(self):
        dsm_unit = self.d.sentry['ibm-db2'][0]
        state_db2 = dsm_unit.info['agent-state']
        self.d.relate('ibm-dsm-enterprise:ibm-db2', 'ibm-dsm-db2:db2')
        print('DB2 Server is %s' % state_db2)
        url = 'http://%s:11080' % dsm_unit.info['public-address']
        https_url = 'http://%s:11081' % dsm_unit.info['public-address']
        response = requests.get(url, verify=False)
        response = requests.get(https_url, verify=False)
        response.raise_for_status()


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