itest: include compressed btcd backend logs
This commit is contained in:
1 parent
4487acc5d9
commit
ca7192f8fd
3 files changed
+57
-20
No files matched your search
@@ -161,6 +161,11 @@ you.
|
|||||||
when encoding/decoding messages. Such that most of the heap escapes are fixed,
|
when encoding/decoding messages. Such that most of the heap escapes are fixed,
|
||||||
resulting in less memory being used when running `lnd`.
|
resulting in less memory being used when running `lnd`.
|
||||||
|
|
||||||
|
## Log system
|
||||||
|
|
||||||
|
* [Save compressed log files from logrorate during
|
||||||
|
itest](https://github.com/lightningnetwork/lnd/pull/5354).
|
||||||
|
|
||||||
## Bug Fixes
|
## Bug Fixes
|
||||||
|
|
||||||
A bug has been fixed that would cause `lnd` to [try to bootstrap using the
|
A bug has been fixed that would cause `lnd` to [try to bootstrap using the
|
||||||
|
|||||||
+24
-7
@@ -6,7 +6,9 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/btcjson"
|
"github.com/btcsuite/btcd/btcjson"
|
||||||
"github.com/btcsuite/btcd/chaincfg"
|
"github.com/btcsuite/btcd/chaincfg"
|
||||||
@@ -118,15 +120,30 @@ func NewBackend(miner string, netParams *chaincfg.Params) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// After shutting down the chain backend, we'll make a copy of
|
// After shutting down the chain backend, we'll make a copy of
|
||||||
// the log file before deleting the temporary log dir.
|
// the log files, including any compressed log files from
|
||||||
logFile := baseLogDir + "/" + netParams.Name + "/btcd.log"
|
// logrorate, before deleting the temporary log dir.
|
||||||
logDestination := fmt.Sprintf(
|
logDir := fmt.Sprintf("%s/%s", baseLogDir, netParams.Name)
|
||||||
"%s/output_btcd_chainbackend.log", GetLogDir(),
|
files, err := ioutil.ReadDir(logDir)
|
||||||
)
|
|
||||||
err := CopyFile(logDestination, logFile)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errStr += fmt.Sprintf("unable to copy file: %v\n", err)
|
errStr += fmt.Sprintf(
|
||||||
|
"unable to read log directory: %v\n", err,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, file := range files {
|
||||||
|
logFile := fmt.Sprintf("%s/%s", logDir, file.Name())
|
||||||
|
newFilename := strings.Replace(
|
||||||
|
file.Name(), "btcd.log", "output_btcd_chainbackend.log", 1,
|
||||||
|
)
|
||||||
|
logDestination := fmt.Sprintf(
|
||||||
|
"%s/%s", GetLogDir(), newFilename,
|
||||||
|
)
|
||||||
|
err := CopyFile(logDestination, logFile)
|
||||||
|
if err != nil {
|
||||||
|
errStr += fmt.Sprintf("unable to copy file: %v\n", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err = os.RemoveAll(baseLogDir); err != nil {
|
if err = os.RemoveAll(baseLogDir); err != nil {
|
||||||
errStr += fmt.Sprintf(
|
errStr += fmt.Sprintf(
|
||||||
"cannot remove dir %s: %v\n", baseLogDir, err,
|
"cannot remove dir %s: %v\n", baseLogDir, err,
|
||||||
|
|||||||
+28
-13
@@ -445,10 +445,11 @@ func newNode(cfg NodeConfig) (*HarnessNode, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewMiner creates a new miner using btcd backend. The logDir specifies the
|
// NewMiner creates a new miner using btcd backend. The baseLogDir specifies
|
||||||
// miner node's log dir. When tests finished, during clean up, its logs are
|
// the miner node's log dir. When tests are finished, during clean up, its log
|
||||||
// copied to a file specified as logFilename.
|
// files, including any compressed log files from logrotate, are copied to
|
||||||
func NewMiner(logDir, logFilename string, netParams *chaincfg.Params,
|
// logDir as logFilename.
|
||||||
|
func NewMiner(baseLogDir, logFilename string, netParams *chaincfg.Params,
|
||||||
handler *rpcclient.NotificationHandlers,
|
handler *rpcclient.NotificationHandlers,
|
||||||
btcdBinary string) (*rpctest.Harness, func() error, error) {
|
btcdBinary string) (*rpctest.Harness, func() error, error) {
|
||||||
|
|
||||||
@@ -458,7 +459,7 @@ func NewMiner(logDir, logFilename string, netParams *chaincfg.Params,
|
|||||||
"--nowinservice",
|
"--nowinservice",
|
||||||
"--nobanning",
|
"--nobanning",
|
||||||
"--debuglevel=debug",
|
"--debuglevel=debug",
|
||||||
"--logdir=" + logDir,
|
"--logdir=" + baseLogDir,
|
||||||
"--trickleinterval=100ms",
|
"--trickleinterval=100ms",
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -476,18 +477,32 @@ func NewMiner(logDir, logFilename string, netParams *chaincfg.Params,
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// After shutting down the miner, we'll make a copy of the log
|
// After shutting down the miner, we'll make a copy of
|
||||||
// file before deleting the temporary log dir.
|
// the log files before deleting the temporary log dir.
|
||||||
logFile := fmt.Sprintf("%s/%s/btcd.log", logDir, netParams.Name)
|
logDir := fmt.Sprintf("%s/%s", baseLogDir, netParams.Name)
|
||||||
copyPath := fmt.Sprintf("%s/../%s", logDir, logFilename)
|
files, err := ioutil.ReadDir(logDir)
|
||||||
err := CopyFile(filepath.Clean(copyPath), logFile)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to copy file: %v", err)
|
return fmt.Errorf("unable to read log directory: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = os.RemoveAll(logDir); err != nil {
|
for _, file := range files {
|
||||||
|
logFile := fmt.Sprintf(
|
||||||
|
"%s/%s", logDir, file.Name(),
|
||||||
|
)
|
||||||
|
newFilename := strings.Replace(file.Name(), "btcd.log", logFilename, 1)
|
||||||
|
copyPath := fmt.Sprintf(
|
||||||
|
"%s/../%s", baseLogDir, newFilename,
|
||||||
|
)
|
||||||
|
|
||||||
|
err := CopyFile(filepath.Clean(copyPath), logFile)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to copy file: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = os.RemoveAll(baseLogDir); err != nil {
|
||||||
return fmt.Errorf(
|
return fmt.Errorf(
|
||||||
"cannot remove dir %s: %v", logDir, err,
|
"cannot remove dir %s: %v", baseLogDir, err,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in new issue
Block a user