Merge lp:~bigdata-dev/charms/trusty/hdp-hadoop/cs-jps-quickfix into lp:charms/trusty/hdp-hadoop

Proposed by Cory Johns
Status: Merged
Merged at revision: 32
Proposed branch: lp:~bigdata-dev/charms/trusty/hdp-hadoop/cs-jps-quickfix
Merge into: lp:charms/trusty/hdp-hadoop
Diff against target: 49 lines (+9/-9)
2 files modified
hooks/bdutils.py (+7/-7)
tests/01-hadoop-cluster-deployment-1.py (+2/-2)
To merge this branch: bzr merge lp:~bigdata-dev/charms/trusty/hdp-hadoop/cs-jps-quickfix
Reviewer Review Type Date Requested Status
Matt Bruzek (community) Approve
amir sanjar (community) Approve
Review via email: mp+250932@code.launchpad.net

Description of the change

To post a comment you must log in.
Revision history for this message
amir sanjar (asanjar) :
review: Approve
Revision history for this message
Matt Bruzek (mbruzek) wrote :

I can't get the charm tests to run from my computer, but these changes look good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/bdutils.py'
2--- hooks/bdutils.py 2014-09-17 14:49:16 +0000
3+++ hooks/bdutils.py 2015-02-25 14:48:55 +0000
4@@ -1,4 +1,5 @@
5 #!/usr/bin/python
6+import re
7 import os
8 import pwd
9 import grp
10@@ -124,10 +125,9 @@
11 os.environ[ll[0]] = ll[1].strip().strip(';').strip("\"").strip()
12
13 def is_jvm_service_active(processname):
14- cmd=["jps"]
15- p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
16- out, err = p.communicate()
17- if err == None and str(out).find(processname) != -1:
18- return True
19- else:
20- return False
21\ No newline at end of file
22+ pat = re.sub(r'^(.)', r'^[^ ]*java .*[\1]', processname)
23+ try:
24+ output = subprocess.check_output(['sudo', 'pgrep', '-f', pat])
25+ except subprocess.CalledProcessError:
26+ return False
27+ return filter(None, map(str.strip, output.split('\n'))) != []
28
29=== modified file 'tests/01-hadoop-cluster-deployment-1.py'
30--- tests/01-hadoop-cluster-deployment-1.py 2014-11-21 18:37:23 +0000
31+++ tests/01-hadoop-cluster-deployment-1.py 2015-02-25 14:48:55 +0000
32@@ -28,7 +28,7 @@
33 # Validate hadoop services on master node have been started
34 ############################################################
35 def test_hadoop_master_service_status(self):
36- o,c= self.master_unit.run("jps | awk '{print $2}'")
37+ o,c= self.master_unit.run("pgrep -a java")
38 if o.find('ResourceManager') == -1:
39 amulet.raise_status(amulet.FAIL, msg="ResourceManager not started")
40 else:
41@@ -46,7 +46,7 @@
42 # Validate hadoop services on compute node have been started
43 ############################################################
44 def test_hadoop_compute_service_status(self):
45- o,c= self.compute_unit.run("jps | awk '{print $2}'")
46+ o,c= self.compute_unit.run("pgrep -a java")
47 if o.find('NodeManager') == -1:
48 amulet.raise_status(amulet.FAIL, msg="NodeManager not started")
49 else:

Subscribers

People subscribed via source and target branches