Skip to content

Commit bd5bbd1

Browse files
committed
Invert mistaken boolean conditional (#1865)
To date, the thread has quit immediately before completing the first iteration. This is a mistake as the thread should stay around for the life of the endpoint to verify that the parent always exists. Whoops! The automated test missed this because while it verified the loop conditional, it did not verify the internal conditional. Correct by ensuring loop iterates at least a few times. (Overkill to 100, "just because.")
1 parent d5b19ed commit bd5bbd1

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

compute_endpoint/globus_compute_endpoint/endpoint/interchange.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def start(self):
203203

204204
def _parent_watcher(ppid: int):
205205
while ppid == os.getppid():
206-
if not self._quiesce_event.wait(timeout=1):
206+
if self._quiesce_event.wait(timeout=1):
207207
return
208208
log.warning(f"Parent ({ppid}) has gone away; initiating shut down")
209209
self.stop()

compute_endpoint/tests/integration/endpoint/endpoint/test_interchange.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,13 @@ def test_die_with_parent_refuses_to_start_if_not_parent(mocker, ep_ix_factory):
168168
assert "refusing to start" in warn_msg
169169

170170

171-
def test_die_with_parent_goes_away_if_parent_dies(mocker, ep_ix_factory, mock_rp):
172-
ppid = os.getppid()
171+
def test_die_with_parent_goes_away_if_parent_dies(
172+
mocker, ep_ix_factory, mock_rp, mock_tqs
173+
):
174+
ppid = random.randint(2, 1_000_000)
173175

174-
mocker.patch(f"{_MOCK_BASE}time.sleep")
175176
mock_ppid = mocker.patch(f"{_MOCK_BASE}os.getppid")
176-
mock_ppid.side_effect = (ppid, 1)
177+
mock_ppid.side_effect = [ppid] * 100 + [1] # sometime in future, parent dies
177178
ei = ep_ix_factory(parent_pid=ppid)
178179
mock_warn = mocker.patch.object(log, "warning")
179180
assert not ei.time_to_quit, "Verify test setup"

0 commit comments

Comments
 (0)