bipinprasad commented on a change in pull request #3273:
URL: https://github.com/apache/storm/pull/3273#discussion_r434901650
##########
File path:
storm-server/src/test/java/org/apache/storm/daemon/supervisor/ContainerTest.java
##########
@@ -271,4 +281,88 @@ public boolean runProfiling(ProfileRequest request,
boolean stop) throws IOExcep
return false;
}
}
+
+ private Collection<Long> getRunningProcessIds() throws IOException {
+ // get list of few running processes
+ Collection<Long> pids = new ArrayList<>();
+ Process p = Runtime.getRuntime().exec(ServerUtils.IS_ON_WINDOWS ?
"tasklist" : "ps -e");
+ try (BufferedReader input = new BufferedReader(new
InputStreamReader(p.getInputStream()))) {
+ String line;
+ while ((line = input.readLine()) != null) {
+ line = line.trim();
+ if (line.isEmpty()) {
+ continue;
+ }
+ try {
+ pids.add(Long.parseLong(line.split("\\s")[0]));
+ } catch (Exception ex) {
+ continue;
+ }
+ }
+ }
+ return pids;
+ }
+
+ @Test
+ public void testIsProcessAlive() throws Exception {
+ // specific selected process should be alive for a randomly generated
user
+ String randomUser = RandomStringUtils.randomAlphanumeric(12);
+
+ // get list of few running processes
+ Collection<Long> pids = getRunningProcessIds();
+ Assert.isNonEmpty(pids);
+ for (long pid: pids) {
+ boolean status = Container.isProcessAlive(pid, randomUser);
+ org.junit.Assert.assertFalse("Random user " + randomUser + " is
not expected to own any process", status);
Review comment:
changed
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]