Skip to content

Commit 459dc5e

Browse files
Drop the subclass wrapper teardown test
The scenario it covered belongs to the integration that still wraps run(), and is exercised by the idempotency test in #24852. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 883dee0 commit 459dc5e

1 file changed

Lines changed: 0 additions & 71 deletions

File tree

datadog_checks_base/tests/base/checks/test_database_check.py

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -74,53 +74,6 @@ def shutdown(self):
7474
self.shutdown_calls += 1
7575

7676

77-
class UnmigratedWrapperCheck(LifecycleCheck):
78-
"""Check that still carries its own copy of the cancellation protocol, the way Postgres does.
79-
80-
Mirrors PostgreSql.run/cancel/_finalize, so the base wrapper is reached through a subclass
81-
wrapper that calls super().run() rather than being the outermost run(). Its _finalize is
82-
guarded, which is what keeps teardown from running once per wrapper.
83-
"""
84-
85-
def __init__(self, *args, **kwargs):
86-
super().__init__(*args, **kwargs)
87-
self.finalize_calls = 0
88-
89-
def run(self):
90-
with self._cancel_lock:
91-
if self._cancelled:
92-
return ''
93-
self._is_running = True
94-
try:
95-
return super().run()
96-
finally:
97-
needs_finalize = False
98-
with self._cancel_lock:
99-
self._is_running = False
100-
if self._cancelled:
101-
needs_finalize = True
102-
if needs_finalize:
103-
self._finalize()
104-
105-
def cancel(self):
106-
self.cancel_async_jobs()
107-
needs_finalize = False
108-
with self._cancel_lock:
109-
self._cancelled = True
110-
if not self._is_running:
111-
needs_finalize = True
112-
if needs_finalize:
113-
self._finalize()
114-
115-
def _finalize(self):
116-
with self._cancel_lock:
117-
if self._finalized:
118-
return
119-
self._finalized = True
120-
self.finalize_calls += 1
121-
self.shutdown()
122-
123-
12477
@pytest.fixture
12578
def registry_check():
12679
check = FakeDatabaseCheck("test", {}, [{}])
@@ -361,30 +314,6 @@ def test_run_async_jobs_does_not_restart_jobs_after_cancel():
361314
assert job._job_loop_future is None
362315

363316

364-
def test_subclass_run_wrapper_finalizes_once():
365-
"""Teardown runs once for an integration that still wraps run() itself.
366-
367-
Such a wrapper reaches this one through super().run(), so both frames see the cancellation
368-
and call _finalize(). The base wrapper does not special-case that nesting; the subclass's own
369-
idempotency guard is what keeps teardown from running once per wrapper. This covers the
370-
window before integrations drop their wrappers in favour of this class's.
371-
"""
372-
check = UnmigratedWrapperCheck("test", {}, [{}])
373-
check.release_check.clear()
374-
run_thread = threading.Thread(target=check.run)
375-
run_thread.start()
376-
assert check.in_check.wait(timeout=WAIT_TIMEOUT)
377-
378-
check.cancel()
379-
check.release_check.set()
380-
run_thread.join(timeout=WAIT_TIMEOUT)
381-
382-
assert not run_thread.is_alive()
383-
assert check.check_calls == 1
384-
assert check.finalize_calls == 1
385-
assert check.shutdown_calls == 1
386-
387-
388317
def test_check_is_reclaimed_after_cancel():
389318
"""Verify cancel() breaks every reference cycle, so refcounting alone reclaims the check.
390319

0 commit comments

Comments
 (0)