Skip to content

[MOD-15026] allow passing startup grace#247

Merged
GuyAv46 merged 2 commits intoRedisLabsModules:masterfrom
JoanFM:joan-startup-grace
Apr 23, 2026
Merged

[MOD-15026] allow passing startup grace#247
GuyAv46 merged 2 commits intoRedisLabsModules:masterfrom
JoanFM:joan-startup-grace

Conversation

@JoanFM
Copy link
Copy Markdown
Contributor

@JoanFM JoanFM commented Apr 23, 2026

Why this change

RLTest's StandardEnv.startEnv has a hardcoded time.sleep(0.1) between subprocess.Popen(redis-server ...) and the liveness probe (_isAlive + waitForRedisToStartwait_for_conn). That 100 ms grace period is the only window during which the framework tolerates a redis-server that exits on its own (e.g. because a loadmodule argument was rejected and the server aborted).

For tests that intentionally pass invalid module args and expect the server to fail to start, this is racy:

  • If redis-server aborts within 100 ms → _isAlive returns False, masterProcess is set to None, Env.__init__ returns cleanly, and the test can assert not env.isUp().
  • If redis-server aborts slightly later (common under load, ASAN, macOS, CI) → _isAlive returns True, the framework opens a connection, and wait_for_conn eventually raises Exception('Redis server is dead ...'). That exception is raised from inside Env.__init__ before RTestInstance.currEnv is assigned, so even when the test's own try/except swallows it, the runner reports a spurious <Environment destroyed> failure at teardown.

Concretely, this has been making testconfigMultiTextOffsetDeltaSlopNeg flaky in RediSearch, where we pass MULTI_TEXT_SLOP -1 on purpose and expect the module to reject it during init.

What this PR does

Adds a startupGraceSecs parameter (default 0.1, i.e. identical to the current behavior) to StandardEnv.__init__ and Env.__init__, plumbed through getEnvKwargs, and replaces the hardcoded time.sleep(0.1) in startEnv with time.sleep(self.startupGraceSecs).

Tests that expect the server to abort during module init can then bump the grace period, e.g.:

env = Env(moduleArgs='MULTI_TEXT_SLOP -1', startupGraceSecs=2)
assert not env.isUp()

This keeps the liveness probe from racing with the abort without affecting any existing caller.

@JoanFM JoanFM changed the title allow passing startup grace [MOD-15026] allow passing startup grace Apr 23, 2026
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 23, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 34.26%. Comparing base (02cfbb9) to head (e6148b6).
⚠️ Report is 9 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #247      +/-   ##
==========================================
+ Coverage   32.46%   34.26%   +1.79%     
==========================================
  Files          17       17              
  Lines        2597     2697     +100     
==========================================
+ Hits          843      924      +81     
- Misses       1754     1773      +19     
Flag Coverage Δ
unittests 34.26% <100.00%> (+1.79%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@GuyAv46 GuyAv46 merged commit b2c5fd3 into RedisLabsModules:master Apr 23, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants