Merge lp:~yellow/charm-tools/trunk into lp:~charmers/charm-tools/trunk

Proposed by Brad Crittenden on 2012-04-11
Status: Merged
Approved by: Juan L. Negron on 2012-09-05
Approved revision: 149
Merge reported by: Juan L. Negron
Merged at revision: not available
Proposed branch: lp:~yellow/charm-tools/trunk
Merge into: lp:~charmers/charm-tools/trunk
Diff against target: 139 lines (+23/-13)
3 files modified
helpers/python/charmhelpers/__init__.py (+12/-8)
helpers/python/charmhelpers/tests/test_charmhelpers.py (+10/-4)
setup.py (+1/-1)
To merge this branch: bzr merge lp:~yellow/charm-tools/trunk
Reviewer Review Type Date Requested Status
Juan L. Negron (community) 2012-04-11 Approve on 2012-08-31
Review via email: mp+101554@code.launchpad.net

Description of the Change

Update parsing of 'juju status' output to account for change in tokens ('state' -> 'agent-state').

To post a comment you must log in.
Juan L. Negron (negronjl) wrote :

Reviewing this now.

-Juan

Juan L. Negron (negronjl) wrote :

Hello:

Thanks for the contribution! Wow this was a mouthful :)

I see a few things that need to be addressed:

- This depends on python-testtools and python shelltoolbox
  I couldn't find shelltoolbox on the archive ( I did find it here: https://launchpad.net/python-shelltoolbox )
  The package dependency should be addressed as this package will fail testing at least.
  The necessary changes should be made to fix the failed dependency on shelltoolbox (branch, include the package, etc.)

Would you address the above and resubmit ?

Thanks,

Juan

review: Resubmit
Brad Crittenden (bac) wrote :

Hi Juan,

Thank you for the review and I apologize for not responding sooner but I missed the email.

We have a current action item for Clint to provide packaging for python-shelltoolbox and for packaging the python parts of charm-tools. We'll need him to complete those two tasks before this code can be merged.

Mark Mims (mark-mims) wrote :

On 06/18/2012 09:10 AM, Brad Crittenden wrote:
> Hi Juan,
>
> Thank you for the review and I apologize for not responding sooner but I missed the email.
>
> We have a current action item for Clint to provide packaging for python-shelltoolbox and for packaging the python parts of charm-tools. We'll need him to complete those two tasks before this code can be merged.
Hey Brad, do you have individual bugs for those? Juan and I are trying
to handle what we can for Clint right now (newborn baby and all).

--
Mark Mims, Ph.D.
Canonical Ltd.
<email address hidden>
+1(512)981-6467

Brad Crittenden (bac) wrote :

Hi Mark,

We communicated with Clint informally for those tasks, IIRC. I'll open bugs and link them here.

Brad Crittenden (bac) wrote :

Hi Mark,

I've opened bug 1016585 against lp:python-shelltoolbox and bug 1016588 against charm-tools for the two packaging tasks that we'd previously discussed with Clint. Let me know if you have questions.

Brad Crittenden (bac) wrote :

Hi Juan,

python-shelltoolbox has been accepted into Sid and Quantal. The dependency would still break on Precise and earlier unless we add python-shelltoolbox to the juju PPA.

What do you recommend?

Juan L. Negron (negronjl) wrote :

Hi Brad:

I have no objections to adding python-shelltoolbox to the juju PPA. Let's
see what Clint and Mark say about it. It would require more than just my
+1 on this for it to happen.

Mark?

Clint?

Thanks,

Juan

On Thu, Aug 30, 2012 at 7:09 AM, Brad Crittenden <email address hidden> wrote:

> Hi Juan,
>
> python-shelltoolbox has been accepted into Sid and Quantal. The
> dependency would still break on Precise and earlier unless we add
> python-shelltoolbox to the juju PPA.
>
> What do you recommend?
> --
> https://code.launchpad.net/~yellow/charm-tools/trunk/+merge/101554
> You are reviewing the proposed merge of lp:~yellow/charm-tools/trunk into
> lp:charm-tools.
>

Mark Mims (mark-mims) wrote :

no complaints from me... please go ahead.

Thanks for putting that package together!!

On Thu, Aug 30, 2012 at 09:35:31AM -0700, Juan Negron wrote:
> Hi Brad:
>
> I have no objections to adding python-shelltoolbox to the juju PPA. Let's
> see what Clint and Mark say about it. It would require more than just my
> +1 on this for it to happen.
>
> Mark?
>
> Clint?
>
> Thanks,
>
> Juan
>
>
>
> On Thu, Aug 30, 2012 at 7:09 AM, Brad Crittenden <email address hidden> wrote:
>
> > Hi Juan,
> >
> > python-shelltoolbox has been accepted into Sid and Quantal. The
> > dependency would still break on Precise and earlier unless we add
> > python-shelltoolbox to the juju PPA.
> >
> > What do you recommend?
> > --
> > https://code.launchpad.net/~yellow/charm-tools/trunk/+merge/101554
> > You are reviewing the proposed merge of lp:~yellow/charm-tools/trunk into
> > lp:charm-tools.
> >

--
Mark Mims, Ph.D.
Ubuntu Server Team
Canonical Ltd.
<email address hidden>
+1(512)981-6467

Brad Crittenden (bac) wrote :

Hi Juan and Mark,

Yesterday Clint merged Graham's branch that included the python module into charm tools. This branch adds some necessary fixes to be current with juju changes that occurred after Graham submitted his branch. Without the changes in this branch the python helpers are broken.

The review should be much easier than the previous version and getting it merged straightforward.

Thanks,
Brad

Juan L. Negron (negronjl) wrote :

This LGTM. Approved.

-Juan

review: Approve
Brad Crittenden (bac) wrote :

Juan could you mark this proposal as 'Approved' and please land it for me as I don't have permission.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'helpers/python/charmhelpers/__init__.py'
2--- helpers/python/charmhelpers/__init__.py 2012-03-16 15:11:45 +0000
3+++ helpers/python/charmhelpers/__init__.py 2012-08-31 13:20:31 +0000
4@@ -12,6 +12,10 @@
5 'relation_get',
6 'relation_set',
7 'unit_info',
8+ 'wait_for_machine',
9+ 'wait_for_page_contents',
10+ 'wait_for_relation',
11+ 'wait_for_unit',
12 ]
13
14 from collections import namedtuple
15@@ -19,7 +23,6 @@
16 import operator
17 from shelltoolbox import (
18 command,
19- run,
20 script_name,
21 )
22 import tempfile
23@@ -28,6 +31,7 @@
24 import yaml
25
26
27+SLEEP_AMOUNT = 0.1
28 Env = namedtuple('Env', 'uid gid home')
29 log = command('juju-log')
30 # We create a juju_status Command here because it makes testing much,
31@@ -125,14 +129,14 @@
32 if len(non_zookeeper_machines) >= num_machines:
33 all_machines_running = True
34 for machine in non_zookeeper_machines:
35- if machine['instance-state'] != 'running':
36+ if machine.get('instance-state') != 'running':
37 all_machines_running = False
38 break
39 if all_machines_running:
40 break
41 if time.time() - start_time >= timeout:
42 raise RuntimeError('timeout waiting for service to start')
43- time.sleep(0.1)
44+ time.sleep(SLEEP_AMOUNT)
45 return num_machines, time.time() - start_time
46
47
48@@ -141,14 +145,14 @@
49 wait_for_machine(num_machines=1)
50 start_time = time.time()
51 while True:
52- state = unit_info(service_name, 'state')
53+ state = unit_info(service_name, 'agent-state')
54 if 'error' in state or state == 'started':
55 break
56 if time.time() - start_time >= timeout:
57 raise RuntimeError('timeout waiting for service to start')
58- time.sleep(0.1)
59+ time.sleep(SLEEP_AMOUNT)
60 if state != 'started':
61- raise RuntimeError('unit did not start, state: ' + state)
62+ raise RuntimeError('unit did not start, agent-state: ' + state)
63
64
65 def wait_for_relation(service_name, relation_name, timeout=120):
66@@ -160,7 +164,7 @@
67 break
68 if time.time() - start_time >= timeout:
69 raise RuntimeError('timeout waiting for relation to be up')
70- time.sleep(0.1)
71+ time.sleep(SLEEP_AMOUNT)
72
73
74 def wait_for_page_contents(url, contents, timeout=120, validate=None):
75@@ -178,4 +182,4 @@
76 return page
77 if time.time() - start_time >= timeout:
78 raise RuntimeError('timeout waiting for contents of ' + url)
79- time.sleep(0.1)
80+ time.sleep(SLEEP_AMOUNT)
81
82=== modified file 'helpers/python/charmhelpers/tests/test_charmhelpers.py'
83--- helpers/python/charmhelpers/tests/test_charmhelpers.py 2012-03-19 11:50:05 +0000
84+++ helpers/python/charmhelpers/tests/test_charmhelpers.py 2012-08-31 13:20:31 +0000
85@@ -1,6 +1,5 @@
86 # Tests for Python charm helpers.
87
88-import charmhelpers
89 import unittest
90 import yaml
91
92@@ -8,6 +7,13 @@
93 from StringIO import StringIO
94 from testtools import TestCase
95
96+import sys
97+# Path hack to ensure we test the local code, not a version installed in
98+# /usr/local/lib. This is necessary since /usr/local/lib is prepended before
99+# what is specified in PYTHONPATH.
100+sys.path.insert(0, 'helpers/python')
101+import charmhelpers
102+
103
104 class CharmHelpersTestCase(TestCase):
105 """A basic test case for Python charm helpers."""
106@@ -56,7 +62,7 @@
107 'relations': {
108 'db': {'state': 'up'},
109 },
110- 'state': unit_state,
111+ 'agent-state': unit_state,
112 }
113 service_data['units']['{}/{}'.format(service_name, i)] = (
114 unit_data)
115@@ -131,9 +137,9 @@
116 self.patch(charmhelpers, 'juju_status', mock_juju_status)
117 self.assertEqual(
118 'pending',
119- charmhelpers.unit_info('test-service', 'state'))
120+ charmhelpers.unit_info('test-service', 'agent-state'))
121
122- def test_unit_info_returns_empty_for_nonexistant_service(self):
123+ def test_unit_info_returns_empty_for_nonexistent_service(self):
124 # If the service passed to unit_info() has not yet started (or
125 # otherwise doesn't exist), unit_info() will return an empty
126 # string.
127
128=== modified file 'setup.py'
129--- setup.py 2012-03-14 22:13:47 +0000
130+++ setup.py 2012-08-31 13:20:31 +0000
131@@ -10,7 +10,7 @@
132
133 from setuptools import setup, find_packages
134
135-__version__ = '0.0.1'
136+__version__ = '0.0.3'
137
138
139 setup(

Subscribers

People subscribed via source and target branches