Skip to content

Commit 2267687

Browse files
sl0thentr0pyclaude
andcommitted
test: pass SENTRY_PYTHON_TEST_REDIS_HOST through tox
The workflow sets SENTRY_PYTHON_TEST_REDIS_HOST=redis for 3.6/3.7 container runs (since redis is a sibling service container, not on loopback), but tox strips env vars not listed in passenv. The celery beat tests therefore read the default 127.0.0.1, find nothing on loopback inside the python container, and hang in kombu's retry_over_time. Adding the var to passenv fixes it; un-skip the beat tests on py3.7. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 1624c6f commit 2267687

5 files changed

Lines changed: 8 additions & 33 deletions

File tree

scripts/populate_tox/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"deps": {
7474
"*": ["newrelic<10.17.0", "redis"],
7575
"py3.6": ["newrelic<8"],
76-
"py3.7": ["importlib-metadata<5.0", "pytest-timeout"],
76+
"py3.7": ["importlib-metadata<5.0"],
7777
},
7878
},
7979
"chalice": {

scripts/populate_tox/tox.jinja

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,6 @@ setenv =
198198
common: PYTEST_ADDOPTS="--ignore=tests/test_shadowed_module.py"
199199
gevent: PYTEST_ADDOPTS="--ignore=tests/test_shadowed_module.py"
200200
201-
# Debug CI hangs for celery on py3.7: dump tracebacks and fail the test
202-
# rather than letting the job time out at the workflow level.
203-
py3.7-celery: PYTEST_ADDOPTS=--timeout=120 --timeout-method=thread
204-
205201
# TESTPATH definitions for test suites not managed by toxgen
206202
common: _TESTPATH=tests
207203
gevent: _TESTPATH=tests
@@ -226,6 +222,7 @@ passenv =
226222
SENTRY_PYTHON_TEST_POSTGRES_USER
227223
SENTRY_PYTHON_TEST_POSTGRES_PASSWORD
228224
SENTRY_PYTHON_TEST_POSTGRES_NAME
225+
SENTRY_PYTHON_TEST_REDIS_HOST
229226
TESTPATH
230227
231228
basepython =

tests/integrations/celery/integration_tests/__init__.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,11 @@ def tick(self):
2424
return 1
2525

2626

27-
def kill_beat(beat_pid_file, delay_seconds=1, pidfile_timeout=30):
27+
def kill_beat(beat_pid_file, delay_seconds=1):
2828
"""
29-
Terminates Celery Beat after `delay_seconds` of beat-runtime.
30-
31-
Waits up to `pidfile_timeout` seconds for the pidfile to appear before
32-
starting the runtime timer, so slow process startup doesn't race the
33-
killer into a FileNotFoundError that would leak a running beat.
29+
Terminates Celery Beat after the given `delay_seconds`.
3430
"""
3531
logger.info("Starting Celery Beat killer...")
36-
deadline = time.monotonic() + pidfile_timeout
37-
while not os.path.exists(beat_pid_file):
38-
if time.monotonic() > deadline:
39-
raise RuntimeError("Celery Beat pidfile %s never appeared" % beat_pid_file)
40-
time.sleep(0.05)
4132
time.sleep(delay_seconds)
4233
pid = int(open(beat_pid_file, "r").read())
4334
logger.info("Terminating Celery Beat...")

tests/integrations/celery/integration_tests/test_celery_beat_cron_monitoring.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,7 @@ def inner(propagate_traces=True, monitor_beat_tasks=False, **kwargs):
5353
return inner
5454

5555

56-
@pytest.mark.skipif(
57-
sys.version_info < (3, 8),
58-
reason="Requires Python 3.8+ (py3.7 + container fork hits kombu/redis-py issue)",
59-
)
56+
@pytest.mark.skipif(sys.version_info < (3, 7), reason="Requires Python 3.7+")
6057
@pytest.mark.forked
6158
def test_explanation(celery_init, capture_envelopes):
6259
"""
@@ -95,10 +92,7 @@ def test_task():
9592
assert len(envelopes) >= 0
9693

9794

98-
@pytest.mark.skipif(
99-
sys.version_info < (3, 8),
100-
reason="Requires Python 3.8+ (py3.7 + container fork hits kombu/redis-py issue)",
101-
)
95+
@pytest.mark.skipif(sys.version_info < (3, 7), reason="Requires Python 3.7+")
10296
@pytest.mark.forked
10397
def test_beat_task_crons_success(celery_init, capture_envelopes):
10498
app = celery_init(
@@ -131,10 +125,7 @@ def test_task():
131125
assert check_in["status"] == "ok"
132126

133127

134-
@pytest.mark.skipif(
135-
sys.version_info < (3, 8),
136-
reason="Requires Python 3.8+ (py3.7 + container fork hits kombu/redis-py issue)",
137-
)
128+
@pytest.mark.skipif(sys.version_info < (3, 7), reason="Requires Python 3.7+")
138129
@pytest.mark.forked
139130
def test_beat_task_crons_error(celery_init, capture_envelopes):
140131
app = celery_init(

tox.ini

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,6 @@ deps =
752752
celery: redis
753753
{py3.6}-celery: newrelic<8
754754
{py3.7}-celery: importlib-metadata<5.0
755-
{py3.7}-celery: pytest-timeout
756755

757756
dramatiq-v1.9.0: dramatiq==1.9.0
758757
dramatiq-v2.1.0: dramatiq==2.1.0
@@ -1000,10 +999,6 @@ setenv =
1000999
common: PYTEST_ADDOPTS="--ignore=tests/test_shadowed_module.py"
10011000
gevent: PYTEST_ADDOPTS="--ignore=tests/test_shadowed_module.py"
10021001

1003-
# Debug CI hangs for celery on py3.7: dump tracebacks and fail the test
1004-
# rather than letting the job time out at the workflow level.
1005-
py3.7-celery: PYTEST_ADDOPTS=--timeout=120 --timeout-method=thread
1006-
10071002
# TESTPATH definitions for test suites not managed by toxgen
10081003
common: _TESTPATH=tests
10091004
gevent: _TESTPATH=tests
@@ -1084,6 +1079,7 @@ passenv =
10841079
SENTRY_PYTHON_TEST_POSTGRES_USER
10851080
SENTRY_PYTHON_TEST_POSTGRES_PASSWORD
10861081
SENTRY_PYTHON_TEST_POSTGRES_NAME
1082+
SENTRY_PYTHON_TEST_REDIS_HOST
10871083
TESTPATH
10881084

10891085
basepython =

0 commit comments

Comments
 (0)