Skip to content

[antithesis] Enable reuse of banff e2e test for antithesis testing #3554

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

marun
Copy link
Contributor

@marun marun commented Nov 19, 2024

Why this should be merged

Having to duplicate existing test coverage to benefit from execution with antithesis is not ideal. Better to be able to trivially refactor compatible e2e coverage for reuse. This PR refactors the banff e2e test for reuse with antithesis to demonstrate that this is possible.

How this works

  • adds new APITestFunction type that a compatible e2e test can implement to allow for execution with both ginkgo and antithesis
  • adds ExecuteAPITest helper to simplify execution of an APITestFunction with ginkgo
  • Refactors the banff e2e test into an APITestFunction executed by ExecuteAPITest
  • Refactors the avalanchego antithesis test setup to support execution of the banff test
    • Moves test dispatch into a new function so that panics can be recovered via a deferred function
      • This supports use of require by e2e tests without risking an unhandled panic exiting the test process

How this was tested

CI

Need to be documented in RELEASES.md?

N/A

@marun marun marked this pull request as draft November 19, 2024 15:24
@marun marun changed the title bE2e reuse [antithesis] Enable reuse of banff e2e test for antithesis testing Nov 19, 2024
@marun marun added the testing This primarily focuses on testing label Nov 19, 2024
@marun marun self-assigned this Nov 19, 2024
@marun marun marked this pull request as ready for review November 19, 2024 18:14
@marun marun marked this pull request as draft November 20, 2024 21:59
@marun
Copy link
Contributor Author

marun commented Nov 20, 2024

Switched to draft in light of wanting to rebase on #3557

@marun marun changed the base branch from master to testing-switch-to-zap November 21, 2024 13:52
@marun marun force-pushed the testing-switch-to-zap branch from cf8a4d4 to 292016a Compare November 21, 2024 19:27
Base automatically changed from testing-switch-to-zap to master November 21, 2024 22:39
@marun marun marked this pull request as ready for review November 22, 2024 16:12
@marun marun marked this pull request as draft December 5, 2024 13:44
@marun
Copy link
Contributor Author

marun commented Dec 5, 2024

Moving to draft and adding a bunch of TODOs prompted by a manually-triggered antithesis run. The error handling of the e2e test is not sufficiently robust, so there are a lot of unhelpful errors that need to be addressed before this PR will be mergeable.

@marun marun force-pushed the e2e-reuse branch 3 times, most recently from 6e0b41c to 981663d Compare December 14, 2024 20:33
Copy link

This PR has become stale because it has been open for 30 days with no activity. Adding the lifecycle/frozen label will cause this PR to ignore lifecycle events.

Copy link

github-actions bot commented Mar 9, 2025

This PR has become stale because it has been open for 30 days with no activity. Adding the lifecycle/frozen label will cause this PR to ignore lifecycle events.

@maru-ava maru-ava moved this from In Progress 🏗️ to Ready 🚦 in avalanchego Jul 2, 2025
@maru-ava maru-ava marked this pull request as ready for review July 2, 2025 22:36
@Copilot Copilot AI review requested due to automatic review settings July 2, 2025 22:36
@maru-ava maru-ava self-requested a review as a code owner July 2, 2025 22:36
@maru-ava maru-ava requested review from Elvis339, joshua-kim and RodrigoVillar and removed request for StephenButtolph and Elvis339 July 2, 2025 22:36
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the Banff end-to-end tests to be reusable by both Ginkgo and Antithesis harnesses, enhancing context management and cleanup handling.

  • Introduce APITestFunction and ExecuteAPITest to unify API-based test execution
  • Extend TestContext with parent context support and revamp cleanup via Recover/RecoverAndExit
  • Refactor Banff suite and Antithesis entrypoints to use the new abstractions

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_context.go Added GetDefaultContextParent() to TestContext interface
tests/simple_test_context.go Added parent context, error/panic handlers, replaced Cleanup with Recover/RecoverAndExit
tests/load/c/main/main.go Switched defer from tc.Cleanup() to tc.RecoverAndExit()
tests/fixture/e2e/ginkgo_test_context.go Registered GinkgoTestContext and implemented GetDefaultContextParent()
tests/fixture/e2e/apitest.go Defined APITestFunction and ExecuteAPITest helper
tests/e2e/banff/suites.go Refactored Banff test into TestCustomAssetTransfer and invoked via ExecuteAPITest
tests/context_helpers.go Updated ContextWithTimeout to respect TestContext parent context
tests/antithesis/xsvm/main.go Switched to antithesis context and RecoverAndExit(), set parent context
tests/antithesis/context.go Added NewInstrumentedTestContextWithArgs with Antithesis assertion handlers
tests/antithesis/avalanchego/main.go Adopted Antithesis context abstraction and replaced wallet init with e2e.NewWallet
Comments suppressed due to low confidence (1)

tests/simple_test_context.go:70

  • [nitpick] Consider adding unit tests for RecoverAndExit and Recover to verify cleanup invocation and correct panic/exit behavior under assertion failures.
func (tc *SimpleTestContext) RecoverAndExit() {

@joshua-kim joshua-kim moved this from Ready 🚦 to In Progress 🏗️ in avalanchego Jul 7, 2025
@maru-ava maru-ava requested a review from Elvis339 July 8, 2025 05:54
@maru-ava
Copy link
Contributor

Approving my own PR is a treat (because my personal account proposed it), but I'll hold off on merging until someone else approves.

@maru-ava maru-ava removed the request for review from Elvis339 July 17, 2025 04:52
// execTestWithRecovery ensures assertion-related panics encountered during test execution are recovered
// and that deferred cleanups are always executed before returning.
func execTestWithRecovery(ctx context.Context, log logging.Logger, test Test, wallet *Wallet) {
tc := tests.NewTestContext(log)
Copy link
Contributor

@maru-ava maru-ava Jul 18, 2025

Choose a reason for hiding this comment

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

Creating a new TestContext here ensures that recovery executes only the cleanups registered to this context.

@@ -85,10 +85,7 @@ func (l LoadGenerator) Run(
default:
}

ctx, cancel := context.WithTimeout(ctx, testTimeout)
Copy link
Contributor

Choose a reason for hiding this comment

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

Moved to execTestWithRecovery to ensure that cancelation is localized to test execution rather than only being performed on goroutine exit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing This primarily focuses on testing tooling Build, test and development tooling
Projects
Status: In Progress 🏗️
Development

Successfully merging this pull request may close these issues.

4 participants