10000 feat(e2e): `config` flag for arbitrary CometBFT configurations by cason · Pull Request #3967 · cometbft/cometbft · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(e2e): config flag for arbitrary CometBFT configurations #3967

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

Merged
merged 26 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4991c80
e2e: rename Manifest fields colliding with Testnet
cason Sep 2, 2024
92f9ec1
e2e: Tesnet includes and extends Manifest
cason Sep 2, 2024
0a596f2
e2e: Node includes and extends ManifestNode
cason Sep 2, 2024
778fbc6
e2e: fix Database Node setting
cason Sep 2, 2024
de9cc68
e2e: manifest `config` flag, global and per node
cason Sep 2, 2024
af7cb2a
e2e: Testnet.Config included in Node.Config
cason Sep 2, 2024
67ce59d
e2e: runner setup apply Config entries
cason Sep 2, 2024
912d029
e2e: validate 'config' entries, must be "key = value"
cason Sep 2, 2024
d1ae2d3
e2e: pleasing the linter
cason Sep 2, 2024
7cbc116
Apply suggestions from code review
cason Sep 2, 2024
2072bad
Merge branch 'main' into cason/e2e-refactor
mergify[bot] Sep 2, 2024
cec8bd1
Merge branch 'cason/e2e-refactor' into cason/3832-e2e-comet-config
mergify[bot] Sep 2, 2024
e0bf483
e2e: only runs viper if there are keys to set
cason Sep 2, 2024
6e8de84
Merge branch 'main' into cason/e2e-refactor
mergify[bot] Sep 3, 2024
bcce981
Merge branch 'cason/e2e-refactor' into cason/3832-e2e-comet-config
mergify[bot] Sep 3, 2024
71b18ae
Merge branch 'main' into cason/e2e-refactor
mergify[bot] Sep 3, 2024
42ce5f1
Merge branch 'cason/e2e-refactor' into cason/3832-e2e-comet-config
mergify[bot] Sep 3, 2024
a476a03
Merge branch 'main' into cason/e2e-refactor
mergify[bot] Sep 3, 2024
c53c554
Merge branch 'cason/e2e-refactor' into cason/3832-e2e-comet-config
mergify[bot] Sep 3, 2024
c0da912
Merge branch 'main' into cason/e2e-refactor
andynog Sep 3, 2024
caff8a2
Merge branch 'cason/e2e-refactor' into cason/3832-e2e-comet-config
mergify[bot] Sep 3, 2024
eb40ed4
Merge branch 'main' into cason/e2e-refactor
mergify[bot] Sep 4, 2024
54169a0
Merge branch 'cason/e2e-refactor' into cason/3832-e2e-comet-config
mergify[bot] Sep 4, 2024
49dbc0d
Merge branch 'main' into cason/e2e-refactor
mergify[bot] Sep 4, 2024
6b4b2de
Merge branch 'cason/e2e-refactor' into cason/3832-e2e-comet-config
mergify[bot] Sep 4, 2024
ab239c7
Merge branch 'main' into cason/3832-e2e-comet-config
mergify[bot] Sep 4, 2024
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
10 changes: 10 additions & 0 deletions test/e2e/pkg/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ type Manifest struct {
// -1 denotes it is set at genesis.
// 0 denotes it is set at InitChain.
PbtsUpdateHeight int64 `toml:"pbts_update_height"`

// Config is a set of key-value config entries to write to CometBFT's
// configuration files for all nodes. The format is "key = value".
// Example: "p2p.send_rate = 512000".
Config []string `toml:"config"`
}

// ManifestNode represents a node in a testnet manifest.
Expand Down Expand Up @@ -242,6 +247,11 @@ type ManifestNode struct {

// Simulated clock skew for this node
ClockSkew time.Duration `toml:"clock_skew"`

// Config is a set of key-value config entries to write to CometBFT's
// configuration files for this node. The format is "key = value".
// Example: "p2p.send_rate = 512000".
Config []string `toml:"config"`
}

// Save saves the testnet manifest to a file.
Expand Down
20 changes: 19 additions & 1 deletion test/e2e/pkg/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ func NewTestnetFromManifest(manifest Manifest, file string, ifd InfrastructureDa
} else if testnet.DefaultZone != "" {
node.Zone = ZoneID(testnet.DefaultZone)
}
// Configs are applied in order, so a local Config in Node
// should override a global config in Testnet.
if len(manifest.Config) > 0 {
node.Config = append(testnet.Config, node.Config...)
}

testnet.Nodes = append(testnet.Nodes, node)
}
Expand Down Expand Up @@ -394,6 +399,13 @@ func (t Testnet) Validate() error {
return fmt.Errorf("invalid node %q: %w", node.Name, err)
}
}
for _, entry := range t.Config {
tokens := strings.Split(entry, " = ")
if len(tokens) != 2 {
return fmt.Errorf("invalid config entry: \"%s\", "+
"expected \"key = value\"", entry)
}
}
return nil
}

Expand Down Expand Up @@ -521,7 +533,13 @@ func (n Node) Validate(testnet Testnet) error {
return fmt.Errorf("invalid perturbation %q", perturbation)
}
}

for _, entry := range n.Config {
tokens := strings.Split(entry, " = ")
if len(tokens) != 2 {
return fmt.Errorf("invalid config entry: \"%s\", "+
"expected \"key = value\"", entry)
}
}
return nil
}

Expand Down
16 changes: 16 additions & 0 deletions test/e2e/runner/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"time"

"github.com/BurntSushi/toml"
"github.com/spf13/viper"

"github.com/cometbft/cometbft/config"
"github.com/cometbft/cometbft/crypto/ed25519"
Expand Down Expand Up @@ -316,6 +317,21 @@ func MakeConfig(node *e2e.Node) (*config.Config, error) {
if node.CompactionInterval != 0 && node.Compact {
cfg.Storage.CompactionInterval = node.CompactionInterval
}

// We currently need viper in order to parse config files.
if len(node.Config) > 0 {
viper.Reset()
for _, entry := range node.Config {
tokens := strings.Split(entry, " = ")
key, value := tokens[0], tokens[1]
logger.Debug("Applying Comet config", "node", node.Name, key, value)
viper.Set(key, value)
}
if err := viper.Unmarshal(cfg); err != nil {
return nil, err
}
}

return cfg, nil
}

Expand Down
Loading
0