diff --git a/test/framework/fixtures/libgoalFixture.go b/test/framework/fixtures/libgoalFixture.go index af84e4d2e1..e6ad44e060 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,6 +312,10 @@ func (f *LibGoalFixture) ShutdownImpl(preserveData bool) { f.NC.StopKMD() if preserveData { f.network.Stop(f.binDir) + f.dumpLogs(filepath.Join(f.PrimaryDataDir(), "node.log")) + for _, nodeDir := range f.NodeDataDirs() { + f.dumpLogs(filepath.Join(nodeDir, "node.log")) + } } else { f.network.Delete(f.binDir) @@ -324,6 +329,24 @@ func (f *LibGoalFixture) ShutdownImpl(preserveData bool) { } } +// 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", filePath) + return + } + 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 + scanner := bufio.NewScanner(file) + for scanner.Scan() { + f.t.Logf(scanner.Text()) + } +} + // 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..0e6f6ec5c8 100644 --- a/test/framework/fixtures/restClientFixture.go +++ b/test/framework/fixtures/restClientFixture.go @@ -265,6 +265,22 @@ 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 { + 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 } }