Browse Source

test: add E2E test for node peering (#5465)

This was a missing test case from the old P2P tests removed in #5453, which makes sure that all nodes are able to peer with each other regardless of how they discover peers.

Fixes #2795, since the default CI testnet uses a combination of (partially meshed) persistent peers and PEX-based seed nodes.
pull/5471/head
Erik Grinaker 4 years ago
committed by GitHub
parent
commit
8d28e7467c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 54 additions and 8 deletions
  1. +3
    -4
      test/e2e/Makefile
  2. +7
    -2
      test/e2e/networks/ci.toml
  3. +2
    -2
      test/e2e/runner/main.go
  4. +42
    -0
      test/e2e/tests/net_test.go

+ 3
- 4
test/e2e/Makefile View File

@ -1,9 +1,8 @@
all: docker runner
docker:
docker build --tag tendermint/e2e-node -f docker/Dockerfile ../..
ci: runner
./build/runner -f networks/ci.toml
# We need to build support for database backends into the app in
# order to build a binary with a Tendermint node in it (for built-in
# ABCI testing).
@ -13,4 +12,4 @@ app:
runner:
go build -o build/runner ./runner
.PHONY: app ci docker runner
.PHONY: app docker runner

+ 7
- 2
test/e2e/networks/ci.toml View File

@ -26,6 +26,11 @@ validator05 = 50
[node.seed01]
mode = "seed"
persistent_peers = ["seed02"]
[node.seed02]
mode = "seed"
persistent_peers = ["seed01"]
[node.validator01]
seeds = ["seed01"]
@ -33,7 +38,7 @@ snapshot_interval = 5
perturb = ["disconnect"]
[node.validator02]
seeds = ["seed01"]
seeds = ["seed02"]
database = "boltdb"
abci_protocol = "tcp"
privval_protocol = "tcp"
@ -64,7 +69,7 @@ perturb = ["pause"]
[node.validator05]
start_at = 1005 # Becomes part of the validator set at 1010
seeds = ["seed01"]
seeds = ["seed02"]
database = "cleveldb"
fast_sync = "v0"
# FIXME Should use grpc, but it has race conditions


+ 2
- 2
test/e2e/runner/main.go View File

@ -68,7 +68,7 @@ func NewCLI() *CLI {
if err := Perturb(cli.testnet); err != nil {
return err
}
if err := Wait(cli.testnet, 5); err != nil { // wait for network to settle
if err := Wait(cli.testnet, 5); err != nil { // allow some txs to go through
return err
}
@ -76,7 +76,7 @@ func NewCLI() *CLI {
if err := <-chLoadResult; err != nil {
return err
}
if err := Wait(cli.testnet, 3); err != nil { // wait for last txs to commit
if err := Wait(cli.testnet, 10); err != nil { // wait for network to settle before tests
return err
}
if err := Test(cli.testnet); err != nil {


+ 42
- 0
test/e2e/tests/net_test.go View File

@ -0,0 +1,42 @@
package e2e_test
import (
"testing"
"github.com/stretchr/testify/require"
e2e "github.com/tendermint/tendermint/test/e2e/pkg"
)
// Tests that all nodes have peered with each other, regardless of discovery method.
func TestNet_Peers(t *testing.T) {
testNode(t, func(t *testing.T, node e2e.Node) {
// Seed nodes shouldn't necessarily mesh with the entire network.
if node.Mode == e2e.ModeSeed {
return
}
client, err := node.Client()
require.NoError(t, err)
netInfo, err := client.NetInfo(ctx)
require.NoError(t, err)
require.Equal(t, len(node.Testnet.Nodes)-1, netInfo.NPeers,
"node is not fully meshed with peers")
seen := map[string]bool{}
for _, n := range node.Testnet.Nodes {
seen[n.Name] = (n.Name == node.Name) // we've clearly seen ourself
}
for _, peerInfo := range netInfo.Peers {
peer := node.Testnet.LookupNode(peerInfo.NodeInfo.Moniker)
require.NotNil(t, peer, "unknown node %v", peerInfo.NodeInfo.Moniker)
require.Equal(t, peer.IP.String(), peerInfo.RemoteIP,
"unexpected IP address for peer %v", peer.Name)
seen[peerInfo.NodeInfo.Moniker] = true
}
for name := range seen {
require.True(t, seen[name], "node %v not peered with %v", node.Name, name)
}
})
}

Loading…
Cancel
Save