Repository navigation
Add regression tests for record renewal in credentials-core - #89
Conversation
Add regression tests for the renewal coordinator and its store writes: refresh intents, cooldowns, parked records, forced reads and the lock registry. Tests only; no production change. Refs cortexkit#88.
RefreshLogs installs a thread-local subscriber without register_callsite, so tracing can cache Interest::never for the refresh events when another thread reaches them first. Return Interest::always and filter by target in event(), as connectors_tests does. This is a suspected cause of the outage-log test flake, not a proven one: the test still failed once in our runs with this change applied.
|
Design gate skipped: the |
There was a problem hiding this comment.
1 issue found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="crates/credentials-core/src/store_tests.rs">
<violation number="1" location="crates/credentials-core/src/store_tests.rs:3646">
P2: This assertion expects `NeedsReauth`, but the intent version is 2 while the stored record remains version 1, so reconciliation returns `NotFound` on the version guard. Expect `NotFound` or create a parked record at version 2.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
| let stale_version = store.read_intent(id).unwrap().unwrap(); | ||
| assert!(matches!( | ||
| store.get_for_reconciliation(&stale_version), | ||
| Err(StoreOpError::NeedsReauth) |
There was a problem hiding this comment.
P2: This assertion expects NeedsReauth, but the intent version is 2 while the stored record remains version 1, so reconciliation returns NotFound on the version guard. Expect NotFound or create a parked record at version 2.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At crates/credentials-core/src/store_tests.rs, line 3646:
<comment>This assertion expects `NeedsReauth`, but the intent version is 2 while the stored record remains version 1, so reconciliation returns `NotFound` on the version guard. Expect `NotFound` or create a parked record at version 2.</comment>
<file context>
@@ -3449,6 +3449,216 @@ fn refresh_commit_cannot_restore_non_active_records() {
+ let stale_version = store.read_intent(id).unwrap().unwrap();
+ assert!(matches!(
+ store.get_for_reconciliation(&stale_version),
+ Err(StoreOpError::NeedsReauth)
+ ));
+ store.open_intent(id, 1, "old-hash").unwrap();
</file context>
| Err(StoreOpError::NeedsReauth) | |
| Err(StoreOpError::NotFound) |
|
Thank you for these. Merged as 7a1be58. Before merging we checked two of them against planted changes: dropping the start-time check from the intent confirmation fails You were right that The fix keeps a second, disabled dispatcher registered while the test runs, so the interest is worked out across every dispatcher. The test now also makes another thread reach the log site first every time, so it fails reliably without the fix. It replaces the I also merged #90: with the enrolled fence arm removed, its test fails at the final |
Refs #88
This pull request changes tests only. If it fits, please label it
trivial, as CONTRIBUTING.md allows when there is no design to agree.What changes
test(credentials-core): cover record renewaladds 15 tests for the renewal coordinator and its store writes: refresh intents, report cooldowns, parked records, forced reads, and the lock registry. They are inengine_tests.rs,store_tests.rs, and the#[cfg(test)] mod lock_registry_testsinengine.rs. No production code changes.test(credentials-core): let RefreshLogs see cached callsitesis a separate commit with the subscriber change you asked for:RefreshLogsreturnsInterest::always()fromregister_callsiteand filters by target inevent(), asconnectors_tests.rsdoes. This is a suspected cause of theauth_events_refresh_outage_logs_onset_and_recovery_across_restartsflake, not a proven one: in our runs that test still failed once with this change applied. You can drop this commit and keep the first one.How it was checked
The 32 code changes in the issue table are the ones these tests catch. Each new test fails on its change and passes on unchanged code. After review, three assertions became stricter (an exact error variant, a success read before a refusal, and no deferral row on a forced read), and a planted change proved each one again.
On the head of this branch (master
1a40f031plus these two commits), on Linux:cargo fmt --all -- --checkandcargo clippy --workspace --all-targets -- -D warningspass.cargo test -p credentials-core --all-featurespassed in two of three runs (1278 tests each). The third run failed onlyauth_events_refresh_outage_logs_onset_and_recovery_across_restartsatengine_tests.rs:1188. That is the flake that the second commit is for, so the second commit does not remove it completely.AI helped write this draft.
Summary by cubic
Adds regression tests covering the record renewal coordinator and its store writes, tied to the failing cases from issue #88. Tests only, no production code changes.
engine_tests.rs,store_tests.rs, andengine.rsfor refresh intents, report cooldowns, parked records, forced reads, and the lock registry.RefreshLogsinengine_tests.rsto register callsites withInterest::always()and filter by target inevent(), matching howconnectors_tests.rsworks. This is a suspected cause of theauth_events_refresh_outage_logs_onset_and_recovery_across_restartsflake, not a proven one—the test still failed once with the change applied. Drop this commit if you prefer to keep the PR strictly tests-only.Written for commit c8adb8d. Summary will update on new commits.