Skip to content

Commit

Permalink
prep for next PR, expose docker init flags
Browse files Browse the repository at this point in the history
  • Loading branch information
czarcas7ic committed May 5, 2022
1 parent 265d1f8 commit f0f61b0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
10 changes: 9 additions & 1 deletion tests/e2e/chain/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ func initNodes(c *internalChain, numVal int) error {
return nil
}

func initValidatorConfigs(c *internalChain) error {
func initValidatorConfigs(c *internalChain, pruning string, pruningKeepRecent string, pruningInterval string, snapshotInterval uint64, snapshotKeepRecent uint32, telemetryEnabled bool, telemetryRetentionTime int64, prometheusEnabled bool) error {
for i, val := range c.validators {
tmCfgPath := filepath.Join(val.configDir(), "config", "config.toml")

Expand All @@ -287,6 +287,7 @@ func initValidatorConfigs(c *internalChain) error {
valConfig.RPC.ListenAddress = "tcp://0.0.0.0:26657"
valConfig.StateSync.Enable = false
valConfig.LogLevel = "info"
valConfig.Instrumentation.Prometheus = prometheusEnabled

var peers []string

Expand All @@ -308,8 +309,15 @@ func initValidatorConfigs(c *internalChain) error {
appCfgPath := filepath.Join(val.configDir(), "config", "app.toml")

appConfig := srvconfig.DefaultConfig()
appConfig.BaseConfig.Pruning = pruning
appConfig.BaseConfig.PruningKeepRecent = pruningKeepRecent
appConfig.BaseConfig.PruningInterval = pruningInterval
appConfig.API.Enable = true
appConfig.MinGasPrices = fmt.Sprintf("%s%s", MinGasPrice, OsmoDenom)
appConfig.StateSync.SnapshotInterval = snapshotInterval
appConfig.StateSync.SnapshotKeepRecent = snapshotKeepRecent
appConfig.Telemetry.Enabled = telemetryEnabled
appConfig.Telemetry.PrometheusRetentionTime = telemetryRetentionTime

srvconfig.WriteConfigFile(appCfgPath, appConfig)
}
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/chain/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package chain

func Init(id, dataDir string, numVal int) (*Chain, error) {
func Init(id, dataDir string, numVal int, pruning string, pruningKeepRecent string, pruningInterval string, snapshotInterval uint64, snapshotKeepRecent uint32, telemetryEnabled bool, telemetryRetentionTime int64, prometheusEnabled bool) (*Chain, error) {
chain, err := new(id, dataDir)
if err != nil {
return nil, err
Expand All @@ -11,7 +11,7 @@ func Init(id, dataDir string, numVal int) (*Chain, error) {
if err := initGenesis(chain); err != nil {
return nil, err
}
if err := initValidatorConfigs(chain); err != nil {
if err := initValidatorConfigs(chain, pruning, pruningKeepRecent, pruningInterval, snapshotInterval, snapshotKeepRecent, telemetryEnabled, telemetryRetentionTime, prometheusEnabled); err != nil {
return nil, err
}
return chain.export(), nil
Expand Down
24 changes: 20 additions & 4 deletions tests/e2e/chain_init/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,30 @@ import (

func main() {
var (
dataDir string
chainId string
numVal int
dataDir string
chainId string
numVal int
pruning string
pruningKeepRecent string
pruningInterval string
snapshotInterval uint64
snapshotKeepRecent uint
telemetryEnabled bool
telemetryRetentionTime int64
prometheusEnabled bool
)

flag.StringVar(&dataDir, "data-dir", "", "chain data directory")
flag.StringVar(&chainId, "chain-id", "", "chain ID")
flag.IntVar(&numVal, "num-val", 2, "number of validators for each chain")
flag.StringVar(&pruning, "pruning", "default", "pruning config")
flag.StringVar(&pruningKeepRecent, "pruning-keep-recent", "0", "pruning keep recent config")
flag.StringVar(&pruningInterval, "pruning-interval", "0", "pruning interval config")
flag.Uint64Var(&snapshotInterval, "snapshot-interval", 1500, "state sync snapshot interval")
flag.UintVar(&snapshotKeepRecent, "snapshot-keep-recent", 2, "number of state sync snapshots to keep and serve")
flag.BoolVar(&telemetryEnabled, "telemetry-enabled", false, "enable telemetry in app.toml")
flag.Int64Var(&telemetryRetentionTime, "telemetry-retention-time", 0, "retention time for telemetry in app.toml")
flag.BoolVar(&prometheusEnabled, "prometheus-enabled", false, "enable prometheus in config.toml")
flag.Parse()

if len(dataDir) == 0 {
Expand All @@ -29,7 +45,7 @@ func main() {
panic(err)
}

createdChain, err := chain.Init(chainId, dataDir, numVal)
createdChain, err := chain.Init(chainId, dataDir, numVal, pruning, pruningKeepRecent, pruningInterval, snapshotInterval, uint32(snapshotKeepRecent), telemetryEnabled, telemetryRetentionTime, prometheusEnabled)
if err != nil {
panic(err)
}
Expand Down

0 comments on commit f0f61b0

Please sign in to comment.