Skip to content

Commit 41e2c6c

Browse files
fix: Make FDv1 fallback test more robust against timing issues
The test was flaky on Windows CI because it required exactly 2 listener calls before signaling success. On the VALID->fallback path, the first notification from FDv1 init isn't guaranteed to arrive before the explicit update. Simplified to match the pattern used by the error-path test: signal on the first listener call and verify the flag key. Co-Authored-By: mkeeler@launchdarkly.com <keelerm84@gmail.com>
1 parent 0424bc8 commit 41e2c6c

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

ldclient/testing/impl/datasystem/test_fdv2_datasystem.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -266,14 +266,10 @@ def test_fdv2_falls_back_to_fdv1_on_polling_success_with_header():
266266

267267
changed = Event()
268268
changes: List[FlagChange] = []
269-
count = 0
270269

271270
def listener(flag_change: FlagChange):
272-
nonlocal count
273-
count += 1
274271
changes.append(flag_change)
275-
if count >= 2:
276-
changed.set()
272+
changed.set()
277273

278274
set_on_ready = Event()
279275
fdv2 = FDv2(Config(sdk_key="dummy"), data_system_config)
@@ -282,11 +278,11 @@ def listener(flag_change: FlagChange):
282278

283279
assert set_on_ready.wait(1), "Data system did not become ready in time"
284280

285-
# Trigger a flag update in FDv1
281+
# Update flag in FDv1 data source to verify it's being used
286282
td_fdv1.update(td_fdv1.flag("fdv1-fallback-flag").on(False))
287283
assert changed.wait(2), "Flag change listener was not called in time"
288284

289-
# Verify FDv1 is active
285+
# Verify we got flag changes from FDv1
290286
assert len(changes) > 0
291287
assert any(c.key == "fdv1-fallback-flag" for c in changes)
292288

0 commit comments

Comments
 (0)