Skip to content
New issue

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

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

Already on GitHub? # to your account

[e2e] Enhance post-test bootstrap checks #3253

Merged
merged 3 commits into from
Aug 2, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/e2e/c/dynamic_fees.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,6 @@ var _ = e2e.DescribeCChain("[Dynamic Fees]", func() {
_ = e2e.SendEthTransaction(ethClient, signedTx)
})

e2e.CheckBootstrapIsPossible(privateNetwork)
_ = e2e.CheckBootstrapIsPossible(privateNetwork)
})
})
2 changes: 1 addition & 1 deletion tests/e2e/c/interchain_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,6 @@ var _ = e2e.DescribeCChain("[Interchain Workflow]", func() {
require.Positive(balances[avaxAssetID])
})

e2e.CheckBootstrapIsPossible(e2e.Env.GetNetwork())
_ = e2e.CheckBootstrapIsPossible(e2e.Env.GetNetwork())
})
})
2 changes: 1 addition & 1 deletion tests/e2e/p/interchain_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,6 @@ var _ = e2e.DescribePChain("[Interchain Workflow]", ginkgo.Label(e2e.UsesCChainL
ginkgo.By("stopping validator node to free up resources for a bootstrap check")
require.NoError(node.Stop(e2e.DefaultContext()))

e2e.CheckBootstrapIsPossible(network)
_ = e2e.CheckBootstrapIsPossible(network)
})
})
2 changes: 1 addition & 1 deletion tests/e2e/p/staking_rewards.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,6 @@ var _ = ginkgo.Describe("[Staking Rewards]", func() {
ginkgo.By("stopping alpha to free up resources for a bootstrap check")
require.NoError(alphaNode.Stop(e2e.DefaultContext()))

e2e.CheckBootstrapIsPossible(network)
_ = e2e.CheckBootstrapIsPossible(network)
})
})
2 changes: 1 addition & 1 deletion tests/e2e/p/validator_sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,6 @@ var _ = e2e.DescribePChain("[Validator Sets]", func() {
}
})

e2e.CheckBootstrapIsPossible(network)
_ = e2e.CheckBootstrapIsPossible(network)
})
})
2 changes: 2 additions & 0 deletions tests/e2e/vms/xsvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ var _ = ginkgo.Describe("[XSVM]", func() {
destinationBalance, err := destinationClient.Balance(e2e.DefaultContext(), destinationKey.Address(), sourceChain.ChainID)
require.NoError(err)
require.Equal(units.Schmeckle, destinationBalance)

_ = e2e.CheckBootstrapIsPossible(network)
})
})

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/x/interchain_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,6 @@ var _ = e2e.DescribeXChain("[Interchain Workflow]", ginkgo.Label(e2e.UsesCChainL
require.Positive(balances[avaxAssetID])
})

e2e.CheckBootstrapIsPossible(e2e.Env.GetNetwork())
_ = e2e.CheckBootstrapIsPossible(e2e.Env.GetNetwork())
})
})
34 changes: 21 additions & 13 deletions tests/fixture/e2e/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/ava-labs/coreth/interfaces"
"github.com/stretchr/testify/require"

"github.com/ava-labs/avalanchego/config"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/tests"
"github.com/ava-labs/avalanchego/tests/fixture/tmpnet"
Expand Down Expand Up @@ -185,34 +186,41 @@ func WithSuggestedGasPrice(ethClient ethclient.Client) common.Option {
return common.WithBaseFee(baseFee)
}

// Verify that a new node can bootstrap into the network. This function is safe to call
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This avoidance of ginkgo.DeferCleanup was in service of a PR that has since been closed, so it is no longer relevant.

// from `Teardown` by virtue of not depending on ginkgo.DeferCleanup.
func CheckBootstrapIsPossible(network *tmpnet.Network) {
// Verify that a new node can bootstrap into the network. If the check wasn't skipped,
// the node will be returned to the caller.
func CheckBootstrapIsPossible(network *tmpnet.Network) *tmpnet.Node {
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
return nil
}
ginkgo.By("checking if bootstrap is possible with the current network state")

ctx, cancel := context.WithTimeout(context.Background(), DefaultTimeout)
defer cancel()
// Ensure all subnets are bootstrapped
subnetIDs := make([]string, len(network.Subnets))
for i, subnet := range network.Subnets {
subnetIDs[i] = subnet.SubnetID.String()
}
flags := tmpnet.FlagsMap{
config.TrackSubnetsKey: strings.Join(subnetIDs, ","),
}

node := tmpnet.NewEphemeralNode(tmpnet.FlagsMap{})
require.NoError(network.StartNode(ctx, ginkgo.GinkgoWriter, node))
node := tmpnet.NewEphemeralNode(flags)
require.NoError(network.StartNode(DefaultContext(), ginkgo.GinkgoWriter, node))
// StartNode will initiate node stop if an error is encountered during start,
// so no further cleanup effort is required if an error is seen here.

// Ensure the node is always stopped at the end of the check
defer func() {
ctx, cancel = context.WithTimeout(context.Background(), DefaultTimeout)
// Register a cleanup to ensure the node is stopped at the end of the test
ginkgo.DeferCleanup(func() {
ctx, cancel := context.WithTimeout(context.Background(), DefaultTimeout)
defer cancel()
require.NoError(node.Stop(ctx))
}()
})

// Check that the node becomes healthy within timeout
require.NoError(tmpnet.WaitForHealthy(ctx, node))
require.NoError(tmpnet.WaitForHealthy(DefaultContext(), node))
return node
}

// Start a temporary network with the provided avalanchego binary.
Expand Down
2 changes: 1 addition & 1 deletion tests/upgrade/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ var _ = ginkgo.Describe("[Upgrade]", func() {
e2e.WaitForHealthy(node)
}

e2e.CheckBootstrapIsPossible(network)
_ = e2e.CheckBootstrapIsPossible(network)
})
})
Loading