Merge lp:~jjo/juju-deployer/diff-usability-fixes into lp:juju-deployer

Proposed by JuanJo Ciarlante
Status: Merged
Merged at revision: 89
Proposed branch: lp:~jjo/juju-deployer/diff-usability-fixes
Merge into: lp:juju-deployer
Diff against target: 125 lines (+39/-20)
5 files modified
deployer/action/diff.py (+14/-9)
deployer/env/go.py (+1/-1)
deployer/tests/test_data/blog-haproxy-services.yaml (+14/-0)
deployer/tests/test_data/blog.yaml (+9/-9)
deployer/tests/test_deployment.py (+1/-1)
To merge this branch: bzr merge lp:~jjo/juju-deployer/diff-usability-fixes
Reviewer Review Type Date Requested Status
juju-deployers Pending
Review via email: mp+197270@code.launchpad.net

Commit message

* action/diff.py:
  - create an output-less do_diff() method, to be used to implement
    unit-tests
  - add more detail to diff output re: values coming from cfg or env.
    Rationale: after seeing a config diff, one usually then goes for a
    juju get <svc_name> to find the env config value, which is a non-sense
    workflow given that we do know its current value.
    Ditto constraints.
* tests/test_data/:
  - fix blog.yaml: proper indentation for memcache,haproxy (so that they're
    actually parsed as services).
  - add blog-haproxy-services.yaml as a proper example
    (instead of nonexistent blog-include.yaml).
* tests/test_deployment.py: call resolve() instead of resolve_config(),
  for wider coverage.

To post a comment you must log in.
Revision history for this message
JuanJo Ciarlante (jjo) wrote :

To ease/minimize this review, lp:~jjo/juju-deployer/diff-usability-fixes_and_diff-tests is stacked over this.

Revision history for this message
Kapil Thangavelu (hazmat) wrote :

thanks

On Fri, Nov 29, 2013 at 5:27 PM, JuanJo Ciarlante <
<email address hidden>> wrote:

> To ease/minimize this review,
> lp:~jjo/juju-deployer/diff-usability-fixes_and_diff-tests is stacked over
> this.
> --
>
> https://code.launchpad.net/~jjo/juju-deployer/diff-usability-fixes/+merge/197270
> Your team juju-deployers is requested to review the proposed merge of
> lp:~jjo/juju-deployer/diff-usability-fixes into lp:juju-deployer.
>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'deployer/action/diff.py'
2--- deployer/action/diff.py 2013-11-21 03:19:56 +0000
3+++ deployer/action/diff.py 2013-11-29 22:24:08 +0000
4@@ -122,10 +122,10 @@
5
6 def _diff_service(self, e_s, d_s, charm):
7 mod = {}
8- if 'constraints' in d_s:
9- d_sc = parse_constraints(d_s['constraints'])
10- if d_sc != e_s['constraints']:
11- mod['constraints'] = e_s['constraints']
12+ d_sc = parse_constraints(d_s.get('constraints',''))
13+ if d_sc != e_s['constraints']:
14+ mod['env-constraints'] = e_s['constraints']
15+ mod['cfg-constraints'] = d_sc
16 for k, v in d_s.get('options', {}).items():
17 # Deploy options not known to the env may originate
18 # from charm version delta or be an invalid config.
19@@ -133,17 +133,22 @@
20 continue
21 e_v = e_s['options'].get(k, {}).get('value')
22 if e_v != v:
23- mod['config'] = {k: e_v}
24+ mod.setdefault('env-config', {}).update({k: e_v})
25+ mod.setdefault('cfg-config', {}).update({k: v})
26 if not charm or not charm.is_subordinate():
27 if e_s['unit_count'] != d_s.get('num_units', 1):
28 mod['num_units'] = e_s['unit_count'] - d_s.get('num_units', 1)
29 return mod
30
31- def run(self):
32+ def do_diff(self):
33 self.start_time = time.time()
34+ self.deployment.resolve()
35 self.env.connect()
36 self.env_status = self.env.status()
37 self.load_env()
38- delta = self.get_delta()
39- if delta:
40- print yaml_dump(delta)
41+ return self.get_delta()
42+
43+ def run(self):
44+ diff = self.do_diff()
45+ if diff:
46+ print yaml_dump(diff)
47
48=== modified file 'deployer/env/go.py'
49--- deployer/env/go.py 2013-11-15 15:13:01 +0000
50+++ deployer/env/go.py 2013-11-29 22:24:08 +0000
51@@ -62,7 +62,7 @@
52 return self.client.get_constraints(svc_name)
53 except EnvError, e:
54 if 'constraints do not apply to subordinate services' in str(e):
55- return None
56+ return {}
57 else:
58 raise e
59
60
61=== added file 'deployer/tests/test_data/blog-haproxy-services.yaml'
62--- deployer/tests/test_data/blog-haproxy-services.yaml 1970-01-01 00:00:00 +0000
63+++ deployer/tests/test_data/blog-haproxy-services.yaml 2013-11-29 22:24:08 +0000
64@@ -0,0 +1,14 @@
65+- service_name: blog
66+ service_host: 0.0.0.0
67+ service_port: 80
68+ service_options:
69+ - mode http
70+ - option httplog
71+ - balance uri
72+ - hash-type consistent
73+ - timeout client 60000
74+ - timeout server 60000
75+ server_options:
76+ - check inter 2000
77+ - rise 2
78+ - fall 5
79
80=== modified file 'deployer/tests/test_data/blog.yaml'
81--- deployer/tests/test_data/blog.yaml 2013-07-22 15:29:31 +0000
82+++ deployer/tests/test_data/blog.yaml 2013-11-29 22:24:08 +0000
83@@ -28,14 +28,14 @@
84 tuning: optimized
85 engine: apache
86 wp-content: include-base64://blog.snippet
87- memcached:
88- branch: lp:charms/precise/memcached
89- options:
90- size: 100
91- haproxy:
92- charm_url: cs:precise/haproxy
93- options:
94- services: include-file://blog-include.yaml
95+ cache:
96+ branch: lp:charms/precise/memcached
97+ options:
98+ size: 100
99+ haproxy:
100+ charm_url: cs:precise/haproxy
101+ options:
102+ services: include-file://blog-haproxy-services.yaml
103 relations:
104 - [blog, db]
105 - - blog
106@@ -56,4 +56,4 @@
107 db:
108 constraints: instance-type=m1.large
109 options:
110- tuning-level: safest
111\ No newline at end of file
112+ tuning-level: safest
113
114=== modified file 'deployer/tests/test_deployment.py'
115--- deployer/tests/test_deployment.py 2013-10-31 19:19:36 +0000
116+++ deployer/tests/test_deployment.py 2013-11-29 22:24:08 +0000
117@@ -41,7 +41,7 @@
118
119 # Load up overrides and resolves
120 d.load_overrides(["key=abc"])
121- d.resolve_config()
122+ d.resolve()
123
124 # Verify include-base64
125 self.assertEqual(d.get_service('newrelic').config, {'key': 'abc'})

Subscribers

People subscribed via source and target branches