From ae0d06692eda5ca43ec0a9de0f8cde80e23391b1 Mon Sep 17 00:00:00 2001 From: hvanz Date: Fri, 10 Feb 2023 10:53:50 -0300 Subject: [PATCH 1/9] Add Prometheus and PrometheusListenAddr flags --- test/e2e/pkg/manifest.go | 7 ++++ test/e2e/pkg/testnet.go | 90 ++++++++++++++++++++-------------------- test/e2e/runner/setup.go | 9 ++++ 3 files changed, 62 insertions(+), 44 deletions(-) diff --git a/test/e2e/pkg/manifest.go b/test/e2e/pkg/manifest.go index cd44ccd5398..5b30785b3bc 100644 --- a/test/e2e/pkg/manifest.go +++ b/test/e2e/pkg/manifest.go @@ -162,6 +162,13 @@ type ManifestNode struct { // It defaults to false so unless the configured, the node will // receive load. SendNoLoad bool `toml:"send_no_load"` + + // When true, Prometheus metrics are served under /metrics on + // PrometheusListenAddr. Defaults to false. + Prometheus bool `toml:"prometheus"` + + // Address to listen for Prometheus collector(s) connections. + PrometheusListenAddr string `toml:"prometheus_listen_addr"` } // Save saves the testnet manifest to a file. diff --git a/test/e2e/pkg/testnet.go b/test/e2e/pkg/testnet.go index 884eb509715..4ae7fe323cb 100644 --- a/test/e2e/pkg/testnet.go +++ b/test/e2e/pkg/testnet.go @@ -83,30 +83,30 @@ type Testnet struct { // Node represents a CometBFT node in a testnet. type Node struct { - Name string - Version string - Testnet *Testnet - Mode Mode - PrivvalKey crypto.PrivKey - NodeKey crypto.PrivKey - IP net.IP - ProxyPort uint32 - StartAt int64 - BlockSync string - StateSync bool - Mempool string - Database string - ABCIProtocol Protocol - PrivvalProtocol Protocol - PersistInterval uint64 - SnapshotInterval uint64 - RetainBlocks uint64 - Seeds []*Node - PersistentPeers []*Node - Perturbations []Perturbation - - // SendNoLoad determines if the e2e test should send load to this node. - SendNoLoad bool + Name string + Version string + Testnet *Testnet + Mode Mode + PrivvalKey crypto.PrivKey + NodeKey crypto.PrivKey + IP net.IP + ProxyPort uint32 + StartAt int64 + BlockSync string + StateSync bool + Mempool string + Database string + ABCIProtocol Protocol + PrivvalProtocol Protocol + PersistInterval uint64 + SnapshotInterval uint64 + RetainBlocks uint64 + Seeds []*Node + PersistentPeers []*Node + Perturbations []Perturbation + SendNoLoad bool + Prometheus bool + PrometheusListenAddr string } // LoadTestnet loads a testnet from a manifest file, using the filename to @@ -183,26 +183,28 @@ func LoadTestnet(manifest Manifest, fname string, ifd InfrastructureData) (*Test v = localVersion } node := &Node{ - Name: name, - Version: v, - Testnet: testnet, - PrivvalKey: keyGen.Generate(manifest.KeyType), - NodeKey: keyGen.Generate("ed25519"), - IP: ind.IPAddress, - ProxyPort: proxyPortGen.Next(), - Mode: ModeValidator, - Database: "goleveldb", - ABCIProtocol: Protocol(testnet.ABCIProtocol), - PrivvalProtocol: ProtocolFile, - StartAt: nodeManifest.StartAt, - BlockSync: nodeManifest.BlockSync, - Mempool: nodeManifest.Mempool, - StateSync: nodeManifest.StateSync, - PersistInterval: 1, - SnapshotInterval: nodeManifest.SnapshotInterval, - RetainBlocks: nodeManifest.RetainBlocks, - Perturbations: []Perturbation{}, - SendNoLoad: nodeManifest.SendNoLoad, + Name: name, + Version: v, + Testnet: testnet, + PrivvalKey: keyGen.Generate(manifest.KeyType), + NodeKey: keyGen.Generate("ed25519"), + IP: ind.IPAddress, + ProxyPort: proxyPortGen.Next(), + Mode: ModeValidator, + Database: "goleveldb", + ABCIProtocol: Protocol(testnet.ABCIProtocol), + PrivvalProtocol: ProtocolFile, + StartAt: nodeManifest.StartAt, + BlockSync: nodeManifest.BlockSync, + Mempool: nodeManifest.Mempool, + StateSync: nodeManifest.StateSync, + PersistInterval: 1, + SnapshotInterval: nodeManifest.SnapshotInterval, + RetainBlocks: nodeManifest.RetainBlocks, + Perturbations: []Perturbation{}, + SendNoLoad: nodeManifest.SendNoLoad, + Prometheus: nodeManifest.Prometheus, + PrometheusListenAddr: nodeManifest.PrometheusListenAddr, } if node.StartAt == testnet.InitialHeight { node.StartAt = 0 // normalize to 0 for initial nodes, since code expects this diff --git a/test/e2e/runner/setup.go b/test/e2e/runner/setup.go index 619bd9323d9..e07c7693391 100644 --- a/test/e2e/runner/setup.go +++ b/test/e2e/runner/setup.go @@ -246,6 +246,15 @@ func MakeConfig(node *e2e.Node) (*config.Config, error) { } cfg.P2P.PersistentPeers += peer.AddressP2P(true) } + + if node.Prometheus { + cfg.Instrumentation.Prometheus = true + if node.PrometheusListenAddr != "" { + cfg.Instrumentation.PrometheusListenAddr = node.PrometheusListenAddr + + } + } + return cfg, nil } From cdc9e89833cd835454c96ee52eba0f2f2f5db26c Mon Sep 17 00:00:00 2001 From: hvanz Date: Fri, 10 Feb 2023 11:50:50 -0300 Subject: [PATCH 2/9] Add Prometheus flag at root level, for all nodes --- test/e2e/pkg/manifest.go | 5 +++++ test/e2e/pkg/testnet.go | 2 ++ test/e2e/runner/setup.go | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/test/e2e/pkg/manifest.go b/test/e2e/pkg/manifest.go index 5b30785b3bc..c9140b12b4f 100644 --- a/test/e2e/pkg/manifest.go +++ b/test/e2e/pkg/manifest.go @@ -82,6 +82,11 @@ type Manifest struct { LoadTxSizeBytes int `toml:"load_tx_size_bytes"` LoadTxBatchSize int `toml:"load_tx_batch_size"` LoadTxConnections int `toml:"load_tx_connections"` + + // When true, enables Prometheus metrics for all nodes. + // If needed, PrometheusListenAddr should be set in each individual node. + // Defaults to false. + Prometheus bool `toml:"prometheus"` } // ManifestNode represents a node in a testnet manifest. diff --git a/test/e2e/pkg/testnet.go b/test/e2e/pkg/testnet.go index 4ae7fe323cb..8f53873f129 100644 --- a/test/e2e/pkg/testnet.go +++ b/test/e2e/pkg/testnet.go @@ -79,6 +79,7 @@ type Testnet struct { ProcessProposalDelay time.Duration CheckTxDelay time.Duration UpgradeVersion string + Prometheus bool } // Node represents a CometBFT node in a testnet. @@ -142,6 +143,7 @@ func LoadTestnet(manifest Manifest, fname string, ifd InfrastructureData) (*Test ProcessProposalDelay: manifest.ProcessProposalDelay, CheckTxDelay: manifest.CheckTxDelay, UpgradeVersion: manifest.UpgradeVersion, + Prometheus: manifest.Prometheus, } if len(manifest.KeyType) != 0 { testnet.KeyType = manifest.KeyType diff --git a/test/e2e/runner/setup.go b/test/e2e/runner/setup.go index e07c7693391..2d172991939 100644 --- a/test/e2e/runner/setup.go +++ b/test/e2e/runner/setup.go @@ -73,6 +73,10 @@ func Setup(testnet *e2e.Testnet, infp infra.Provider) error { } } + if testnet.Prometheus { + node.Prometheus = true + } + cfg, err := MakeConfig(node) if err != nil { return err From 2b56b1df9b0b47fc5888d33d75a6de076337f453 Mon Sep 17 00:00:00 2001 From: hvanz Date: Fri, 10 Feb 2023 12:01:35 -0300 Subject: [PATCH 3/9] Add comment --- test/e2e/pkg/manifest.go | 1 + 1 file changed, 1 insertion(+) diff --git a/test/e2e/pkg/manifest.go b/test/e2e/pkg/manifest.go index c9140b12b4f..92df7288297 100644 --- a/test/e2e/pkg/manifest.go +++ b/test/e2e/pkg/manifest.go @@ -84,6 +84,7 @@ type Manifest struct { LoadTxConnections int `toml:"load_tx_connections"` // When true, enables Prometheus metrics for all nodes. + // When false, just apply the Prometheus flag of each individual node, if present. // If needed, PrometheusListenAddr should be set in each individual node. // Defaults to false. Prometheus bool `toml:"prometheus"` From fe5415d94558a1d7e81850015ce9937222e44fa6 Mon Sep 17 00:00:00 2001 From: hvanz Date: Fri, 10 Feb 2023 17:34:52 -0300 Subject: [PATCH 4/9] Add PrometheusProxyPort; remove PrometheusListenAddr --- test/e2e/pkg/infra/docker/docker.go | 2 + test/e2e/pkg/manifest.go | 6 +- test/e2e/pkg/testnet.go | 115 +++++++++++++++------------- test/e2e/runner/setup.go | 4 - test/e2e/runner/start.go | 3 + 5 files changed, 69 insertions(+), 61 deletions(-) diff --git a/test/e2e/pkg/infra/docker/docker.go b/test/e2e/pkg/infra/docker/docker.go index 4ade99698c6..c30b6c24b4b 100644 --- a/test/e2e/pkg/infra/docker/docker.go +++ b/test/e2e/pkg/infra/docker/docker.go @@ -65,6 +65,7 @@ services: ports: - 26656 - {{ if .ProxyPort }}{{ .ProxyPort }}:{{ end }}26657 + - {{ if .PrometheusProxyPort }}{{ .PrometheusProxyPort }}:{{ end }}26660 - 6060 volumes: - ./{{ .Name }}:/cometbft @@ -86,6 +87,7 @@ services: ports: - 26656 - {{ if .ProxyPort }}{{ .ProxyPort }}:{{ end }}26657 + - {{ if .PrometheusProxyPort }}{{ .PrometheusProxyPort }}:{{ end }}26660 - 6060 volumes: - ./{{ .Name }}:/cometbft diff --git a/test/e2e/pkg/manifest.go b/test/e2e/pkg/manifest.go index 92df7288297..b7d245e27fa 100644 --- a/test/e2e/pkg/manifest.go +++ b/test/e2e/pkg/manifest.go @@ -85,7 +85,6 @@ type Manifest struct { // When true, enables Prometheus metrics for all nodes. // When false, just apply the Prometheus flag of each individual node, if present. - // If needed, PrometheusListenAddr should be set in each individual node. // Defaults to false. Prometheus bool `toml:"prometheus"` } @@ -170,11 +169,8 @@ type ManifestNode struct { SendNoLoad bool `toml:"send_no_load"` // When true, Prometheus metrics are served under /metrics on - // PrometheusListenAddr. Defaults to false. + // PrometheusProxyPort. Defaults to false. Prometheus bool `toml:"prometheus"` - - // Address to listen for Prometheus collector(s) connections. - PrometheusListenAddr string `toml:"prometheus_listen_addr"` } // Save saves the testnet manifest to a file. diff --git a/test/e2e/pkg/testnet.go b/test/e2e/pkg/testnet.go index 8f53873f129..39a7bf0464b 100644 --- a/test/e2e/pkg/testnet.go +++ b/test/e2e/pkg/testnet.go @@ -19,8 +19,9 @@ import ( ) const ( - randomSeed int64 = 2308084734268 - proxyPortFirst uint32 = 5701 + randomSeed int64 = 2308084734268 + proxyPortFirst uint32 = 5701 + prometheusProxyPortFirst uint32 = 6701 defaultBatchSize = 2 defaultConnections = 1 @@ -84,30 +85,30 @@ type Testnet struct { // Node represents a CometBFT node in a testnet. type Node struct { - Name string - Version string - Testnet *Testnet - Mode Mode - PrivvalKey crypto.PrivKey - NodeKey crypto.PrivKey - IP net.IP - ProxyPort uint32 - StartAt int64 - BlockSync string - StateSync bool - Mempool string - Database string - ABCIProtocol Protocol - PrivvalProtocol Protocol - PersistInterval uint64 - SnapshotInterval uint64 - RetainBlocks uint64 - Seeds []*Node - PersistentPeers []*Node - Perturbations []Perturbation - SendNoLoad bool - Prometheus bool - PrometheusListenAddr string + Name string + Version string + Testnet *Testnet + Mode Mode + PrivvalKey crypto.PrivKey + NodeKey crypto.PrivKey + IP net.IP + ProxyPort uint32 + StartAt int64 + BlockSync string + StateSync bool + Mempool string + Database string + ABCIProtocol Protocol + PrivvalProtocol Protocol + PersistInterval uint64 + SnapshotInterval uint64 + RetainBlocks uint64 + Seeds []*Node + PersistentPeers []*Node + Perturbations []Perturbation + SendNoLoad bool + Prometheus bool + PrometheusProxyPort uint32 } // LoadTestnet loads a testnet from a manifest file, using the filename to @@ -119,6 +120,7 @@ func LoadTestnet(manifest Manifest, fname string, ifd InfrastructureData) (*Test dir := strings.TrimSuffix(fname, filepath.Ext(fname)) keyGen := newKeyGenerator(randomSeed) proxyPortGen := newPortGenerator(proxyPortFirst) + prometheusProxyPortGen := newPortGenerator(prometheusProxyPortFirst) _, ipNet, err := net.ParseCIDR(ifd.Network) if err != nil { return nil, fmt.Errorf("invalid IP network address %q: %w", ifd.Network, err) @@ -185,28 +187,28 @@ func LoadTestnet(manifest Manifest, fname string, ifd InfrastructureData) (*Test v = localVersion } node := &Node{ - Name: name, - Version: v, - Testnet: testnet, - PrivvalKey: keyGen.Generate(manifest.KeyType), - NodeKey: keyGen.Generate("ed25519"), - IP: ind.IPAddress, - ProxyPort: proxyPortGen.Next(), - Mode: ModeValidator, - Database: "goleveldb", - ABCIProtocol: Protocol(testnet.ABCIProtocol), - PrivvalProtocol: ProtocolFile, - StartAt: nodeManifest.StartAt, - BlockSync: nodeManifest.BlockSync, - Mempool: nodeManifest.Mempool, - StateSync: nodeManifest.StateSync, - PersistInterval: 1, - SnapshotInterval: nodeManifest.SnapshotInterval, - RetainBlocks: nodeManifest.RetainBlocks, - Perturbations: []Perturbation{}, - SendNoLoad: nodeManifest.SendNoLoad, - Prometheus: nodeManifest.Prometheus, - PrometheusListenAddr: nodeManifest.PrometheusListenAddr, + Name: name, + Version: v, + Testnet: testnet, + PrivvalKey: keyGen.Generate(manifest.KeyType), + NodeKey: keyGen.Generate("ed25519"), + IP: ind.IPAddress, + ProxyPort: proxyPortGen.Next(), + Mode: ModeValidator, + Database: "goleveldb", + ABCIProtocol: Protocol(testnet.ABCIProtocol), + PrivvalProtocol: ProtocolFile, + StartAt: nodeManifest.StartAt, + BlockSync: nodeManifest.BlockSync, + Mempool: nodeManifest.Mempool, + StateSync: nodeManifest.StateSync, + PersistInterval: 1, + SnapshotInterval: nodeManifest.SnapshotInterval, + RetainBlocks: nodeManifest.RetainBlocks, + Perturbations: []Perturbation{}, + SendNoLoad: nodeManifest.SendNoLoad, + Prometheus: nodeManifest.Prometheus, + PrometheusProxyPort: prometheusProxyPortGen.Next(), } if node.StartAt == testnet.InitialHeight { node.StartAt = 0 // normalize to 0 for initial nodes, since code expects this @@ -332,14 +334,23 @@ func (n Node) Validate(testnet Testnet) error { if !testnet.IP.Contains(n.IP) { return fmt.Errorf("node IP %v is not in testnet network %v", n.IP, testnet.IP) } - if n.ProxyPort > 0 { - if n.ProxyPort <= 1024 { - return fmt.Errorf("local port %v must be >1024", n.ProxyPort) - } + if n.ProxyPort == n.PrometheusProxyPort { + return fmt.Errorf("node local port %v used also for Prometheus local port", n.ProxyPort) + } + if n.ProxyPort > 0 && n.ProxyPort <= 1024 { + return fmt.Errorf("local port %v must be >1024", n.ProxyPort) + } + if n.PrometheusProxyPort > 0 && n.PrometheusProxyPort <= 1024 { + return fmt.Errorf("local port %v must be >1024", n.PrometheusProxyPort) + } + if n.ProxyPort > 0 || n.PrometheusProxyPort > 0 { for _, peer := range testnet.Nodes { if peer.Name != n.Name && peer.ProxyPort == n.ProxyPort { return fmt.Errorf("peer %q also has local port %v", peer.Name, n.ProxyPort) } + if peer.Name != n.Name && peer.PrometheusProxyPort == n.PrometheusProxyPort { + return fmt.Errorf("peer %q also has local port %v", peer.Name, n.PrometheusProxyPort) + } } } switch n.BlockSync { diff --git a/test/e2e/runner/setup.go b/test/e2e/runner/setup.go index 2d172991939..5d4b48b238d 100644 --- a/test/e2e/runner/setup.go +++ b/test/e2e/runner/setup.go @@ -253,10 +253,6 @@ func MakeConfig(node *e2e.Node) (*config.Config, error) { if node.Prometheus { cfg.Instrumentation.Prometheus = true - if node.PrometheusListenAddr != "" { - cfg.Instrumentation.PrometheusListenAddr = node.PrometheusListenAddr - - } } return cfg, nil diff --git a/test/e2e/runner/start.go b/test/e2e/runner/start.go index fa483b78b3f..c09d94e7cf8 100644 --- a/test/e2e/runner/start.go +++ b/test/e2e/runner/start.go @@ -50,6 +50,9 @@ func Start(testnet *e2e.Testnet) error { return err } logger.Info("start", "msg", log.NewLazySprintf("Node %v up on http://127.0.0.1:%v", node.Name, node.ProxyPort)) + if node.PrometheusProxyPort > 0 { + logger.Info("start", "msg", log.NewLazySprintf("Node %v: Prometheus up on http://127.0.0.1:%v", node.Name, node.PrometheusProxyPort)) + } } networkHeight := testnet.InitialHeight From 583a6264438df0287d4cb4ebd0cc354f9b437453 Mon Sep 17 00:00:00 2001 From: hvanz Date: Tue, 21 Feb 2023 11:13:13 +0100 Subject: [PATCH 5/9] Update startup log message --- test/e2e/runner/start.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/e2e/runner/start.go b/test/e2e/runner/start.go index c09d94e7cf8..06d76ad60c2 100644 --- a/test/e2e/runner/start.go +++ b/test/e2e/runner/start.go @@ -49,9 +49,10 @@ func Start(testnet *e2e.Testnet) error { if _, err := waitForNode(node, 0, 15*time.Second); err != nil { return err } - logger.Info("start", "msg", log.NewLazySprintf("Node %v up on http://127.0.0.1:%v", node.Name, node.ProxyPort)) if node.PrometheusProxyPort > 0 { - logger.Info("start", "msg", log.NewLazySprintf("Node %v: Prometheus up on http://127.0.0.1:%v", node.Name, node.PrometheusProxyPort)) + logger.Info("start", "msg", log.NewLazySprintf("Node %v up on http://127.0.0.1:%v; with Prometheus on http://127.0.0.1:%v", node.Name, node.ProxyPort, node.PrometheusProxyPort)) + } else { + logger.Info("start", "msg", log.NewLazySprintf("Node %v up on http://127.0.0.1:%v", node.Name, node.ProxyPort)) } } From 4366d3013d5989d10f70cb2cc905365d651458e1 Mon Sep 17 00:00:00 2001 From: hvanz Date: Tue, 21 Feb 2023 12:20:51 +0100 Subject: [PATCH 6/9] Update startup log message --- test/e2e/runner/start.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/runner/start.go b/test/e2e/runner/start.go index 06d76ad60c2..9b0849b4a8a 100644 --- a/test/e2e/runner/start.go +++ b/test/e2e/runner/start.go @@ -50,7 +50,7 @@ func Start(testnet *e2e.Testnet) error { return err } if node.PrometheusProxyPort > 0 { - logger.Info("start", "msg", log.NewLazySprintf("Node %v up on http://127.0.0.1:%v; with Prometheus on http://127.0.0.1:%v", node.Name, node.ProxyPort, node.PrometheusProxyPort)) + logger.Info("start", "msg", log.NewLazySprintf("Node %v up on http://127.0.0.1:%v; with Prometheus on http://127.0.0.1:%v/metrics", node.Name, node.ProxyPort, node.PrometheusProxyPort)) } else { logger.Info("start", "msg", log.NewLazySprintf("Node %v up on http://127.0.0.1:%v", node.Name, node.ProxyPort)) } From 84c713b74030674759198f8acbd539b058cbabab Mon Sep 17 00:00:00 2001 From: hvanz Date: Thu, 23 Feb 2023 16:44:48 +0100 Subject: [PATCH 7/9] Don't print the whole line in docker template --- test/e2e/pkg/infra/docker/docker.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/e2e/pkg/infra/docker/docker.go b/test/e2e/pkg/infra/docker/docker.go index c30b6c24b4b..aa11795d8bb 100644 --- a/test/e2e/pkg/infra/docker/docker.go +++ b/test/e2e/pkg/infra/docker/docker.go @@ -65,7 +65,9 @@ services: ports: - 26656 - {{ if .ProxyPort }}{{ .ProxyPort }}:{{ end }}26657 - - {{ if .PrometheusProxyPort }}{{ .PrometheusProxyPort }}:{{ end }}26660 +{{- if .PrometheusProxyPort }} + - {{ .PrometheusProxyPort }}:26660 +{{- end }} - 6060 volumes: - ./{{ .Name }}:/cometbft @@ -87,7 +89,9 @@ services: ports: - 26656 - {{ if .ProxyPort }}{{ .ProxyPort }}:{{ end }}26657 - - {{ if .PrometheusProxyPort }}{{ .PrometheusProxyPort }}:{{ end }}26660 +{{- if .PrometheusProxyPort }} + - {{ .PrometheusProxyPort }}:26660 +{{- end }} - 6060 volumes: - ./{{ .Name }}:/cometbft From 9c819400d0acbf701a51eaa8d259e18491c2f39d Mon Sep 17 00:00:00 2001 From: hvanz Date: Fri, 24 Feb 2023 12:57:43 +0100 Subject: [PATCH 8/9] Remove flag from ManifestNode --- test/e2e/pkg/manifest.go | 9 ++------- test/e2e/pkg/testnet.go | 2 +- test/e2e/runner/setup.go | 4 ---- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/test/e2e/pkg/manifest.go b/test/e2e/pkg/manifest.go index b7d245e27fa..74fe56216ea 100644 --- a/test/e2e/pkg/manifest.go +++ b/test/e2e/pkg/manifest.go @@ -83,9 +83,8 @@ type Manifest struct { LoadTxBatchSize int `toml:"load_tx_batch_size"` LoadTxConnections int `toml:"load_tx_connections"` - // When true, enables Prometheus metrics for all nodes. - // When false, just apply the Prometheus flag of each individual node, if present. - // Defaults to false. + // Enable or disable Prometheus metrics on all nodes. + // Defaults to false (disabled). Prometheus bool `toml:"prometheus"` } @@ -167,10 +166,6 @@ type ManifestNode struct { // It defaults to false so unless the configured, the node will // receive load. SendNoLoad bool `toml:"send_no_load"` - - // When true, Prometheus metrics are served under /metrics on - // PrometheusProxyPort. Defaults to false. - Prometheus bool `toml:"prometheus"` } // Save saves the testnet manifest to a file. diff --git a/test/e2e/pkg/testnet.go b/test/e2e/pkg/testnet.go index 39a7bf0464b..0a996fcb9b6 100644 --- a/test/e2e/pkg/testnet.go +++ b/test/e2e/pkg/testnet.go @@ -207,7 +207,7 @@ func LoadTestnet(manifest Manifest, fname string, ifd InfrastructureData) (*Test RetainBlocks: nodeManifest.RetainBlocks, Perturbations: []Perturbation{}, SendNoLoad: nodeManifest.SendNoLoad, - Prometheus: nodeManifest.Prometheus, + Prometheus: testnet.Prometheus, PrometheusProxyPort: prometheusProxyPortGen.Next(), } if node.StartAt == testnet.InitialHeight { diff --git a/test/e2e/runner/setup.go b/test/e2e/runner/setup.go index 5d4b48b238d..f1ee096650a 100644 --- a/test/e2e/runner/setup.go +++ b/test/e2e/runner/setup.go @@ -73,10 +73,6 @@ func Setup(testnet *e2e.Testnet, infp infra.Provider) error { } } - if testnet.Prometheus { - node.Prometheus = true - } - cfg, err := MakeConfig(node) if err != nil { return err From 38f18afcd7b2f16c2de3b565b4b0ebc0a151d616 Mon Sep 17 00:00:00 2001 From: hvanz Date: Fri, 24 Feb 2023 13:29:08 +0100 Subject: [PATCH 9/9] Do not generate PrometheusProxyPort if config is disabled --- test/e2e/pkg/testnet.go | 56 +++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/test/e2e/pkg/testnet.go b/test/e2e/pkg/testnet.go index 0a996fcb9b6..18f7aae0c72 100644 --- a/test/e2e/pkg/testnet.go +++ b/test/e2e/pkg/testnet.go @@ -187,28 +187,27 @@ func LoadTestnet(manifest Manifest, fname string, ifd InfrastructureData) (*Test v = localVersion } node := &Node{ - Name: name, - Version: v, - Testnet: testnet, - PrivvalKey: keyGen.Generate(manifest.KeyType), - NodeKey: keyGen.Generate("ed25519"), - IP: ind.IPAddress, - ProxyPort: proxyPortGen.Next(), - Mode: ModeValidator, - Database: "goleveldb", - ABCIProtocol: Protocol(testnet.ABCIProtocol), - PrivvalProtocol: ProtocolFile, - StartAt: nodeManifest.StartAt, - BlockSync: nodeManifest.BlockSync, - Mempool: nodeManifest.Mempool, - StateSync: nodeManifest.StateSync, - PersistInterval: 1, - SnapshotInterval: nodeManifest.SnapshotInterval, - RetainBlocks: nodeManifest.RetainBlocks, - Perturbations: []Perturbation{}, - SendNoLoad: nodeManifest.SendNoLoad, - Prometheus: testnet.Prometheus, - PrometheusProxyPort: prometheusProxyPortGen.Next(), + Name: name, + Version: v, + Testnet: testnet, + PrivvalKey: keyGen.Generate(manifest.KeyType), + NodeKey: keyGen.Generate("ed25519"), + IP: ind.IPAddress, + ProxyPort: proxyPortGen.Next(), + Mode: ModeValidator, + Database: "goleveldb", + ABCIProtocol: Protocol(testnet.ABCIProtocol), + PrivvalProtocol: ProtocolFile, + StartAt: nodeManifest.StartAt, + BlockSync: nodeManifest.BlockSync, + Mempool: nodeManifest.Mempool, + StateSync: nodeManifest.StateSync, + PersistInterval: 1, + SnapshotInterval: nodeManifest.SnapshotInterval, + RetainBlocks: nodeManifest.RetainBlocks, + Perturbations: []Perturbation{}, + SendNoLoad: nodeManifest.SendNoLoad, + Prometheus: testnet.Prometheus, } if node.StartAt == testnet.InitialHeight { node.StartAt = 0 // normalize to 0 for initial nodes, since code expects this @@ -228,6 +227,9 @@ func LoadTestnet(manifest Manifest, fname string, ifd InfrastructureData) (*Test if nodeManifest.PersistInterval != nil { node.PersistInterval = *nodeManifest.PersistInterval } + if node.Prometheus { + node.PrometheusProxyPort = prometheusProxyPortGen.Next() + } for _, p := range nodeManifest.Perturb { node.Perturbations = append(node.Perturbations, Perturbation(p)) } @@ -343,11 +345,11 @@ func (n Node) Validate(testnet Testnet) error { if n.PrometheusProxyPort > 0 && n.PrometheusProxyPort <= 1024 { return fmt.Errorf("local port %v must be >1024", n.PrometheusProxyPort) } - if n.ProxyPort > 0 || n.PrometheusProxyPort > 0 { - for _, peer := range testnet.Nodes { - if peer.Name != n.Name && peer.ProxyPort == n.ProxyPort { - return fmt.Errorf("peer %q also has local port %v", peer.Name, n.ProxyPort) - } + for _, peer := range testnet.Nodes { + if peer.Name != n.Name && peer.ProxyPort == n.ProxyPort { + return fmt.Errorf("peer %q also has local port %v", peer.Name, n.ProxyPort) + } + if n.PrometheusProxyPort > 0 { if peer.Name != n.Name && peer.PrometheusProxyPort == n.PrometheusProxyPort { return fmt.Errorf("peer %q also has local port %v", peer.Name, n.PrometheusProxyPort) }