Skip to content

lmdb 5(b) Fix failing tests with LMDB#683

Open
subygan wants to merge 4 commits into
ENG-1159/migrate-fs-lmdbfrom
ENG-1159/fix-test
Open

lmdb 5(b) Fix failing tests with LMDB#683
subygan wants to merge 4 commits into
ENG-1159/migrate-fs-lmdbfrom
ENG-1159/fix-test

Conversation

@subygan

@subygan subygan commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Tests, helpers, and Windows CI setup were updated to use filesystem-backed merkle repositories and runner-temp test directories.

Changes

Filesystem-backed merkle test harness

Layer / File(s) Summary
Filesystem merkle helpers
crates/liboxen/src/test.rs
Adds filesystem-backed merkle repository initialization and a one-commit async test runner, along with the imports they use.
Tree wire-format tests
crates/liboxen/src/repositories/tree.rs
Switches the compress and create-node parity tests to the filesystem-backed async harness for on-disk node layout comparisons.
Tree unpack tests
crates/liboxen/src/repositories/tree.rs
Pins unpack-related tree tests to filesystem-backed repos, updates unpack behavior to skip existing entries, and runs the hash-recovery test through the async empty-dir harness.
Tree download tests
crates/liboxen/src/api/client/tree.rs
Replaces generic repo setup with filesystem-backed initialization and keeps the node-count assertions tied to .oxen/tree/nodes.
Migration tests
crates/liboxen/src/command/migrate/m20260626_migrate_merkle_nodes_to_lmdb.rs
Updates the migration test harnesses to initialize an FS-backed merkle backend from directory-based setup for the up path and leftover-temp-env case.
Windows CI test data paths
.github/workflows/ci_test.yml
Replaces the Windows ramdisk setup with runner-temp directories for test and sync paths.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Oxen-AI/Oxen#660: Updates the same merkle tree wire-format/parity tests around filesystem-backed storage behavior.
  • Oxen-AI/Oxen#638: Refactors tree unpack and related merkle-node behavior that these filesystem-pinned tests exercise.
  • Oxen-AI/Oxen#651: Adjusts tree download behavior and tests that now depend on .oxen/tree/nodes layout assertions.

Suggested reviewers

  • CleanCut

Poem

I twitch my nose at nodes in rows,
and hop where .oxen/tree/nodes grows.
The runner temp is neat and bright,
filesystem roots all pass the light.
🐰 Hop-hop!

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive No pull request description was provided, so there is nothing to assess against the changeset. Add a brief description summarizing the test fixes, especially the FS-pinned backend changes and LMDB migration test updates.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title matches the main change: stabilizing LMDB-related tests by pinning them to the filesystem backend.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ENG-1159/fix-test

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
crates/liboxen/src/test.rs (1)

472-482: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Preserve the original test error instead of collapsing it into assert!(result).

Any OxenError from the callback becomes the same panic, which makes the newly migrated FS-backend tests much harder to diagnose. Clean up, then return the callback’s Result directly.

Suggested fix
-    let result = match test(repo).await {
-        Ok(_) => true,
-        Err(err) => {
-            eprintln!("Error running test. Err: {err}");
-            false
-        }
-    };
-
-    maybe_cleanup_repo(&repo_dir)?;
-    assert!(result);
-    Ok(())
+    let result = test(repo).await;
+    maybe_cleanup_repo(&repo_dir)?;
+    result
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/liboxen/src/test.rs` around lines 472 - 482, The test harness in
test() is collapsing callback failures into a generic assert!(result) panic,
which hides the original OxenError. Update the flow around match
test(repo).await, maybe_cleanup_repo, and assert!(result) so cleanup still runs
but the callback’s Result is returned directly instead of converted to a
boolean/panic, preserving the original error context for failures.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/liboxen/src/test.rs`:
- Around line 435-441: The repository setup in test.rs only checks
config_filepath(path) after creating oxen_hidden_dir, so partially initialized
.oxen state can slip through. Update the helper that initializes the repo to
fail on any pre-existing hidden repo state by checking oxen_hidden_dir (or its
contents) before creating it, and keep the existing OxenError::basic_str
path-specific error in that initialization flow.

---

Nitpick comments:
In `@crates/liboxen/src/test.rs`:
- Around line 472-482: The test harness in test() is collapsing callback
failures into a generic assert!(result) panic, which hides the original
OxenError. Update the flow around match test(repo).await, maybe_cleanup_repo,
and assert!(result) so cleanup still runs but the callback’s Result is returned
directly instead of converted to a boolean/panic, preserving the original error
context for failures.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 709e7408-ce47-4afe-9882-08aaf1888341

📥 Commits

Reviewing files that changed from the base of the PR and between 84c98c4 and f2b83d3.

📒 Files selected for processing (4)
  • crates/liboxen/src/api/client/tree.rs
  • crates/liboxen/src/command/migrate/m20260626_migrate_merkle_nodes_to_lmdb.rs
  • crates/liboxen/src/repositories/tree.rs
  • crates/liboxen/src/test.rs

Comment on lines +435 to +441
let hidden_dir = util::fs::oxen_hidden_dir(path);
util::fs::create_dir_all(&hidden_dir)?;
if util::fs::config_filepath(path).try_exists()? {
return Err(OxenError::basic_str(format!(
"Oxen repository already exists: {path:?}"
)));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Fail on any pre-existing .oxen state, not just config.toml.

This helper creates .oxen first and only rejects when .oxen/config.toml already exists, so a partially initialized repo can be silently reused with stale tree/nodes contents. That breaks the clean-layout assumption the new FS-pinned tests rely on.

Suggested fix
 pub fn init_fs_merkle_backend(path: &Path) -> Result<LocalRepository, OxenError> {
     let hidden_dir = util::fs::oxen_hidden_dir(path);
-    util::fs::create_dir_all(&hidden_dir)?;
-    if util::fs::config_filepath(path).try_exists()? {
+    if hidden_dir.try_exists()? {
         return Err(OxenError::basic_str(format!(
             "Oxen repository already exists: {path:?}"
         )));
     }
+    util::fs::create_dir_all(&hidden_dir)?;
     let config = RepositoryConfig {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let hidden_dir = util::fs::oxen_hidden_dir(path);
util::fs::create_dir_all(&hidden_dir)?;
if util::fs::config_filepath(path).try_exists()? {
return Err(OxenError::basic_str(format!(
"Oxen repository already exists: {path:?}"
)));
}
let hidden_dir = util::fs::oxen_hidden_dir(path);
if hidden_dir.try_exists()? {
return Err(OxenError::basic_str(format!(
"Oxen repository already exists: {path:?}"
)));
}
util::fs::create_dir_all(&hidden_dir)?;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/liboxen/src/test.rs` around lines 435 - 441, The repository setup in
test.rs only checks config_filepath(path) after creating oxen_hidden_dir, so
partially initialized .oxen state can slip through. Update the helper that
initializes the repo to fail on any pre-existing hidden repo state by checking
oxen_hidden_dir (or its contents) before creating it, and keep the existing
OxenError::basic_str path-specific error in that initialization flow.

@subygan subygan force-pushed the ENG-1159/fix-test branch from 37d0d0d to f2b83d3 Compare June 27, 2026 00:33
@subygan subygan changed the title 5(b) Fix failing tests with LMDB lmdb 5(b) Fix failing tests with LMDB Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant