Skip to content

Commit

Permalink
e2e: More fixture refinement in support of coreth integration testing (
Browse files Browse the repository at this point in the history
  • Loading branch information
marun authored Nov 14, 2023
1 parent 72d2fae commit 29f86e9
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
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)
defer cancel()
require.NoError(ginkgo.GinkgoT(), testnet.WaitForHealthy(ctx, node))
}

// 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

0 comments on commit 29f86e9

Please sign in to comment.