Repository navigation
test: delete e2e merchant accounts after each run - #344
Merged
Merged
Conversation
Calls core-api's DELETE /merchant-accounts/{id} (gr4vy/core-api#9999)
directly, since it is not in the public spec. Failures are logged and
never fail the run.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A create whose response is lost still leaves the account on the server; deleting an id that was never created returns 404, which cleanup already treats as done. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Active moderate and critical findings remain in Harness.java: the sandbox URL is duplicated rather than derived from the SDK template, and cleanup can delete an account this run did not create after a definitive create rejection.
2 open issues
What changed in this PR
Adds shutdown-time cleanup for merchant accounts created by E2E tests, preventing sandbox account accumulation through a signed raw DELETE request.
Changes:
- Tracks shared and test-specific merchant accounts before creation.
- Registers a JVM shutdown hook to delete tracked accounts.
- Treats successful and already-missing accounts as completed while logging other failures.
Review findings:
- Moderate (4 votes): Derive the cleanup host from
Gr4vy.SERVERSandSERVER_IDinstead of duplicating the sandbox URL. - Critical (1 vote): Avoid deleting an account when creation was definitively rejected; retain pre-create tracking only for ambiguous failures or verify ownership before deletion.
This pull request requires changes.
| File | Summary |
|---|---|
src/test/java/com/gr4vy/sdk/util/Harness.java |
Tracks merchant accounts and deletes them during JVM shutdown. |
src/test/java/com/gr4vy/sdk/backoffice/MerchantAccountsTest.java |
Registers the additional merchant account created by the test for cleanup. |
Review effort: Lite
cbetta
marked this pull request as ready for review
November 4, 2026 16:03
Reuses Checkout.API_BASE_URL so the delete call can't drift from the host the SDK client targets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.


Every e2e run left its merchant accounts behind on api.sandbox.e2e.gr4vy.app now that it is no longer reset. This deletes them with core-api's new
DELETE /merchant-accounts/{id}(gr4vy/core-api#9999, TA-19741). It isn't in the public spec, so the call is a raw request signed with the existingPRIVATE_KEY. A failed delete is logged and never fails the run (204 and 404 both count as done).Each CI shard is its own JVM, so the hook runs once per shard. The shared merchant is tracked when it is created, and
MerchantAccountsTest.createtracks its extra account.Cleanup is armed before the create call, so an account whose create response is lost still gets deleted (a never-created id just returns 404).
Verified:
./gradlew compileTestJava(JDK 21) passes. Not yet run live against e2e.🤖 Generated with Claude Code