~ibmcharmers/charms/trusty/layer-ibm-mobilefirst-server/devel

« back to all changes in this revision

Viewing changes to tests/01-deploy_mobilefirst.py

  • Committer: Suchitra Venugopal
  • Date: 2016-09-06 09:48:53 UTC
  • Revision ID: suchvenu@in.ibm.com-20160906094853-1n09myeisek096nm
IBM MobileFirst Server

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
import os
 
7
import yaml
 
8
import sys
 
9
 
 
10
 
 
11
class TestDeploy(unittest.TestCase):
 
12
    """
 
13
    Deployment test for the IBM IM charm.
 
14
 
 
15
    This charm doesn't do much by itself, so we expect functional
 
16
    tests to happen in the charms that use this layer (for example, websphere).
 
17
    """
 
18
    def setUp(self):
 
19
        self.d = amulet.Deployment(series='trusty')
 
20
        local_path = os.path.join(os.path.dirname(__file__), 'local.yaml')
 
21
        with open(local_path, "r") as fd:
 
22
            config = yaml.safe_load(fd)
 
23
 
 
24
        curl_url = config.get('ibm-repo').get('db2_curl_url')
 
25
        if not curl_url:
 
26
            message = 'Please provide the curl url from where the ' \
 
27
                      'package can be downloaded.'
 
28
            amulet.raise_status(amulet.FAIL, msg=message)
 
29
            sys.exit(1)
 
30
 
 
31
        curl_opts = config.get('ibm-repo').get('db2_curl_opts')
 
32
        if not curl_opts:
 
33
            message = 'Please provide the curl_opts to specify the ' \
 
34
                      'credentials to download the packages.'
 
35
            amulet.raise_status(amulet.FAIL, msg=message)
 
36
            sys.exit(1)
 
37
 
 
38
        self.d.add('ibm-db2', 'cs:~ibmcharmers/trusty/ibm-db2')
 
39
        self.d.add('websphere-liberty',
 
40
                   'cs:~ibmcharmers/trusty/websphere-liberty')
 
41
        self.d.add('ibm-mobilefirst-server',
 
42
                   'cs:~ibmcharmers/trusty/ibm-mobilefirst-server')
 
43
        self.d.configure('websphere-liberty',
 
44
                         {'accept-ibm-websphere-license': True})
 
45
        self.d.configure('websphere-liberty',
 
46
                         {'accept-ibm-java-license': True})
 
47
        self.d.configure('ibm-db2', {'license_accepted': True,
 
48
                         'curl_url': curl_url, 'curl_opts': curl_opts})
 
49
 
 
50
        self.d.setup(timeout=900)
 
51
        self.d.sentry.wait(timeout=1800)
 
52
 
 
53
    def test_deploy_with_placeholder_resource(self):
 
54
        # The status message when using placeholder resources will include the
 
55
        # string "ibm_im_installer resource". If we see that, the test is
 
56
        # successful.
 
57
        sentry_re = re.compile('ibm_mobilefirstserver_installer resource')
 
58
        self.d.sentry.wait_for_messages({"ibm-mobilefirstserver": sentry_re})
 
59
 
 
60
if __name__ == '__main__':
 
61
    unittest.main()