feat: Apply blanket minimum timeout bound to 1s - BED-7153#280
feat: Apply blanket minimum timeout bound to 1s - BED-7153#280definitelynotagoblin merged 1 commit intov4from
Conversation
WalkthroughThe changes introduce a minimum timeout feature to the AdaptiveTimeout class by adding a configurable lower bound parameter. A new constructor overload enables callers to specify a minimum timeout, and the GetAdaptiveTimeout method now clamps computed values to respect this minimum. One usage site explicitly disables adaptive timeouts for the GetMembers operation. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
test/unit/AdaptiveTimeoutTest.cs (2)
145-156: New minimum timeout test validates the clamping behavior.The test correctly verifies that when the computed adaptive timeout (based on a fast 50ms sample) falls below the configured
minTimeout, the result is clamped tominTimeout.One minor observation: the assertion on line 155 (
Assert.True(adaptiveTimeoutResult < maxTimeout)) is redundant given line 154 already asserts equality withminTimeout(which is less thanmaxTimeoutby constructor constraint). Consider removing it or keeping it as documentation of intent.🔧 Optional: Remove redundant assertion
var adaptiveTimeoutResult = adaptiveTimeout.GetAdaptiveTimeout(); Assert.Equal(minTimeout, adaptiveTimeoutResult); - Assert.True(adaptiveTimeoutResult < maxTimeout); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@test/unit/AdaptiveTimeoutTest.cs` around lines 145 - 156, Remove the redundant assertion in the AdaptiveTimeout_GetAdaptiveTimeout_MinTimeout test: delete the Assert.True(adaptiveTimeoutResult < maxTimeout) check (it duplicates the intent already proven by Assert.Equal(minTimeout, adaptiveTimeoutResult)). Locate the test method named AdaptiveTimeout_GetAdaptiveTimeout_MinTimeout and remove the extra Assert.True call so the test only asserts equality to minTimeout.
145-156: Consider adding validation tests for constructor edge cases.The new feature includes constructor validation that throws
ArgumentExceptionfor invalidminTimeoutvalues. Consider adding tests to verify these guard clauses:
minTimeout < TimeSpan.Zero→ should throwminTimeout >= maxTimeout→ should throw[Fact] public void AdaptiveTimeout_Constructor_ThrowsOnNegativeMinTimeout() { Assert.Throws<ArgumentException>(() => new AdaptiveTimeout(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(-1), new TestLogger(_testOutputHelper, Microsoft.Extensions.Logging.LogLevel.Trace), 10, 1000, 3)); } [Fact] public void AdaptiveTimeout_Constructor_ThrowsWhenMinTimeoutExceedsMax() { Assert.Throws<ArgumentException>(() => new AdaptiveTimeout(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2), new TestLogger(_testOutputHelper, Microsoft.Extensions.Logging.LogLevel.Trace), 10, 1000, 3)); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@test/unit/AdaptiveTimeoutTest.cs` around lines 145 - 156, Add unit tests that validate the AdaptiveTimeout constructor guard clauses: create tests (e.g., AdaptiveTimeout_Constructor_ThrowsOnNegativeMinTimeout and AdaptiveTimeout_Constructor_ThrowsWhenMinTimeoutExceedsMax) that call new AdaptiveTimeout(...) and assert ArgumentException is thrown when minTimeout < TimeSpan.Zero and when minTimeout >= maxTimeout respectively; use the same TestLogger and similar constructor args as other tests to locate the AdaptiveTimeout constructor validation code.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@test/unit/AdaptiveTimeoutTest.cs`:
- Around line 145-156: Remove the redundant assertion in the
AdaptiveTimeout_GetAdaptiveTimeout_MinTimeout test: delete the
Assert.True(adaptiveTimeoutResult < maxTimeout) check (it duplicates the intent
already proven by Assert.Equal(minTimeout, adaptiveTimeoutResult)). Locate the
test method named AdaptiveTimeout_GetAdaptiveTimeout_MinTimeout and remove the
extra Assert.True call so the test only asserts equality to minTimeout.
- Around line 145-156: Add unit tests that validate the AdaptiveTimeout
constructor guard clauses: create tests (e.g.,
AdaptiveTimeout_Constructor_ThrowsOnNegativeMinTimeout and
AdaptiveTimeout_Constructor_ThrowsWhenMinTimeoutExceedsMax) that call new
AdaptiveTimeout(...) and assert ArgumentException is thrown when minTimeout <
TimeSpan.Zero and when minTimeout >= maxTimeout respectively; use the same
TestLogger and similar constructor args as other tests to locate the
AdaptiveTimeout constructor validation code.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 537ed8ea-bc7a-4643-8614-fc160efcdb24
📒 Files selected for processing (3)
src/CommonLib/AdaptiveTimeout.cssrc/CommonLib/Processors/LocalGroupProcessor.cstest/unit/AdaptiveTimeoutTest.cs
Description
Add minimum timeout floor for adaptive timeouts, apply a 1 second blanket floor to all current uses, with the option being configurable.
Motivation and Context
https://specterops.atlassian.net/browse/BED-7153
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist:
Summary by CodeRabbit
New Features
Improvements