-
Notifications
You must be signed in to change notification settings - Fork 5
Cache /getQuarantineConfig on disk with short TTL for MutTestReport
#941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache /getQuarantineConfig on disk with short TTL for MutTestReport
#941
Conversation
|
😎 Merged successfully - details. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #941 +/- ##
==========================================
+ Coverage 73.58% 73.86% +0.28%
==========================================
Files 72 72
Lines 16460 16539 +79
==========================================
+ Hits 12112 12217 +105
+ Misses 4348 4322 -26 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
test_report/src/report.rs
Outdated
| let cache_data = match fs::read_to_string(&cache_path) { | ||
| Ok(data) => data, | ||
| Err(err) => { | ||
| tracing::warn!("Failed to read quarantined tests cache file: {:?}", err); | ||
| return None; | ||
| } | ||
| }; | ||
|
|
||
| let cache_entry: QuarantinedTestsDiskCacheEntry = match serde_json::from_str(&cache_data) { | ||
| Ok(entry) => entry, | ||
| Err(err) => { | ||
| tracing::warn!("Failed to parse quarantined tests cache file: {:?}", err); | ||
| return None; | ||
| } | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I think this can be simplified by having it streamed directly from the reader
serde_json::from_reader(reader)
test_report/src/report.rs
Outdated
| // first check in-memory cache | ||
| if self.0.borrow().quarantined_tests.as_ref().is_some() { | ||
| // already fetched | ||
| return; | ||
| } | ||
|
|
||
| // then check disk cache | ||
| if let Some(quarantined_tests) = | ||
| self.load_quarantined_tests_from_disk_cache(&org_url_slug, &repo_url) | ||
| { | ||
| // update in-memory cache | ||
| self.0.borrow_mut().quarantined_tests = Some(quarantined_tests); | ||
| return; | ||
| } | ||
|
|
||
| // cache miss - make API call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: The comments feel self-explanatory and unnecessary.
| cached_at_secs: now, | ||
| }; | ||
|
|
||
| // create cache directory if it doesn't exist |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is also unnecessary
TRUNK-17215
Caches the result of
/getQuarantineConfiglocally on disk with a TTL of 5 min, duration configurable via theTRUNK_QUARANTINED_TESTS_DISK_CACHE_TTL_SECSenv var. This caching is only configured forMutTestReport, currently only utilized by the rspec plugin. This should help mitigate the number of network requests needed for customers who:Tested with a locally-built gem with these changes, observed correct cache hits & misses. Example cached results file: