Add testing support option to introduce latency#15937
Open
jdaugherty wants to merge 1 commit into
Open
Conversation
Contributor
Author
|
@jamesfredley this gives us a way to reproduce the test run failures locally. The idea is we can add these to our test apps to introduce latency, then have AI iterate to fix the flakiness so this isn't a problem going forward. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 8.0.x #15937 +/- ##
==================================================
+ Coverage 49.3287% 49.3450% +0.0163%
- Complexity 16768 16791 +23
==================================================
Files 1985 1987 +2
Lines 93327 93357 +30
Branches 16336 16343 +7
==================================================
+ Hits 46037 46067 +30
+ Misses 40165 40164 -1
- Partials 7125 7126 +1
🚀 New features to boost your workflow:
|
✅ All tests passed ✅🏷️ Commit: 8f75d23 Learn more about TestLens at testlens.app. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a new testing support library,
grails-testing-support-latency, that injects artificiallatency into a running Grails application so that requests randomly take longer.
Why: Functional tests are prone to timing bugs — assertions that race a click-triggered
navigation, missing waits, response-ordering assumptions. These pass reliably on fast local
machines and fail intermittently on slower CI infrastructure (see the recent
User1FunctionalSpec.'edit report 20'flake in the spring-security ACL functional test app,which only reproduced when the server response was slow). Slowing responses down widens the
window in which these bugs occur, turning rare flakes into deterministic failures that can be
found and fixed locally.
What:
grails-testing-support-latency(org.apache.grails:grails-testing-support-latency):LatencyFilter— aOncePerRequestFilterthat delays each matched request by a randomamount between a configurable minimum and maximum, for a configurable fraction of requests,
with an optional fixed seed for reproducible delay sequences. Invalid configuration
(negative delays,
max-delay<min-delay, probability outside 0..1) fails fast at startup.LatencyProperties— bound from thegrails.testing.latencyprefix (enabled,min-delay,max-delay,probability,url-patterns,seed) with SpringDurationbinding.LatencyAutoConfiguration— conditional ongrails.testing.latency.enabled=true, so thelibrary is completely inert unless explicitly switched on; registers the filter at highest
precedence so the delay covers the entire request pipeline.
grails-test-examples/latencythat enables latency for/slow/*only andconfirms end-to-end behavior against the running application: matched requests take at least
the configured minimum, unmatched requests do not.
activation, full property table, YAML example, CI usage pattern, production warning) and a
"Latency Testing Support" entry in the What's New section.
settings.gradleandgradle/publish-root-config.gradle; the BOM picksit up automatically via the subprojects constraint loop.
Verification performed:
./gradlew :grails-testing-support-latency:build— 10 unit tests passing (delay bounds,zero-probability passthrough, configuration validation, conditional auto-configuration)
./gradlew :grails-test-examples-latency:integrationTest— 2 end-to-end tests passing./gradlew :grails-testing-support-latency:codeStyle— clean./gradlew :grails-doc:publishGuide -x aggregateGroovydoc— docs build clean, new sections renderContributor Checklist
Issue and Scope
the Description above. Happy to open a ticket for the release changelog if preferred.
documentation are all included.
existing API) targeting
8.0.x.Code Quality
dedicated example app with integration tests confirming runtime behavior.
./gradlew build --rerun-tasks.(Targeted builds above are green; full rerun not yet executed.)
codeStylepasses on the new module).and verified against the project's quality standards via the test and style checks above.
Licensing and Attribution
(Groovy, Gradle, YAML, XML, AsciiDoc) includes the Apache license header.
prepared with assistance from Claude Code (Anthropic), with human review of all changes.
Documentation
no Upgrade Notes changes are needed.