Merge lp:~lazypower/charms/trusty/db2/test-fixup into lp:~suchvenu/charms/trusty/db2/ibmdb2

Proposed by Charles Butler on 2015-07-14
Status: Needs review
Proposed branch: lp:~lazypower/charms/trusty/db2/test-fixup
Merge into: lp:~suchvenu/charms/trusty/db2/ibmdb2
Diff against target: 91 lines (+29/-22)
3 files modified
tests/10-bundles-test.py (+26/-19)
tests/bundles.yaml (+1/-1)
tests/local.yaml (+2/-2)
To merge this branch: bzr merge lp:~lazypower/charms/trusty/db2/test-fixup
Reviewer Review Type Date Requested Status
Suchitra Venugopal 2015-07-14 Disapprove on 2016-05-05
Review via email: mp+264709@code.launchpad.net

Description of the Change

Demonstrating a working deployment, with isolated configuration injection logic

To post a comment you must log in.
review: Disapprove

Unmerged revisions

2. By Charles Butler on 2015-07-14

Adjust the test routine demonstrating a working test deployment

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/10-bundles-test.py' (properties changed: -x to +x)
2--- tests/10-bundles-test.py 2015-07-14 11:32:09 +0000
3+++ tests/10-bundles-test.py 2015-07-14 13:08:22 +0000
4@@ -20,24 +20,13 @@
5 """ Set up an amulet deployment using the bundle. """
6 d = amulet.Deployment()
7
8- local_path = os.path.join(os.path.dirname(__file__), 'local.yaml')
9- with open(local_path, "r") as fd:
10- config = yaml.safe_load(fd)
11-
12- url = config.get('db2').get('db2_url')
13- print('Using URL %s' % url)
14- # Test if a DB2 url for the repository is defined
15- if not url:
16- print("You need to define a url for the DB2 packages repository.\n"
17- "Edit local.yaml or tests/00-setup and run it again.")
18- sys.exit(1)
19-
20- pkg = config.get('db2').get('db2_package')
21- print('Using DB2 package %s' % pkg)
22- if not pkg:
23- print("You need to define a package name for IBM DB2.\n"
24- "Edit local.yaml or tests/00-setup and run it again.")
25- sys.exit(1)
26+ # We have a contextual test, if no config is present, initialze the
27+ # test with an empty configuration set
28+ config = {}
29+
30+ cfgpath = os.path.join(os.path.dirname(__file__), 'local.yaml')
31+ if os.path.exists(cfgpath):
32+ config = load_config(cfgpath)
33
34 bundle_path = os.path.join(os.path.dirname(__file__), 'bundles.yaml')
35 with open(bundle_path, 'r') as bundle_file:
36@@ -45,7 +34,8 @@
37 d.load(contents)
38
39 # Software doesn't actually install until you accept the license
40- d.configure('db2', { 'accept-ibm-db2-license': True, 'db2_url': url, 'db2_package_name' : pkg })
41+ import pdb; pdb.set_trace()
42+ d.configure('db2', config)
43
44 d.setup(seconds_to_wait)
45 d.sentry.wait(seconds_to_wait)
46@@ -55,5 +45,22 @@
47 """ Test to see if the bundle deployed successfully. """
48 self.assertTrue(self.d.deployed)
49
50+
51+
52+# Python unit testing frameworks only invokes methods prefixed with test_
53+# this will only be called when implicitly invoked
54+def load_config(config_path):
55+ with open(config_path, 'r') as f:
56+ bundle_options = yaml.safe_load(f)
57+
58+ if 'db2_url' not in bundle_options.keys():
59+ raise ValueError("db2_url is a required configuration value")
60+ if 'db2_package_name' not in bundle_options.keys():
61+ raise ValueError("db2_package is a required configuration value")
62+
63+ return bundle_options
64+
65+
66+
67 if __name__ == '__main__':
68 unittest.main()
69
70=== modified file 'tests/bundles.yaml'
71--- tests/bundles.yaml 2015-07-14 11:32:09 +0000
72+++ tests/bundles.yaml 2015-07-14 13:08:22 +0000
73@@ -1,7 +1,7 @@
74 ibm-db2-bundle:
75 services:
76 "db2":
77- charm: "db2"
78+ charm: "local:trusty/db2"
79 num_units: 1
80 annotations:
81 "gui-x": "300"
82
83=== modified file 'tests/local.yaml'
84--- tests/local.yaml 2015-07-14 11:32:09 +0000
85+++ tests/local.yaml 2015-07-14 13:08:22 +0000
86@@ -1,3 +1,3 @@
87-db2:
88 db2_url: "http://9.124.100.99/debs/DB2"
89-db2_package: "DB2_Svr_10.5.0.3_Linux_x86-64.tar.gz"
90+db2_package_name: "DB2_Svr_10.5.0.3_Linux_x86-64.tar.gz"
91+accept-ibm-db2-license: True

Subscribers

People subscribed via source and target branches