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

Proposed by Cory Johns
Status: Merged
Merged at revision: 18
Proposed branch: lp:~bigdata-dev/charms/trusty/hdp-storm/cs-jps-quickfix
Merge into: lp:charms/trusty/hdp-storm
Diff against target: 86 lines (+23/-20)
2 files modified
hooks/bdutils.py (+20/-17)
tests/10-deploy (+3/-3)
To merge this branch: bzr merge lp:~bigdata-dev/charms/trusty/hdp-storm/cs-jps-quickfix
Reviewer Review Type Date Requested Status
Matt Bruzek (community) Approve
amir sanjar (community) Approve
Review via email: mp+250934@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 was not able to get the charm tests running on my machine but I looked over the code and it looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hooks/bdutils.py'
--- hooks/bdutils.py 2014-09-03 04:10:49 +0000
+++ hooks/bdutils.py 2015-02-25 14:49:18 +0000
@@ -1,4 +1,5 @@
1#!/usr/bin/python1#!/usr/bin/python
2import re
2import os3import os
3import pwd4import pwd
4import grp5import grp
@@ -133,28 +134,30 @@
133 m = ll[0]+" = "+ll[1].strip().strip(';').strip("\"").strip()134 m = ll[0]+" = "+ll[1].strip().strip(';').strip("\"").strip()
134 #log ("==> {} ".format("\""+m+"\""))135 #log ("==> {} ".format("\""+m+"\""))
135 os.environ[ll[0]] = ll[1].strip().strip(';').strip("\"").strip()136 os.environ[ll[0]] = ll[1].strip().strip(';').strip("\"").strip()
136 137
138
139def jps(name):
140 """
141 Get PIDs for named Java processes, for any user.
142 """
143 pat = re.sub(r'^(.)', r'^[^ ]*java .*[\1]', name)
144 try:
145 output = subprocess.check_output(['sudo', 'pgrep', '-f', pat])
146 except subprocess.CalledProcessError:
147 return []
148 return map(int, filter(None, map(str.strip, output.split('\n'))))
149
150
137def is_jvm_service_active(processname):151def is_jvm_service_active(processname):
138 cmd=["jps"]152 return jps(processname) != []
139 p = subprocess.Popen(cmd, stdout=subprocess.PIPE)153
140 out, err = p.communicate()
141 if err == None and str(out).find(processname) != -1:
142 return True
143 else:
144 return False
145154
146def kill_java_process(process):155def kill_java_process(process):
147 cmd=["jps"]156 for pid in jps(process):
148 p = subprocess.Popen(cmd, stdout=subprocess.PIPE)157 os.kill(pid, signal.SIGTERM)
149 out, err = p.communicate()
150 cmd = out.split()
151 for i in range(0, len(cmd)):
152 if cmd[i] == process:
153 pid = int(cmd[i-1])
154 os.kill(pid, signal.SIGTERM)
155 return 0158 return 0
156159
157def mergeFiles(file1, file2):160def mergeFiles(file1, file2):
158 with open(file1, 'a') as f1:161 with open(file1, 'a') as f1:
159 with open(file2) as f2:162 with open(file2) as f2:
160 f1.write(f2.read())
161\ No newline at end of file163\ No newline at end of file
164 f1.write(f2.read())
162165
=== modified file 'tests/10-deploy'
--- tests/10-deploy 2014-09-19 22:54:54 +0000
+++ tests/10-deploy 2015-02-25 14:49:18 +0000
@@ -28,7 +28,7 @@
28 getattr(self, test)()28 getattr(self, test)()
2929
30 def test_zookeeper_service_status(self):30 def test_zookeeper_service_status(self):
31 o,c= self.zk_unit.run("jps | awk '{print $2}'")31 o,c= self.zk_unit.run("pgrep -a java")
32 if o.find('QuorumPeerMain') == -1:32 if o.find('QuorumPeerMain') == -1:
33 amulet.raise_status(amulet.FAIL, msg="Zookeeper QuorumPeerMain not started")33 amulet.raise_status(amulet.FAIL, msg="Zookeeper QuorumPeerMain not started")
34 34
@@ -51,13 +51,13 @@
51 if (time.time() - ticks) > 300:51 if (time.time() - ticks) > 300:
52 amulet.raise_status(amulet.FAIL, msg="nimbus-server is not started")52 amulet.raise_status(amulet.FAIL, msg="nimbus-server is not started")
53 break53 break
54 o,c= self.st_unit.run("jps | awk '{print $2}'")54 o,c= self.st_unit.run("pgrep -a java")
55 if o.find('nimbus') != -1:55 if o.find('nimbus') != -1:
56 break56 break
57 time.sleep(2)57 time.sleep(2)
58 58
59 def test_storm_slave_service_status(self):59 def test_storm_slave_service_status(self):
60 o,c= self.st_slave_unit.run("jps | awk '{print $2}'")60 o,c= self.st_slave_unit.run("pgrep -a java")
61 if o.find('supervisor') == -1:61 if o.find('supervisor') == -1:
62 amulet.raise_status(amulet.FAIL, msg="supervisor is not started")62 amulet.raise_status(amulet.FAIL, msg="supervisor is not started")
63 63

Subscribers

People subscribed via source and target branches