mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
actually yield checksums to caller
While fixing a bug that log messages were ending up in the output buffer for backups, we fixed up a bunch of things to do with log messages and output for various commands. Due to a subtle oversight, this means that since we did that, executor_test's `chkSumCluster` has been dutifully printing `hash:blahblahblah` to os.Stdout, and returning an empty string. This also, indirectly, fixes a very strange behavior we've had ever since then, which is that a lot of test output silently disappears. The reason is probably, although I haven't found the right code path, that we were ending up closing os.Stdout.
This commit is contained in:
parent
841ef32545
commit
70f92bc038
4 changed files with 11 additions and 10 deletions
|
|
@ -3,13 +3,15 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/featurebasedb/featurebase/v3/ctl"
|
||||
"github.com/featurebasedb/featurebase/v3/logger"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func newChkSumCommand(logdest logger.Logger) *cobra.Command {
|
||||
cmd := ctl.NewChkSumCommand(logdest)
|
||||
cmd := ctl.NewChkSumCommand(logdest, os.Stdout)
|
||||
ccmd := &cobra.Command{
|
||||
Use: "chksum",
|
||||
Short: "Digital signature of FeatureBase data",
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import (
|
|||
"crypto/tls"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/cespare/xxhash"
|
||||
pilosa "github.com/featurebasedb/featurebase/v3"
|
||||
|
|
@ -38,9 +37,9 @@ func (cmd *ChkSumCommand) Logger() logger.Logger {
|
|||
}
|
||||
|
||||
// NewChkSumCommand returns a new instance of BackupCommand.
|
||||
func NewChkSumCommand(logdest logger.Logger) *ChkSumCommand {
|
||||
func NewChkSumCommand(logdest logger.Logger, stdout io.Writer) *ChkSumCommand {
|
||||
return &ChkSumCommand{
|
||||
stdout: os.Stdout,
|
||||
stdout: stdout,
|
||||
logDest: logdest,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,9 +13,8 @@ import (
|
|||
|
||||
func TestChkSumCommand_Run(t *testing.T) {
|
||||
cmLog := logger.NewStandardLogger(os.Stderr)
|
||||
cm := NewChkSumCommand(cmLog)
|
||||
buf := &bytes.Buffer{}
|
||||
cm.stdout = buf
|
||||
cm := NewChkSumCommand(cmLog, buf)
|
||||
|
||||
cluster := test.MustRunCluster(t, 1)
|
||||
defer cluster.Close()
|
||||
|
|
|
|||
|
|
@ -7447,15 +7447,16 @@ func backupTarTest(t *testing.T, c *test.Cluster, index string) {
|
|||
|
||||
func chkSumCluster(t *testing.T, c *test.Cluster) string {
|
||||
t.Helper()
|
||||
buf := &bytes.Buffer{}
|
||||
chkSumLog := logger.NewStandardLogger(buf)
|
||||
chkSum := ctl.NewChkSumCommand(chkSumLog)
|
||||
errBuf := &bytes.Buffer{}
|
||||
outBuf := &bytes.Buffer{}
|
||||
chkSumLog := logger.NewStandardLogger(errBuf)
|
||||
chkSum := ctl.NewChkSumCommand(chkSumLog, outBuf)
|
||||
chkSum.Host = c.Nodes[len(c.Nodes)-1].URL()
|
||||
if err := chkSum.Run(context.Background()); err != nil {
|
||||
t.Fatalf("running checksum: %v", err)
|
||||
}
|
||||
|
||||
return buf.String()
|
||||
return outBuf.String()
|
||||
}
|
||||
|
||||
func backupCluster(t *testing.T, c *test.Cluster, index string) (backupDir string) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue