Skip to content

Op head reconciliation testing - #44

Open
sidracha wants to merge 1 commit into
srachaba-6-get-op-headsfrom
srachaba-7-reconcile-tests
Open

sidracha wants to merge 1 commit into
srachaba-6-get-op-headsfrom
srachaba-7-reconcile-tests

Conversation

@sidracha

@sidracha sidracha commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

tests: add reconciliation unit tests and concurrent op head integration tests

Add unit tests in server/src/reconcile_op_heads.rs that directly exercise reconcile_repo_op_heads(). One test verifies the single-head fast path, where reconciliation is a no-op and the existing head is returned without invoking jj-lib. Another test sets up two divergent operation heads in the store and asserts that the server's reconciliation produces exactly the same merged operation as calling jj-lib's resolution directly, confirming parity with jj-lib. A failure-path test registers a divergent head whose underlying operation object is missing from the store, and verifies that reconciliation retries MAX_RETRIES times and then surfaces an error to the caller rather than silently succeeding.

Add integration tests in cli/tests/test_concurrent_op_heads.rs that run against a live SQLite-backed server. The first test has two clients race to advance the same op head, and verifies that the stale write is rejected with a CAS conflict. A stress test fires many concurrent UpdateOpHeads RPCs at once and verifies that no writes are lost. Another test confirms that ReconcileOpHeads is a no-op when only a single op head exists for the repo. The final test is end-to-end: it creates divergent op heads in a real workspace, runs a jj CLI command, and confirms that the client automatically triggers server-side reconciliation, collapsing the divergent heads into a single merged operation.

@sidracha
sidracha force-pushed the srachaba-7-reconcile-tests branch 2 times, most recently from 4344c89 to e87600f Compare September 8, 2026 18:47
@sidracha
sidracha force-pushed the srachaba-7-reconcile-tests branch from e87600f to 5cc8a8e Compare September 14, 2026 20:50
…on tests

Add unit tests in server/src/reconcile_op_heads.rs that directly exercise reconcile_repo_op_heads(). One test verifies the single-head fast path, where reconciliation is a no-op and the existing head is returned without invoking jj-lib. Another test sets up two divergent operation heads in the store and asserts that the server's reconciliation produces exactly the same merged operation as calling jj-lib's resolution directly, confirming parity with jj-lib. A failure-path test registers a divergent head whose underlying operation object is missing from the store, and verifies that reconciliation retries MAX_RETRIES times and then surfaces an error to the caller rather than silently succeeding.

Add integration tests in cli/tests/test_concurrent_op_heads.rs that run against a live SQLite-backed server. The first test has two clients race to advance the same op head, and verifies that the stale write is rejected with a CAS conflict. A stress test fires many concurrent UpdateOpHeads RPCs at once and verifies that no writes are lost. Another test confirms that ReconcileOpHeads is a no-op when only a single op head exists for the repo. The final test is end-to-end: it creates divergent op heads in a real workspace, runs a jj CLI command, and confirms that the client automatically triggers server-side reconciliation, collapsing the divergent heads into a single merged operation.
@sidracha
sidracha force-pushed the srachaba-7-reconcile-tests branch from 5cc8a8e to 7148b0b Compare September 14, 2026 20:59
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