Skip to content

Commit

Permalink
Shutdown engines in test
Browse files Browse the repository at this point in the history
Add a missing `.shutdown()` in a test engine factory.  The comment was correct
that the _executor_ was not started, but either missed that the status
reporting thread was started, or the rug was changed underneath it.
  • Loading branch information
khk-globus committed Jan 13, 2025
1 parent 20ee473 commit 1d82637
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions compute_endpoint/tests/unit/test_gce_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

@pytest.fixture
def gce_factory(tmp_path, randomstring) -> t.Callable:
engines: list[GlobusComputeEngine] = []

def _kernel(**k):
expect_uri = randomstring(length=random.randint(1, 20))
expect_opts = randomstring(length=random.randint(1, 20))
Expand All @@ -27,16 +29,21 @@ def _kernel(**k):
**k,
}
with mock.patch(f"{_MOCK_BASE}ReportingThread"):
gce = GlobusComputeEngine(**k)
with mock.patch.object(gce.executor, "start"):
gce.start(endpoint_id=uuid.uuid4(), run_dir=tmp_path)
assert gce.executor.start.called
with mock.patch(f"{_MOCK_BASE}JobStatusPoller"):
gce = GlobusComputeEngine(**k)
gce.executor.start = mock.Mock()
gce.start(endpoint_id=uuid.uuid4(), run_dir=str(tmp_path))
assert gce.executor.start.called

engines.append(gce)

# No cleanup necessary because executor not started
return gce, expect_uri, expect_opts

yield _kernel

for e in engines:
e.shutdown()


def test_docker(tmp_path, gce_factory):
gce, exp_uri, exp_opts = gce_factory(container_type="docker")
Expand Down

0 comments on commit 1d82637

Please sign in to comment.