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

testing: improve e2e test bootstrapping #3690

Merged
merged 3 commits into from
Jan 31, 2025
Merged
Changes from 2 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
49 changes: 35 additions & 14 deletions tests/fixture/e2e/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

"github.com/ava-labs/avalanchego/api/info"
"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"
"github.com/ava-labs/avalanchego/utils/crypto/secp256k1"
Expand Down Expand Up @@ -144,23 +145,43 @@ func NewTestEnvironment(tc tests.TestContext, flagVars *FlagVars, desiredNetwork
flagVars.ReuseNetwork(),
)

// Wait for chains to have bootstrapped on all nodes
// create a slice of all the validators and chains pairs that we'll be waiting to be bootstrapped.
var pendingBootstappingChains []struct {
validatorID ids.NodeID
chainID ids.ID
}
for _, subnet := range network.Subnets {
for _, validatorID := range subnet.ValidatorIDs {
for _, chain := range subnet.Chains {
pendingBootstappingChains = append(pendingBootstappingChains, struct {
validatorID ids.NodeID
chainID ids.ID
}{validatorID: validatorID, chainID: chain.ChainID})
}
}
}
// Wait for chains to have bootstrapped on all validators
tc.Eventually(func() bool {
for _, subnet := range network.Subnets {
for _, validatorID := range subnet.ValidatorIDs {
uri, err := network.GetURIForNodeID(validatorID)
require.NoError(err)
infoClient := info.NewClient(uri)
for _, chain := range subnet.Chains {
isBootstrapped, err := infoClient.IsBootstrapped(tc.DefaultContext(), chain.ChainID.String())
// Ignore errors since a chain id that is not yet known will result in a recoverable error.
if err != nil || !isBootstrapped {
return false
}
}
allValidatorsBootstrapped := true
for i := len(pendingBootstappingChains) - 1; i >= 0; i-- {
pending := pendingBootstappingChains[i]
uri, err := network.GetURIForNodeID(pending.validatorID)
require.NoError(err)
infoClient := info.NewClient(uri)
isBootstrapped, err := infoClient.IsBootstrapped(tc.DefaultContext(), pending.chainID.String())
// Ignore errors since a chain id that is not yet known will result in a recoverable error.
if err != nil || !isBootstrapped {
allValidatorsBootstrapped = false
continue
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we perform an IsBootstrapped check here rather than checking if the node is healthy? If the node reports healthy, all bootstrapping checks should pass and this will include correctly checking that dynamic state sync has completed (which is handled as a bit of an outlier).

Copy link
Contributor Author

@tsachiherman tsachiherman Jan 31, 2025

Choose a reason for hiding this comment

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

by the time we reach this point, the health check was already complete against all the nodes. Some differences:

  • The health checking doesn't seem to be chain-specific, whereas the bootstrapping test is.
  • When doing the health checking, the port would get dynamically refreshed. That's won't happen during the bootstrapping testing.

}
tc.Log().Info("Validator successfully bootstrapped chain",
zap.String("nodeID", pending.validatorID.String()),
zap.String("chainID", pending.chainID.String()),
)
// remove the entry from the pending list so that we won't need to test this entry again.
pendingBootstappingChains = append(pendingBootstappingChains[:i], pendingBootstappingChains[i+1:]...)
}
return true
return allValidatorsBootstrapped
}, DefaultTimeout, DefaultPollingInterval, "failed to see all chains bootstrap before timeout")
}

Expand Down
Loading