rename IP node field

This commit is contained in:
William Banfield
2022-12-05 11:25:01 -05:00
parent 4dd0ff5621
commit ac539b1f3d
5 changed files with 21 additions and 17 deletions
@@ -34,11 +34,11 @@ func (p Provider) CreateNode(ctx context.Context, n *e2e.Node) error {
return nil
}
func (p Provider) StartTendermint(ctx context.Context, n *e2e.Node) error {
return e2essh.Exec(p.SSHConfig, fmt.Sprintf("%s:%d", n.IP, sshPort), fmt.Sprintf("systemctl start %s", testappName))
return e2essh.Exec(p.SSHConfig, fmt.Sprintf("%s:%d", n.InternalIP, sshPort), fmt.Sprintf("systemctl start %s", testappName))
}
func (p Provider) TerminateTendermint(ctx context.Context, n *e2e.Node) error {
return e2essh.Exec(p.SSHConfig, fmt.Sprintf("%s:%d", n.IP, sshPort), fmt.Sprintf("systemctl -s SIGTERM %s", testappName))
return e2essh.Exec(p.SSHConfig, fmt.Sprintf("%s:%d", n.InternalIP, sshPort), fmt.Sprintf("systemctl -s SIGTERM %s", testappName))
}
func (p Provider) KillTendermint(ctx context.Context, n *e2e.Node) error {
return e2essh.Exec(p.SSHConfig, fmt.Sprintf("%s:%d", n.IP, sshPort), fmt.Sprintf("systemctl -s SIGKILL %s", testappName))
return e2essh.Exec(p.SSHConfig, fmt.Sprintf("%s:%d", n.InternalIP, sshPort), fmt.Sprintf("systemctl -s SIGKILL %s", testappName))
}
+4
View File
@@ -7,6 +7,7 @@ import (
"net"
"os"
"path/filepath"
"time"
"golang.org/x/crypto/ssh"
"golang.org/x/crypto/ssh/agent"
@@ -14,10 +15,13 @@ import (
)
func Exec(cfg *ssh.ClientConfig, addr, cmd string) error {
start := time.Now()
c, err := ssh.Dial("tcp", addr, cfg)
if err != nil {
return err
}
after := time.Since(start)
fmt.Printf("Time: %s\n", after)
defer c.Close()
s, err := c.NewSession()
if err != nil {
+11 -11
View File
@@ -84,7 +84,7 @@ type Node struct {
SyncApp bool // Should we use a synchronized app with an unsynchronized local client?
PrivvalKey crypto.PrivKey
NodeKey crypto.PrivKey
IP net.IP
InternalIP net.IP
ProxyPort uint32
StartAt int64
BlockSync string
@@ -173,7 +173,7 @@ func LoadTestnet(manifest Manifest, fname string, ifd InfrastructureData) (*Test
Testnet: testnet,
PrivvalKey: keyGen.Generate(manifest.KeyType),
NodeKey: keyGen.Generate("ed25519"),
IP: ind.IPAddress,
InternalIP: ind.IPAddress,
ProxyPort: ind.Port,
Mode: ModeValidator,
SyncApp: nodeManifest.SyncApp,
@@ -308,18 +308,18 @@ func (n Node) Validate(testnet Testnet) error {
if n.Name == "" {
return errors.New("node has no name")
}
if n.IP == nil {
if n.InternalIP == nil {
return errors.New("node has no IP address")
}
if !testnet.IP.Contains(n.IP) {
return fmt.Errorf("node IP %v is not in testnet network %v", n.IP, testnet.IP)
if !testnet.IP.Contains(n.InternalIP) {
return fmt.Errorf("node IP %v is not in testnet network %v", n.InternalIP, testnet.IP)
}
if n.ProxyPort > 0 {
if n.ProxyPort <= 1024 {
return fmt.Errorf("local port %v must be >1024", n.ProxyPort)
}
for _, peer := range testnet.Nodes {
if peer.Name != n.Name && peer.ProxyPort == n.ProxyPort && peer.IP.Equal(n.IP) {
if peer.Name != n.Name && peer.ProxyPort == n.ProxyPort && peer.InternalIP.Equal(n.InternalIP) {
return fmt.Errorf("peer %q also has local port %v", peer.Name, n.ProxyPort)
}
}
@@ -435,8 +435,8 @@ func (t Testnet) HasPerturbations() bool {
// Address returns a P2P endpoint address for the node.
func (n Node) AddressP2P(withID bool) string {
ip := n.IP.String()
if n.IP.To4() == nil {
ip := n.InternalIP.String()
if n.InternalIP.To4() == nil {
// IPv6 addresses must be wrapped in [] to avoid conflict with : port separator
ip = fmt.Sprintf("[%v]", ip)
}
@@ -449,8 +449,8 @@ func (n Node) AddressP2P(withID bool) string {
// Address returns an RPC endpoint address for the node.
func (n Node) AddressRPC() string {
ip := n.IP.String()
if n.IP.To4() == nil {
ip := n.InternalIP.String()
if n.InternalIP.To4() == nil {
// IPv6 addresses must be wrapped in [] to avoid conflict with : port separator
ip = fmt.Sprintf("[%v]", ip)
}
@@ -459,7 +459,7 @@ func (n Node) AddressRPC() string {
// Client returns an RPC client for a node.
func (n Node) Client() (*rpchttp.HTTP, error) {
return rpchttp.New(fmt.Sprintf("http://%s:%v", n.IP, n.ProxyPort), "/websocket")
return rpchttp.New(fmt.Sprintf("http://%s:%v", n.InternalIP, n.ProxyPort), "/websocket")
}
// Stateless returns true if the node is either a seed node or a light node
+2 -2
View File
@@ -56,7 +56,7 @@ func Start(testnet *e2e.Testnet, p infra.Provider) error {
if _, err := waitForNode(node, 0, 15*time.Second); err != nil {
return err
}
logger.Info("start", "msg", log.NewLazySprintf("Node %v up on http://%s:%v", node.Name, node.IP, node.ProxyPort))
logger.Info("start", "msg", log.NewLazySprintf("Node %v up on http://%s:%v", node.Name, node.InternalIP, node.ProxyPort))
}
networkHeight := testnet.InitialHeight
@@ -117,7 +117,7 @@ func Start(testnet *e2e.Testnet, p infra.Provider) error {
return err
}
logger.Info("start", "msg", log.NewLazySprintf("Node %v up on http://%s:%v at height %v",
node.Name, node.IP, node.ProxyPort, status.SyncInfo.LatestBlockHeight))
node.Name, node.InternalIP, node.ProxyPort, status.SyncInfo.LatestBlockHeight))
}
return nil
+1 -1
View File
@@ -34,7 +34,7 @@ func TestNet_Peers(t *testing.T) {
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,
require.Equal(t, peer.InternalIP.String(), peerInfo.RemoteIP,
"unexpected IP address for peer %v", peer.Name)
seen[peerInfo.NodeInfo.Moniker] = true
}