mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
remove unused log buffers from test cluster, fixes race
the buffers were unused internally and external users had no access to them. Those wishing to read the logs of the cluster in tests may replace stdout/stderr with buffers on the Command struct. The race occurred when a node was stopped and then started again. some memberlist goroutines might not be completely cleaned up by the time the node restarted, and then two loggers were using the same output buffer.
This commit is contained in:
parent
3315c9e35c
commit
4ea48e1b40
1 changed files with 5 additions and 12 deletions
|
|
@ -18,7 +18,6 @@ import (
|
|||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
gohttp "net/http"
|
||||
"os"
|
||||
|
|
@ -40,10 +39,6 @@ type Command struct {
|
|||
*server.Command
|
||||
|
||||
commandOptions []server.CommandOption
|
||||
|
||||
stdin bytes.Buffer
|
||||
stdout bytes.Buffer
|
||||
stderr bytes.Buffer
|
||||
}
|
||||
|
||||
func OptAllowedOrigins(origins []string) server.CommandOption {
|
||||
|
|
@ -65,17 +60,15 @@ func newCommand(opts ...server.CommandOption) *Command {
|
|||
// beginning of the option slice so that it can be overridden by user-passed
|
||||
// options.
|
||||
opts = append([]server.CommandOption{server.OptCommandCloseTimeout(time.Millisecond * 2)}, opts...)
|
||||
m := &Command{Command: server.NewCommand(os.Stdin, os.Stdout, os.Stderr, opts...), commandOptions: opts}
|
||||
m := &Command{commandOptions: opts}
|
||||
m.Command = server.NewCommand(bytes.NewReader(nil), ioutil.Discard, ioutil.Discard, opts...)
|
||||
m.Config.DataDir = path
|
||||
m.Config.Bind = "http://localhost:0"
|
||||
m.Config.Cluster.Disabled = true
|
||||
m.Command.Stdin = &m.stdin
|
||||
m.Command.Stdout = &m.stdout
|
||||
m.Command.Stderr = &m.stderr
|
||||
|
||||
if testing.Verbose() {
|
||||
m.Command.Stdout = io.MultiWriter(os.Stdout, m.Command.Stdout)
|
||||
m.Command.Stderr = io.MultiWriter(os.Stderr, m.Command.Stderr)
|
||||
m.Command.Stdout = os.Stdout
|
||||
m.Command.Stderr = os.Stderr
|
||||
}
|
||||
|
||||
return m
|
||||
|
|
@ -120,7 +113,7 @@ func (m *Command) Reopen() error {
|
|||
|
||||
// Create new main with the same config.
|
||||
config := m.Command.Config
|
||||
m.Command = server.NewCommand(os.Stdin, os.Stdout, os.Stderr, m.commandOptions...)
|
||||
m.Command = server.NewCommand(bytes.NewReader(nil), ioutil.Discard, ioutil.Discard, m.commandOptions...)
|
||||
m.Command.Config = config
|
||||
|
||||
// Run new program.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue