Repository navigation
test(rocm-core): give the JSONL store tests a record type of their own - #920
Closed
jussielo-amd wants to merge 1 commit into
Closed
jussielo-amd wants to merge 1 commit into
jussielo-amd wants to merge 1 commit into
Conversation
The tests in jsonl_store.rs drove the generic store engine through the automation audit store: they imported AuditEventRecord, append_audit_event and load_recent_audit_events and seeded files with helpers shaped around that record. That is a test-only edge from the generic engine back to one of its users, so the engine's own tests could not be read or run without its first customer. They now use a small local record (Entry, padded so a serialized line is about as long as a real store's, which the rotation caps and the torn-tail cuts are sized against) and local helpers over append_jsonl_record and load_recent_jsonl_records. automation.rs keeps its audit fixtures in test_support.rs and its own tests are unchanged. Test-only: every leaf test name and assertion is kept, and no production code changes. docs/architecture.md and docs/testing.md no longer describe the test-only edge. Signed-off-by: Jussi Elo <jussi.elo@amd.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block approval of the test-fixture decoupling change.
No open issues 🎉
What changed in this PR
Decouples the generic JSONL store tests from automation-specific records and helpers, keeping test fixtures aligned with the engine’s role in rocm-core. Production behavior is unchanged.
Changes:
- Introduces a local
Entryrecord and helpers for seeding, appending, reading, and repairing test stores. - Migrates existing tests to those fixtures while preserving test names and assertions.
- Updates documentation and fixture comments to describe the removed test dependency.
| File | Description |
|---|---|
| docs/testing.md | Documents the engine tests’ independent record type. |
| docs/architecture.md | Removes the description of the test-only dependency on automation. |
| crates/rocm-core/src/test_support.rs | Clarifies fixture usage in the module comment. |
| crates/rocm-core/src/jsonl_store.rs | Replaces audit-specific test fixtures with local records and store helpers. |
Review effort: Balanced
Collaborator
Author
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.
Summary
This delivers ROCMAI-886, which came out of the review of the rocm-core split. The tests in
crates/rocm-core/src/jsonl_store.rsdrove the generic JSONL store engine through the automation audit store: they importedAuditEventRecord,append_audit_eventandload_recent_audit_eventsand seeded files through helpers shaped around that record. That is a test-only edge from the generic engine back to one of its users, and it meant the engine's own tests could not be read, run or moved without the first customer. It did no harm to the build, which is why it was left as a follow-up, but the dependency pointed the wrong way.The store tests now carry their own small record type (
Entry, a tag plus padding so a serialized line is about as long as a real store's) and a handful of local helpers, and the engine's tests no longer name anything fromautomation.rs. The automation tests are untouched and keep covering the automation-specific stores through the shared audit fixtures intest_support.rs.This is a test-only change: no production code changes, every leaf test name is kept, and each test makes the same assertions about the same behaviour.
What moved
AuditEventRecord,audit_record,audit_line,audit_messagesfromtest_supportEntry,entry,entry_line,entry_tags, local tojsonl_store::testsseed_audit_store,paths.audit_events_path(),paths.ensure()seed_store,temp_store(a store path under a throwaway root, directory created)append_audit_event,load_recent_audit_eventsappend_entry(no rotation),load_recent_entries(the same four generations the audit reader used), overappend_jsonl_recordandload_recent_jsonl_recordsrepair_audit_store_withrepair_store_with, taking the store paththe_store_lock_is_a_sibling_of_the_storebuilt paths throughAppPathsaccessorstest_support.rskeeps its audit helpers, sinceautomation.rsstill uses them; only its module comment changes to say so.docs/architecture.mdno longer describes the test-only edge, anddocs/testing.mdnotes that the engine's tests use a record type of their own.Verification
Ran locally:
cargo fmt --all --checkandcargo clippy -p rocm-core --all-targets -- -D warnings: clean.cargo test -p rocm-core --lib --no-fail-fast: 1004 passed, 3 ignored, before and after. The sorted--listof test names is byte-identical before and after (1007 entries), so no leaf name was added, dropped or renamed.cargo xtask manifest --checkandcargo xtask check-crate-edges: both pass. Lychee overdocs/architecture.mdanddocs/testing.mdpasses, and the repository's pre-commit hooks passed on the commit.load_recent_spans_a_rollover); dropping the store lock (rotation_under_concurrent_threads_loses_no_recordsandrotation_keeps_the_live_file_and_the_configured_generationsfail); changing the lock file's name (the_store_lock_is_a_sibling_of_the_store); disabling the shrink retry (load_recent_retries_past_a_shrink_mid_scan_and_succeeds); dropping the generation shift (7 rotation tests fail); making a successful replace fall through to the truncate (a_torn_tail_is_not_truncated_when_replacing_the_store_works); and cutting the torn tail one byte too far (three torn-tail tests fail).cargo llvm-cov -p rocm-core --summary-onlyreports 89.58% of 32797 lines before and 89.57% of 32793 lines after (jsonl_store.rsitself 96.21% to 95.91%: three more)?;error-propagation lines of multi-line test calls are unexecuted, as they were for the equivalent calls before). That is about 0.01 points, well inside the 0.2 point tolerance ofcargo xtask coverage, andcoverage-floors.tomlis not touched. I did not run the fullcargo xtask coverageacross the workspace.Not run locally: the Windows cross-check of the
cfg(windows)test (append_repairs_a_torn_tail_while_another_handle_blocks_replacing_the_store), becausering's build script needslib.exe, which this Linux host lacks. That test was edited the same way as its Unix siblingappend_repairs_a_torn_tail_in_a_directory_that_takes_no_new_files(a store path andappend_entryin place of the audit accessors), and the Windows CI job is what exercises it. The full workspace gate,cargo xtask e2eandscripts/smoke_local.pyare left to CI.User-visible behaviour
None, so no Gherkin scenario applies: the change is confined to a
#[cfg(test)]module and two documentation sentences, and no command output, exit code, file or engine selection changes.Notes for reviewers
It is a single commit. The interesting part is the fixture block at the top of
jsonl_store::tests; the rest of the diff is mechanical substitution of the audit helpers with those. The padding inEntryis deliberate: the rotation tests size their byte caps against a realistic line length (TEST_ROTATIONrotates after about 14 records, androtation_under_concurrent_threads_loses_no_recordsasserts it rotates more than once), and the torn-tail tests cut the first 20 bytes of a line, so a minimal one-field record would have changed what they exercise. The store is namedevents.jsonlbecausea_failed_rotation_prints_its_warning_once_to_stderrasserts the warning names that file.