feat: verbose logging during upgrades (#24720)
Co-authored-by: Alex | Interchain Labs <alex@interchainlabs.io>
This commit is contained in:
co-authored by
Alex | Interchain Labs
parent
3d777ad46a
commit
be955efe25
@@ -170,6 +170,7 @@ replace github.com/cosmos/cosmos-sdk => ../.
|
||||
replace (
|
||||
cosmossdk.io/api => ../api
|
||||
cosmossdk.io/core => ../core
|
||||
cosmossdk.io/log => ../log
|
||||
cosmossdk.io/store => ../store
|
||||
cosmossdk.io/x/tx => ../x/tx
|
||||
)
|
||||
|
||||
@@ -6,8 +6,6 @@ cosmossdk.io/depinject v1.2.0 h1:6NW/FSK1IkWTrX7XxUpBmX1QMBozpEI9SsWkKTBc5zw=
|
||||
cosmossdk.io/depinject v1.2.0/go.mod h1:pvitjtUxZZZTQESKNS9KhGjWVslJZxtO9VooRJYyPjk=
|
||||
cosmossdk.io/errors v1.0.2 h1:wcYiJz08HThbWxd/L4jObeLaLySopyyuUFB5w4AGpCo=
|
||||
cosmossdk.io/errors v1.0.2/go.mod h1:0rjgiHkftRYPj//3DrD6y8hcm40HcPv/dR4R/4efr0k=
|
||||
cosmossdk.io/log v1.5.1 h1:wLwiYXmfrort/O+j6EkjF+HvbdrRQd+4cYCPKFSm+zM=
|
||||
cosmossdk.io/log v1.5.1/go.mod h1:5cXXBvfBkR2/BcXmosdCSLXllvgSjphrrDVdfVRmBGM=
|
||||
cosmossdk.io/math v1.5.3 h1:WH6tu6Z3AUCeHbeOSHg2mt9rnoiUWVWaQ2t6Gkll96U=
|
||||
cosmossdk.io/math v1.5.3/go.mod h1:uqcZv7vexnhMFJF+6zh9EWdm/+Ylyln34IvPnBauPCQ=
|
||||
cosmossdk.io/schema v1.1.0 h1:mmpuz3dzouCoyjjcMcA/xHBEmMChN+EHh8EHxHRHhzE=
|
||||
|
||||
+23
-1
@@ -207,7 +207,7 @@ func (s *SystemUnderTest) IsDirty() bool {
|
||||
|
||||
// watchLogs stores stdout/stderr in a file and in a ring buffer to output the last n lines on test error
|
||||
func (s *SystemUnderTest) watchLogs(node int, cmd *exec.Cmd) {
|
||||
logfile, err := os.Create(filepath.Join(WorkDir, s.outputDir, fmt.Sprintf("node%d.out", node)))
|
||||
logfile, err := os.Create(s.logfileName(node))
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("open logfile error %#+v", err))
|
||||
}
|
||||
@@ -230,6 +230,10 @@ func (s *SystemUnderTest) watchLogs(node int, cmd *exec.Cmd) {
|
||||
})
|
||||
}
|
||||
|
||||
func (s *SystemUnderTest) logfileName(node int) string {
|
||||
return filepath.Join(WorkDir, s.outputDir, fmt.Sprintf("node%d.out", node))
|
||||
}
|
||||
|
||||
func appendToBuf(r io.Reader, b *ring.Ring, stop <-chan struct{}) {
|
||||
scanner := bufio.NewScanner(r)
|
||||
for scanner.Scan() {
|
||||
@@ -791,6 +795,24 @@ func (s *SystemUnderTest) BlockTime() time.Duration {
|
||||
return s.blockTime
|
||||
}
|
||||
|
||||
// FindLogMessage searches the logs of each node and returns a count of the number of
|
||||
// nodes that had a match for the provided regular expression.
|
||||
func (s *SystemUnderTest) FindLogMessage(regex *regexp.Regexp) int {
|
||||
found := 0
|
||||
for i := 0; i < s.nodesCount; i++ {
|
||||
logfile := s.logfileName(i)
|
||||
content, err := os.ReadFile(logfile)
|
||||
if err != nil {
|
||||
continue // skip if file cannot be read
|
||||
}
|
||||
if regex.Match(content) {
|
||||
found++
|
||||
}
|
||||
|
||||
}
|
||||
return found
|
||||
}
|
||||
|
||||
type Node struct {
|
||||
ID string
|
||||
IP string
|
||||
|
||||
Reference in New Issue
Block a user