mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-19 06:31:57 +00:00
e2e: add control over the log level of nodes (#5958)
This commit is contained in:
+18
-4
@@ -116,6 +116,11 @@ func NewCLI() *CLI {
|
||||
cli.root.Flags().BoolVarP(&cli.preserve, "preserve", "p", false,
|
||||
"Preserves the running of the test net after tests are completed")
|
||||
|
||||
cli.root.SetHelpCommand(&cobra.Command{
|
||||
Use: "no-help",
|
||||
Hidden: true,
|
||||
})
|
||||
|
||||
cli.root.AddCommand(&cobra.Command{
|
||||
Use: "setup",
|
||||
Short: "Generates the testnet directory and configuration",
|
||||
@@ -189,17 +194,26 @@ func NewCLI() *CLI {
|
||||
})
|
||||
|
||||
cli.root.AddCommand(&cobra.Command{
|
||||
Use: "logs",
|
||||
Short: "Shows the testnet logs",
|
||||
Use: "logs [node]",
|
||||
Short: "Shows the testnet or a specefic node's logs",
|
||||
Example: "runner logs valiator03",
|
||||
Args: cobra.MaximumNArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if len(args) == 1 {
|
||||
return execComposeVerbose(cli.testnet.Dir, "logs", args[0])
|
||||
}
|
||||
return execComposeVerbose(cli.testnet.Dir, "logs")
|
||||
},
|
||||
})
|
||||
|
||||
cli.root.AddCommand(&cobra.Command{
|
||||
Use: "tail",
|
||||
Short: "Tails the testnet logs",
|
||||
Use: "tail [node]",
|
||||
Short: "Tails the testnet or a specific node's logs",
|
||||
Args: cobra.MaximumNArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if len(args) == 1 {
|
||||
return execComposeVerbose(cli.testnet.Dir, "logs", "--follow", args[0])
|
||||
}
|
||||
return execComposeVerbose(cli.testnet.Dir, "logs", "--follow")
|
||||
},
|
||||
})
|
||||
|
||||
@@ -122,17 +122,24 @@ func Setup(testnet *e2e.Testnet) error {
|
||||
func MakeDockerCompose(testnet *e2e.Testnet) ([]byte, error) {
|
||||
// Must use version 2 Docker Compose format, to support IPv6.
|
||||
tmpl, err := template.New("docker-compose").Funcs(template.FuncMap{
|
||||
"misbehaviorsToString": func(misbehaviors map[int64]string) string {
|
||||
str := ""
|
||||
"startCommands": func(misbehaviors map[int64]string, logLevel string) string {
|
||||
command := "start"
|
||||
misbehaviorString := ""
|
||||
for height, misbehavior := range misbehaviors {
|
||||
// after the first behavior set, a comma must be prepended
|
||||
if str != "" {
|
||||
str += ","
|
||||
if misbehaviorString != "" {
|
||||
misbehaviorString += ","
|
||||
}
|
||||
heightString := strconv.Itoa(int(height))
|
||||
str += misbehavior + "," + heightString
|
||||
misbehaviorString += misbehavior + "," + heightString
|
||||
}
|
||||
return str
|
||||
if misbehaviorString != "" {
|
||||
command += " --misbehaviors " + misbehaviorString
|
||||
}
|
||||
if logLevel != "" && logLevel != config.DefaultPackageLogLevels() {
|
||||
command += " --log-level " + logLevel
|
||||
}
|
||||
return command
|
||||
},
|
||||
}).Parse(`version: '2.4'
|
||||
|
||||
@@ -160,7 +167,9 @@ services:
|
||||
entrypoint: /usr/bin/entrypoint-builtin
|
||||
{{- else if .Misbehaviors }}
|
||||
entrypoint: /usr/bin/entrypoint-maverick
|
||||
command: ["start", "--misbehaviors", "{{ misbehaviorsToString .Misbehaviors }}"]
|
||||
{{- end }}
|
||||
{{- if ne .ABCIProtocol "builtin"}}
|
||||
command: {{ startCommands .Misbehaviors .LogLevel }}
|
||||
{{- end }}
|
||||
init: true
|
||||
ports:
|
||||
@@ -227,6 +236,9 @@ func MakeConfig(node *e2e.Node) (*config.Config, error) {
|
||||
cfg := config.DefaultConfig()
|
||||
cfg.Moniker = node.Name
|
||||
cfg.ProxyApp = AppAddressTCP
|
||||
if node.LogLevel != "" {
|
||||
cfg.LogLevel = node.LogLevel
|
||||
}
|
||||
cfg.RPC.ListenAddress = "tcp://0.0.0.0:26657"
|
||||
cfg.P2P.ExternalAddress = fmt.Sprintf("tcp://%v", node.AddressP2P(false))
|
||||
cfg.P2P.AddrBookStrict = false
|
||||
|
||||
Reference in New Issue
Block a user