From db48c82fd7c813d4bcff751d05ac1fa3763f4eb5 Mon Sep 17 00:00:00 2001 From: Nicholas Guo Date: Wed, 10 Aug 2022 08:32:51 -0700 Subject: [PATCH 1/8] add logs --- test/framework/fixtures/libgoalFixture.go | 20 ++++++++++++++++++++ test/framework/fixtures/restClientFixture.go | 7 +++++++ 2 files changed, 27 insertions(+) diff --git a/test/framework/fixtures/libgoalFixture.go b/test/framework/fixtures/libgoalFixture.go index af84e4d2e1..eac9e267c7 100644 --- a/test/framework/fixtures/libgoalFixture.go +++ b/test/framework/fixtures/libgoalFixture.go @@ -311,6 +311,10 @@ func (f *LibGoalFixture) ShutdownImpl(preserveData bool) { f.NC.StopKMD() if preserveData { f.network.Stop(f.binDir) + f.dumpLogs(f.PrimaryDataDir()) + for _, nodeDir := range f.NodeDataDirs() { + f.dumpLogs(nodeDir) + } } else { f.network.Delete(f.binDir) @@ -324,6 +328,22 @@ func (f *LibGoalFixture) ShutdownImpl(preserveData bool) { } } +// dumpLogs prints out node.log files for the running nodes +func (f *LibGoalFixture) dumpLogs(dataDir string) { + file, err := os.Open(dataDir + "/node.log") + if err != nil { + f.t.Logf("could not open %s node.log", dataDir) + return + } + b, err := ioutil.ReadAll(file) + if err != nil { + f.t.Logf("could not read %s node.log", dataDir) + return + } + fmt.Println("node.log for ", dataDir) + fmt.Print(string(b)) +} + // intercept baseFixture.failOnError so we can clean up any algods that are still alive func (f *LibGoalFixture) failOnError(err error, message string) { if err != nil { diff --git a/test/framework/fixtures/restClientFixture.go b/test/framework/fixtures/restClientFixture.go index 7265c560cb..6d893a4463 100644 --- a/test/framework/fixtures/restClientFixture.go +++ b/test/framework/fixtures/restClientFixture.go @@ -265,6 +265,13 @@ func (f *RestClientFixture) WaitForAllTxnsToConfirm(roundTimeout uint64, txidsAn for txid, addr := range txidsAndAddresses { _, err := f.WaitForConfirmedTxn(roundTimeout, addr, txid) if err != nil { + f.t.Logf("txn failed to confirm: ", addr, txid) + pendingTxns, err := f.AlgodClient.GetPendingTransactions(0) + if err == nil { + f.t.Logf("pending: ", pendingTxns) + } else { + f.t.Logf("unable to log pending txns, ", err) + } return false } } From e17fc584a0623542660da8d60efb91806faeb8aa Mon Sep 17 00:00:00 2001 From: Nicholas Guo Date: Wed, 10 Aug 2022 10:50:02 -0700 Subject: [PATCH 2/8] limit to 100 --- test/framework/fixtures/libgoalFixture.go | 32 +++++++++++++++-------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/test/framework/fixtures/libgoalFixture.go b/test/framework/fixtures/libgoalFixture.go index eac9e267c7..bfb461f8d7 100644 --- a/test/framework/fixtures/libgoalFixture.go +++ b/test/framework/fixtures/libgoalFixture.go @@ -17,6 +17,7 @@ package fixtures import ( + "bufio" "fmt" "io/ioutil" "os" @@ -311,9 +312,13 @@ func (f *LibGoalFixture) ShutdownImpl(preserveData bool) { f.NC.StopKMD() if preserveData { f.network.Stop(f.binDir) - f.dumpLogs(f.PrimaryDataDir()) + f.dumpLogs(f.PrimaryDataDir() + "/node.log") + f.dumpLogs(f.PrimaryDataDir() + "/algod-err.log") + f.dumpLogs(f.PrimaryDataDir() + "/algod-out.log") for _, nodeDir := range f.NodeDataDirs() { - f.dumpLogs(nodeDir) + f.dumpLogs(nodeDir + "/node.log") + f.dumpLogs(nodeDir + "/algod-err.log") + f.dumpLogs(nodeDir + "/algod-out.log") } } else { f.network.Delete(f.binDir) @@ -329,19 +334,24 @@ func (f *LibGoalFixture) ShutdownImpl(preserveData bool) { } // dumpLogs prints out node.log files for the running nodes -func (f *LibGoalFixture) dumpLogs(dataDir string) { - file, err := os.Open(dataDir + "/node.log") +func (f *LibGoalFixture) dumpLogs(filePath string) { + file, err := os.Open(filePath) if err != nil { - f.t.Logf("could not open %s node.log", dataDir) + f.t.Logf("could not open %s node.log", filePath) return } - b, err := ioutil.ReadAll(file) - if err != nil { - f.t.Logf("could not read %s node.log", dataDir) - return + var lines []string + scanner := bufio.NewScanner(file) + for scanner.Scan() { + lines = append(lines, scanner.Text()) + } + if len(lines) > 100 { + lines = lines[len(lines)-100:] + } + f.t.Logf("contents of ", filePath) + for _, line := range lines { + f.t.Logf(line) } - fmt.Println("node.log for ", dataDir) - fmt.Print(string(b)) } // intercept baseFixture.failOnError so we can clean up any algods that are still alive From 33d55d3262660e2a989b6019444cfa382a80af02 Mon Sep 17 00:00:00 2001 From: Nicholas Guo Date: Wed, 10 Aug 2022 12:23:19 -0700 Subject: [PATCH 3/8] print both list of txid --- test/framework/fixtures/restClientFixture.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/framework/fixtures/restClientFixture.go b/test/framework/fixtures/restClientFixture.go index 6d893a4463..0e6f6ec5c8 100644 --- a/test/framework/fixtures/restClientFixture.go +++ b/test/framework/fixtures/restClientFixture.go @@ -268,10 +268,19 @@ func (f *RestClientFixture) WaitForAllTxnsToConfirm(roundTimeout uint64, txidsAn f.t.Logf("txn failed to confirm: ", addr, txid) pendingTxns, err := f.AlgodClient.GetPendingTransactions(0) if err == nil { - f.t.Logf("pending: ", pendingTxns) + pendingTxids := make([]string, 0, pendingTxns.TotalTxns) + for _, txn := range pendingTxns.TruncatedTxns.Transactions { + pendingTxids = append(pendingTxids, txn.TxID) + } + f.t.Logf("pending txids: ", pendingTxids) } else { f.t.Logf("unable to log pending txns, ", err) } + allTxids := make([]string, 0, len(txidsAndAddresses)) + for txID := range txidsAndAddresses { + allTxids = append(allTxids, txID) + } + f.t.Logf("all txids: ", allTxids) return false } } From 8eacc96adc64e4bceadc424f397278c185671450 Mon Sep 17 00:00:00 2001 From: Nicholas Guo Date: Thu, 11 Aug 2022 10:12:34 -0700 Subject: [PATCH 4/8] dont log algod-errr/out --- test/framework/fixtures/libgoalFixture.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/test/framework/fixtures/libgoalFixture.go b/test/framework/fixtures/libgoalFixture.go index bfb461f8d7..e39db22c5c 100644 --- a/test/framework/fixtures/libgoalFixture.go +++ b/test/framework/fixtures/libgoalFixture.go @@ -313,12 +313,8 @@ func (f *LibGoalFixture) ShutdownImpl(preserveData bool) { if preserveData { f.network.Stop(f.binDir) f.dumpLogs(f.PrimaryDataDir() + "/node.log") - f.dumpLogs(f.PrimaryDataDir() + "/algod-err.log") - f.dumpLogs(f.PrimaryDataDir() + "/algod-out.log") for _, nodeDir := range f.NodeDataDirs() { f.dumpLogs(nodeDir + "/node.log") - f.dumpLogs(nodeDir + "/algod-err.log") - f.dumpLogs(nodeDir + "/algod-out.log") } } else { f.network.Delete(f.binDir) @@ -333,11 +329,11 @@ func (f *LibGoalFixture) ShutdownImpl(preserveData bool) { } } -// dumpLogs prints out node.log files for the running nodes +// dumpLogs prints out log files for the running nodes func (f *LibGoalFixture) dumpLogs(filePath string) { file, err := os.Open(filePath) if err != nil { - f.t.Logf("could not open %s node.log", filePath) + f.t.Logf("could not open %s", filePath) return } var lines []string From 7d3ca8359cc458b129c1cbd1e291c4a6b14ec5a0 Mon Sep 17 00:00:00 2001 From: Nicholas Guo Date: Thu, 11 Aug 2022 11:12:02 -0700 Subject: [PATCH 5/8] use filepaath join --- test/framework/fixtures/libgoalFixture.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/framework/fixtures/libgoalFixture.go b/test/framework/fixtures/libgoalFixture.go index e39db22c5c..ab9d20303a 100644 --- a/test/framework/fixtures/libgoalFixture.go +++ b/test/framework/fixtures/libgoalFixture.go @@ -312,9 +312,9 @@ func (f *LibGoalFixture) ShutdownImpl(preserveData bool) { f.NC.StopKMD() if preserveData { f.network.Stop(f.binDir) - f.dumpLogs(f.PrimaryDataDir() + "/node.log") + f.dumpLogs(filepath.Join(f.PrimaryDataDir(), "node.log")) for _, nodeDir := range f.NodeDataDirs() { - f.dumpLogs(nodeDir + "/node.log") + f.dumpLogs(filepath.Join(nodeDir, "node.log")) } } else { f.network.Delete(f.binDir) From a095973067ca84661aa165c1bfcf41a12dc5f016 Mon Sep 17 00:00:00 2001 From: nicholasguoalgorand <67928479+nicholasguoalgorand@users.noreply.github.com> Date: Thu, 11 Aug 2022 12:31:37 -0700 Subject: [PATCH 6/8] Update test/framework/fixtures/libgoalFixture.go Co-authored-by: Pavel Zbitskiy <65323360+algorandskiy@users.noreply.github.com> --- test/framework/fixtures/libgoalFixture.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/framework/fixtures/libgoalFixture.go b/test/framework/fixtures/libgoalFixture.go index ab9d20303a..637aef5eea 100644 --- a/test/framework/fixtures/libgoalFixture.go +++ b/test/framework/fixtures/libgoalFixture.go @@ -344,7 +344,9 @@ func (f *LibGoalFixture) dumpLogs(filePath string) { if len(lines) > 100 { lines = lines[len(lines)-100:] } - f.t.Logf("contents of ", filePath) + f.t.Logln("=================================") + parts := strings.Split(filePath, "/") + f.t.Logf("%s/%s:", parts[len(parts)-2], parts[len(parts)-1]) // Primary/node.log for _, line := range lines { f.t.Logf(line) } From 18cdd70e98b83397d45cbcdab1297c230d873487 Mon Sep 17 00:00:00 2001 From: Nicholas Guo Date: Thu, 11 Aug 2022 12:52:36 -0700 Subject: [PATCH 7/8] dont limit to 100 lines --- test/framework/fixtures/libgoalFixture.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/framework/fixtures/libgoalFixture.go b/test/framework/fixtures/libgoalFixture.go index 637aef5eea..adca50e7b8 100644 --- a/test/framework/fixtures/libgoalFixture.go +++ b/test/framework/fixtures/libgoalFixture.go @@ -341,10 +341,10 @@ func (f *LibGoalFixture) dumpLogs(filePath string) { for scanner.Scan() { lines = append(lines, scanner.Text()) } - if len(lines) > 100 { - lines = lines[len(lines)-100:] - } - f.t.Logln("=================================") + //if len(lines) > 100 { + // lines = lines[len(lines)-100:] + //} + f.t.Log("=================================") parts := strings.Split(filePath, "/") f.t.Logf("%s/%s:", parts[len(parts)-2], parts[len(parts)-1]) // Primary/node.log for _, line := range lines { From fad52b2dfa7579d2ffe464ab491f37936ffbdf32 Mon Sep 17 00:00:00 2001 From: Pavel Zbitskiy Date: Thu, 11 Aug 2022 19:56:53 -0400 Subject: [PATCH 8/8] Code style fixes --- test/framework/fixtures/libgoalFixture.go | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/test/framework/fixtures/libgoalFixture.go b/test/framework/fixtures/libgoalFixture.go index adca50e7b8..e6ad44e060 100644 --- a/test/framework/fixtures/libgoalFixture.go +++ b/test/framework/fixtures/libgoalFixture.go @@ -336,19 +336,14 @@ func (f *LibGoalFixture) dumpLogs(filePath string) { f.t.Logf("could not open %s", filePath) return } - var lines []string - scanner := bufio.NewScanner(file) - for scanner.Scan() { - lines = append(lines, scanner.Text()) - } - //if len(lines) > 100 { - // lines = lines[len(lines)-100:] - //} - f.t.Log("=================================") + defer file.Close() + + f.t.Log("=================================\n") parts := strings.Split(filePath, "/") f.t.Logf("%s/%s:", parts[len(parts)-2], parts[len(parts)-1]) // Primary/node.log - for _, line := range lines { - f.t.Logf(line) + scanner := bufio.NewScanner(file) + for scanner.Scan() { + f.t.Logf(scanner.Text()) } }