<p>Pau Espin Pedrol <strong>merged</strong> this change.</p><p><a href="https://gerrit.osmocom.org/13527">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Jenkins Builder: Verified
  Pau Espin Pedrol: Looks good to me, approved

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">process: Early return during process termination if no proc running<br><br>This avoids extra unneeded logging about killing with signal when<br>actually no signal is being sent.<br><br>Change-Id: I5b5dd78fe3301d8eef2ab93da3b37029268ae198<br>---<br>M selftest/suite_test.ok<br>M src/osmo_gsm_tester/process.py<br>M src/osmo_gsm_tester/suite.py<br>3 files changed, 8 insertions(+), 57 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/selftest/suite_test.ok b/selftest/suite_test.ok</span><br><span>index 85e94b2..908f24f 100644</span><br><span>--- a/selftest/suite_test.ok</span><br><span>+++ b/selftest/suite_test.ok</span><br><span>@@ -96,14 +96,6 @@</span><br><span> tst hello_world.py:[LINENR]: two  [test_suite↪hello_world.py:[LINENR]]</span><br><span> tst hello_world.py:[LINENR]: three  [test_suite↪hello_world.py:[LINENR]]</span><br><span> tst hello_world.py:[LINENR] Test passed (N.N sec)  [test_suite↪hello_world.py]</span><br><span>---- ParallelTerminationStrategy: DBG: Scheduled to terminate 0 processes.</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGTERM</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGINT</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGKILL</span><br><span>---- ParallelTerminationStrategy: DBG: Scheduled to terminate 0 processes.</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGTERM</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGINT</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGKILL</span><br><span> ---------------------------------------------------------------------</span><br><span> trial test_suite PASS</span><br><span> ---------------------------------------------------------------------</span><br><span>@@ -127,14 +119,6 @@</span><br><span> tst test_error.py:[LINENR]: I am 'test_suite' / 'test_error.py:[LINENR]'  [test_suite↪test_error.py:[LINENR]]  [test_error.py:[LINENR]]</span><br><span> tst test_error.py:[LINENR]: ERR: AssertionError: test_error.py:[LINENR]: assert False  [test_suite↪test_error.py:[LINENR]]  [test_error.py:[LINENR]: assert False]</span><br><span> tst test_error.py:[LINENR]: Test FAILED (N.N sec)  [test_suite↪test_error.py:[LINENR]]  [test.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Scheduled to terminate 0 processes.  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGTERM  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGINT  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGKILL  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Scheduled to terminate 0 processes.  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGTERM  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGINT  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGKILL  [process.py:[LINENR]]</span><br><span> ---------------------------------------------------------------------</span><br><span> trial test_suite FAIL</span><br><span> ---------------------------------------------------------------------</span><br><span>@@ -158,14 +142,6 @@</span><br><span> tst test_fail.py:[LINENR]: I am 'test_suite' / 'test_fail.py:[LINENR]'  [test_suite↪test_fail.py:[LINENR]]  [test_fail.py:[LINENR]]</span><br><span> tst test_fail.py:[LINENR]: ERR: EpicFail: This failure is expected  [test_suite↪test_fail.py:[LINENR]]  [test_fail.py:[LINENR]]</span><br><span> tst test_fail.py:[LINENR]: Test FAILED (N.N sec)  [test_suite↪test_fail.py:[LINENR]]  [test.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Scheduled to terminate 0 processes.  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGTERM  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGINT  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGKILL  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Scheduled to terminate 0 processes.  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGTERM  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGINT  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGKILL  [process.py:[LINENR]]</span><br><span> ---------------------------------------------------------------------</span><br><span> trial test_suite FAIL</span><br><span> ---------------------------------------------------------------------</span><br><span>@@ -188,14 +164,6 @@</span><br><span> ----------------------------------------------</span><br><span> tst test_fail_raise.py:[LINENR]: ERR: ExpectedFail: This failure is expected  [test_suite↪test_fail_raise.py:[LINENR]]  [test_fail_raise.py:[LINENR]: raise ExpectedFail('This failure is expected')]</span><br><span> tst test_fail_raise.py:[LINENR]: Test FAILED (N.N sec)  [test_suite↪test_fail_raise.py:[LINENR]]  [test.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Scheduled to terminate 0 processes.  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGTERM  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGINT  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGKILL  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Scheduled to terminate 0 processes.  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGTERM  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGINT  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGKILL  [process.py:[LINENR]]</span><br><span> ---------------------------------------------------------------------</span><br><span> trial test_suite FAIL</span><br><span> ---------------------------------------------------------------------</span><br><span>@@ -283,14 +251,6 @@</span><br><span> tst hello_world.py:[LINENR]: two  [test_suite↪hello_world.py:[LINENR]]  [hello_world.py:[LINENR]]</span><br><span> tst hello_world.py:[LINENR]: three  [test_suite↪hello_world.py:[LINENR]]  [hello_world.py:[LINENR]]</span><br><span> tst hello_world.py:[LINENR] Test passed (N.N sec)  [test_suite↪hello_world.py]  [test.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Scheduled to terminate 0 processes.  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGTERM  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGINT  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGKILL  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Scheduled to terminate 0 processes.  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGTERM  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGINT  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGKILL  [process.py:[LINENR]]</span><br><span> ---------------------------------------------------------------------</span><br><span> trial test_suite PASS</span><br><span> ---------------------------------------------------------------------</span><br><span>@@ -378,14 +338,6 @@</span><br><span> tst hello_world.py:[LINENR]: two  [test_suite↪hello_world.py:[LINENR]]  [hello_world.py:[LINENR]]</span><br><span> tst hello_world.py:[LINENR]: three  [test_suite↪hello_world.py:[LINENR]]  [hello_world.py:[LINENR]]</span><br><span> tst hello_world.py:[LINENR] Test passed (N.N sec)  [test_suite↪hello_world.py]  [test.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Scheduled to terminate 0 processes.  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGTERM  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGINT  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGKILL  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Scheduled to terminate 0 processes.  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGTERM  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGINT  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGKILL  [process.py:[LINENR]]</span><br><span> ---------------------------------------------------------------------</span><br><span> trial test_suite PASS</span><br><span> ---------------------------------------------------------------------</span><br><span>@@ -519,14 +471,6 @@</span><br><span> tst hello_world.py:[LINENR]: two  [test_suite↪hello_world.py:[LINENR]]  [hello_world.py:[LINENR]]</span><br><span> tst hello_world.py:[LINENR]: three  [test_suite↪hello_world.py:[LINENR]]  [hello_world.py:[LINENR]]</span><br><span> tst hello_world.py:[LINENR] Test passed (N.N sec)  [test_suite↪hello_world.py]  [test.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Scheduled to terminate 0 processes.  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGTERM  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGINT  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGKILL  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Scheduled to terminate 0 processes.  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGTERM  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGINT  [process.py:[LINENR]]</span><br><span>---- ParallelTerminationStrategy: DBG: Starting to kill with SIGKILL  [process.py:[LINENR]]</span><br><span> ---------------------------------------------------------------------</span><br><span> trial test_suite PASS</span><br><span> ---------------------------------------------------------------------</span><br><span>diff --git a/src/osmo_gsm_tester/process.py b/src/osmo_gsm_tester/process.py</span><br><span>index 441d4ea..66ecae5 100644</span><br><span>--- a/src/osmo_gsm_tester/process.py</span><br><span>+++ b/src/osmo_gsm_tester/process.py</span><br><span>@@ -104,7 +104,10 @@</span><br><span>             time.sleep(wait_step)</span><br><span> </span><br><span>     def terminate_all(self):</span><br><span style="color: hsl(0, 100%, 40%);">-        self.dbg("Scheduled to terminate %d processes." % len(self._processes))</span><br><span style="color: hsl(120, 100%, 40%);">+        num_processes = len(self._processes)</span><br><span style="color: hsl(120, 100%, 40%);">+        self.dbg("Scheduled to terminate %d processes." % num_processes)</span><br><span style="color: hsl(120, 100%, 40%);">+        if num_processes == 0:</span><br><span style="color: hsl(120, 100%, 40%);">+            return</span><br><span>         self._prune_dead_processes(True)</span><br><span>         self._build_process_map()</span><br><span> </span><br><span>@@ -116,6 +119,8 @@</span><br><span>             if sig == signal.SIGKILL:</span><br><span>                 continue</span><br><span>             self._poll_for_termination()</span><br><span style="color: hsl(120, 100%, 40%);">+            if len(self._processes) == 0:</span><br><span style="color: hsl(120, 100%, 40%);">+                return</span><br><span> </span><br><span> </span><br><span> class Process(log.Origin):</span><br><span>diff --git a/src/osmo_gsm_tester/suite.py b/src/osmo_gsm_tester/suite.py</span><br><span>index 85eca46..0738e96 100644</span><br><span>--- a/src/osmo_gsm_tester/suite.py</span><br><span>+++ b/src/osmo_gsm_tester/suite.py</span><br><span>@@ -244,6 +244,8 @@</span><br><span>         self._processes.insert(0, (process, respawn))</span><br><span> </span><br><span>     def stop_processes(self):</span><br><span style="color: hsl(120, 100%, 40%);">+        if len(self._processes) == 0:</span><br><span style="color: hsl(120, 100%, 40%);">+            return</span><br><span>         strategy = process.ParallelTerminationStrategy()</span><br><span>         while self._processes:</span><br><span>             proc, _ = self._processes.pop()</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/13527">change 13527</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/13527"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-gsm-tester </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I5b5dd78fe3301d8eef2ab93da3b37029268ae198 </div>
<div style="display:none"> Gerrit-Change-Number: 13527 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: Pau Espin Pedrol <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder (1000002) </div>
<div style="display:none"> Gerrit-Reviewer: Pau Espin Pedrol <pespin@sysmocom.de> </div>