p2p: extend e2e tests for new p2p framework (#6323)

This commit is contained in:
Sam Kleinman
2021-04-08 11:09:21 -04:00
committed by GitHub
parent 0b770870c9
commit 0f41f7465c
13 changed files with 118 additions and 64 deletions

View File

@@ -26,8 +26,6 @@ RUN cd test/e2e && make app && cp build/app /usr/bin/app
WORKDIR /tendermint
VOLUME /tendermint
ENV TMHOME=/tendermint
ENV TM_LEGACY_P2P=true
ENV TM_P2P_QUEUE="priority"
EXPOSE 26656 26657 26660 6060
ENTRYPOINT ["/usr/bin/entrypoint"]

View File

@@ -16,6 +16,8 @@ var (
testnetCombinations = map[string][]interface{}{
"topology": {"single", "quad", "large"},
"ipv6": {false, true},
"useNewP2P": {false, true, 2},
"queueType": {"priority"}, // "fifo", "wdrr"
"initialHeight": {0, 1000},
"initialState": {
map[string]string{},
@@ -69,6 +71,17 @@ func generateTestnet(r *rand.Rand, opt map[string]interface{}) (e2e.Manifest, er
Nodes: map[string]*e2e.ManifestNode{},
KeyType: opt["keyType"].(string),
Evidence: evidence.Choose(r).(int),
QueueType: opt["queueType"].(string),
}
var p2pNodeFactor int
switch p2pInfo := opt["useNewP2P"].(type) {
case bool:
manifest.UseNewP2P = p2pInfo
case int:
manifest.UseNewP2P = false
p2pNodeFactor = p2pInfo
}
var numSeeds, numValidators, numFulls, numLightClients int
@@ -89,8 +102,14 @@ func generateTestnet(r *rand.Rand, opt map[string]interface{}) (e2e.Manifest, er
// First we generate seed nodes, starting at the initial height.
for i := 1; i <= numSeeds; i++ {
manifest.Nodes[fmt.Sprintf("seed%02d", i)] = generateNode(
r, e2e.ModeSeed, 0, manifest.InitialHeight, false)
node := generateNode(r, e2e.ModeSeed, 0, manifest.InitialHeight, false)
node.QueueType = manifest.QueueType
if p2pNodeFactor == 0 {
node.UseNewP2P = manifest.UseNewP2P
} else if p2pNodeFactor%i == 0 {
node.UseNewP2P = !manifest.UseNewP2P
}
manifest.Nodes[fmt.Sprintf("seed%02d", i)] = node
}
// Next, we generate validators. We make sure a BFT quorum of validators start
@@ -105,9 +124,17 @@ func generateTestnet(r *rand.Rand, opt map[string]interface{}) (e2e.Manifest, er
nextStartAt += 5
}
name := fmt.Sprintf("validator%02d", i)
manifest.Nodes[name] = generateNode(
node := generateNode(
r, e2e.ModeValidator, startAt, manifest.InitialHeight, i <= 2)
node.QueueType = manifest.QueueType
if p2pNodeFactor == 0 {
node.UseNewP2P = manifest.UseNewP2P
} else if p2pNodeFactor%i == 0 {
node.UseNewP2P = !manifest.UseNewP2P
}
manifest.Nodes[name] = node
if startAt == 0 {
(*manifest.Validators)[name] = int64(30 + r.Intn(71))
} else {
@@ -134,8 +161,14 @@ func generateTestnet(r *rand.Rand, opt map[string]interface{}) (e2e.Manifest, er
startAt = nextStartAt
nextStartAt += 5
}
manifest.Nodes[fmt.Sprintf("full%02d", i)] = generateNode(
r, e2e.ModeFull, startAt, manifest.InitialHeight, false)
node := generateNode(r, e2e.ModeFull, startAt, manifest.InitialHeight, false)
node.QueueType = manifest.QueueType
if p2pNodeFactor == 0 {
node.UseNewP2P = manifest.UseNewP2P
} else if p2pNodeFactor%i == 0 {
node.UseNewP2P = !manifest.UseNewP2P
}
manifest.Nodes[fmt.Sprintf("full%02d", i)] = node
}
// We now set up peer discovery for nodes. Seed nodes are fully meshed with

View File

@@ -4,6 +4,8 @@
initial_height = 1000
evidence = 0
initial_state = { initial01 = "a", initial02 = "b", initial03 = "c" }
use_new_p2p = false
queue_type = "priority"
[validators]
validator01 = 100

View File

@@ -58,6 +58,13 @@ type Manifest struct {
// LogLevel sets the log level of the entire testnet. This can be overridden
// by individual nodes.
LogLevel string `toml:"log_level"`
// UseNewP2P enables use of the new p2p layer for all nodes in
// a test.
UseNewP2P bool `toml:"use_new_p2p"`
// QueueType describes the type of queue that the system uses internally
QueueType string `toml:"queue_type"`
}
// ManifestNode represents a node in a testnet manifest.
@@ -134,6 +141,13 @@ type ManifestNode struct {
// This is helpful when debugging a specific problem. This overrides the network
// level.
LogLevel string `toml:"log_level"`
// UseNewP2P enables use of the new p2p layer for this node.
UseNewP2P bool `toml:"use_new_p2p"`
// QueueType describes the type of queue that the p2p layer
// uses internally.
QueueType string `toml:"queue_type"`
}
// Save saves the testnet manifest to a file.

View File

@@ -90,6 +90,8 @@ type Node struct {
PersistentPeers []*Node
Perturbations []Perturbation
LogLevel string
UseNewP2P bool
QueueType string
}
// LoadTestnet loads a testnet from a manifest file, using the filename to
@@ -167,6 +169,8 @@ func LoadTestnet(file string) (*Testnet, error) {
RetainBlocks: nodeManifest.RetainBlocks,
Perturbations: []Perturbation{},
LogLevel: manifest.LogLevel,
UseNewP2P: manifest.UseNewP2P,
QueueType: manifest.QueueType,
}
if node.StartAt == testnet.InitialHeight {
node.StartAt = 0 // normalize to 0 for initial nodes, since code expects this

View File

@@ -239,6 +239,8 @@ func MakeConfig(node *e2e.Node) (*config.Config, error) {
cfg.RPC.PprofListenAddress = ":6060"
cfg.P2P.ExternalAddress = fmt.Sprintf("tcp://%v", node.AddressP2P(false))
cfg.P2P.AddrBookStrict = false
cfg.P2P.UseNewP2P = node.UseNewP2P
cfg.P2P.QueueType = node.QueueType
cfg.DBBackend = node.Database
cfg.StateSync.DiscoveryTime = 5 * time.Second
if node.Mode != e2e.ModeLight {