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

« back to all changes in this revision

Viewing changes to tests/10-bundles-test.py

  • Committer: Geetha S
  • Date: 2016-08-19 09:33:52 UTC
  • Revision ID: geethas1@in.ibm.com-20160819093352-gnrg3s2j1thp5gc7
Code check in for IBM WAS Base charm.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python3
2
 
 
3
 
import amulet
4
 
import re
5
 
import unittest
6
 
 
7
 
seconds_to_wait = 20000
8
 
 
9
 
class TestDeploy(unittest.TestCase):
10
 
    """
11
 
    Deployment test for the IBM WAS Base charm.
12
 
    """
13
 
    def setUp(self):
14
 
        self.d = amulet.Deployment(series='trusty')
15
 
        self.d.add('ibm-was-base', 'cs:~ibmcharmers/trusty/ibm-was-base')
16
 
        self.d.add('ibm-http', 'cs:~ibmcharmers/trusty/ibm-http')
17
 
        self.d.relate('ibm-was-base:was-ihs', 'ibm-http:ihs')
18
 
        self.d.setup(seconds_to_wait)
19
 
        self.d.sentry.wait(seconds_to_wait)
20
 
 
21
 
    def test_deploy_with_placeholder_resource(self):
22
 
        # The status message when using placeholder resources will include the
23
 
        # string "ibm_was_base_installer resource". If we see that, the test is
24
 
        # successful.
25
 
        sentry_re = re.compile('ibm_was_base_installer resource')
26
 
        self.d.sentry.wait_for_messages({"ibm-was-base": sentry_re})
27
 
 
28
 
   def test_was_base_deployed(self):
29
 
        self.assertTrue(self.d.deployed)
30
 
        unit = self.d.sentry['ibm-was-base'][0]
31
 
        state_was_base = unit_master_0.info['agent-state']
32
 
        print('WAS Base Server is %s' % state_was_base)
33
 
        url  = 'http://%s:9060/ibm/console' % unit.info['public-address']
34
 
        https_url = 'https://%s:9043/ibm/console' % unit.info['public-address']
35
 
        response = requests.get(url, verify=False)
36
 
        response = requests.get(https_url, verify=False)
37
 
        # Raise an exception if the url was not a valid web page.
38
 
        response.raise_for_status()
39
 
 
40
 
    def test_was_ihs(self):
41
 
        http_unit = self.d.sentry['ibm-http'][0]
42
 
        state_http = unit_master_0.info['agent-state']
43
 
        print('Http Server is %s' % state_http)
44
 
        url  = 'http://%s:80' % http_unit.info['public-address']
45
 
        snoop_url = 'http://%s:80/snoop' % http_unit.info['public-address']
46
 
        response = requests.get(url, verify=False)
47
 
        response = requests.get(snoop_url, verify=False)
48
 
        response.raise_for_status()
49
 
 
50
 
if __name__ == '__main__':
51
 
    unittest.main()