Skip to content
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

e2e: More fixture refinement in support of coreth integration testing #2275

Merged
merged 5 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions tests/e2e/ignore.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package e2e

// This file is required by ginkgo to accurately report compilation errors in test packages. Without
// it, the following error will mask the actual errors:
//
// ```
// Failed to compile e2e:
//
// github.com/ava-labs/avalanchego/tests/e2e: no non-test Go files in /path/to/avalanchego/tests/e2e
// ```
21 changes: 19 additions & 2 deletions tests/fixture/e2e/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ func AddEphemeralNode(network testnet.Network, flags testnet.FlagsMap) testnet.N

// Wait for the given node to report healthy.
func WaitForHealthy(node testnet.Node) {
require.NoError(ginkgo.GinkgoT(), testnet.WaitForHealthy(DefaultContext(), node))
// Need to use explicit context (vs DefaultContext()) to support use with DeferCleanup
ctx, cancel := context.WithTimeout(context.Background(), DefaultTimeout)
joshua-kim marked this conversation as resolved.
Show resolved Hide resolved
defer cancel()
require.NoError(ginkgo.GinkgoT(), testnet.WaitForHealthy(ctx, node))
joshua-kim marked this conversation as resolved.
Show resolved Hide resolved
}

// Sends an eth transaction, waits for the transaction receipt to be issued
Expand Down Expand Up @@ -195,12 +198,26 @@ func WithSuggestedGasPrice(ethClient ethclient.Client) common.Option {

// Verify that a new node can bootstrap into the network.
func CheckBootstrapIsPossible(network testnet.Network) {
require := require.New(ginkgo.GinkgoT())

if len(os.Getenv(SkipBootstrapChecksEnvName)) > 0 {
tests.Outf("{{yellow}}Skipping bootstrap check due to the %s env var being set", SkipBootstrapChecksEnvName)
return
}
ginkgo.By("checking if bootstrap is possible with the current network state")
node := AddEphemeralNode(network, testnet.FlagsMap{})

// Call network.AddEphemeralNode instead of AddEphemeralNode to support
// checking for bootstrap implicitly on teardown via a function registered
// with ginkgo.DeferCleanup. It's not possible to call DeferCleanup from
// within a function called by DeferCleanup.
node, err := network.AddEphemeralNode(ginkgo.GinkgoWriter, testnet.FlagsMap{})
require.NoError(err)

defer func() {
tests.Outf("Shutting down ephemeral node %s\n", node.GetID())
require.NoError(node.Stop())
}()

WaitForHealthy(node)
}

Expand Down
14 changes: 13 additions & 1 deletion tests/fixture/testnet/local/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,19 @@ func (ln *LocalNetwork) AddLocalNode(w io.Writer, node *LocalNode, isEphemeral b
if err := node.WriteConfig(); err != nil {
return nil, err
}
return node, node.Start(w, ln.ExecPath)

err = node.Start(w, ln.ExecPath)
if err != nil {
// Attempt to stop an unhealthy node to provide some assurance to the caller
// that an error condition will not result in a lingering process.
stopErr := node.Stop()
if stopErr != nil {
err = errors.Join(err, stopErr)
}
return nil, err
}

return node, nil
}

func (ln *LocalNetwork) GetBootstrapIPsAndIDs() ([]string, []string, error) {
Expand Down