Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions csharp/test/E2E/FeatureFlagCacheE2ETest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,18 @@ public async Task TestFeatureFlagCache_SingleExternalCallAcrossConnections()
OutputHelper?.WriteLine(
$"[FeatureFlagCacheE2ETest] {connectionCount} connections to the same host -> actual external feature-flag fetches: {fetchCount}");

// Assert - exactly one external call; the rest served from the shared cache.
Assert.Equal(1, fetchCount);
// Assert - the shared cache DEDUPS: far fewer external fetches than connections.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Low — The <summary> docstring for this test still asserts the old, now-removed contract: it says opening multiple connections "results in exactly one actual connector-service fetch; the rest are served from the cache." The body of the PR deliberately relaxes that to tolerate a second fetch under the negative-cache TTL. The docstring now contradicts the assertion (fetchCount <= 2) directly below it. Consider updating it to describe dedup ("at most 2 fetches") so the stated contract matches the code.

The test method name TestFeatureFlagCache_SingleExternalCallAcrossConnections is similarly stale, but renaming it is optional churn; the docstring is the clearer fix.

(Anchored to the nearest changed line — see the description for the exact location.)

// Not exactly 1: if the first fetch hits a transient failure/timeout, it is cached
// with a short 60s NEGATIVE TTL (FeatureFlagContext.DefaultNegativeTtl) by design, so a
// later connection legitimately re-fetches — a healthy run makes 1 external call, and a
// run that caught one transient makes 2, both of which still prove dedup (4-of-5 or
// 3-of-5 served from cache). Asserting == 1 turned that designed-in retry into a flake
// (observed Expected 1 / Actual 2). Require dedup: strictly fewer fetches than
// connections, and at most 2 (one initial + at most one transient re-fetch).
Assert.True(fetchCount >= 1 && fetchCount < connectionCount && fetchCount <= 2,
$"Feature-flag cache should dedup {connectionCount} connections to at most 2 external "
+ $"fetches (1 healthy, or 2 if the first fetch transiently failed and re-fetched under "
+ $"the negative-cache TTL), but saw {fetchCount}.");
Assert.True(cache.TryGetContext(hostName!, out _), "Context should be cached after the first fetch");
}

Expand Down
Loading