mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
test: Clean incorrectly used StopSignal field from expect
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
This commit is contained in:
parent
1038c2f45c
commit
157ee32da4
@ -45,9 +45,6 @@ type ExpectProcess struct {
|
|||||||
count int // increment whenever new line gets added
|
count int // increment whenever new line gets added
|
||||||
cur int // current read position
|
cur int // current read position
|
||||||
err error
|
err error
|
||||||
|
|
||||||
// StopSignal is the signal Stop sends to the process; defaults to SIGTERM.
|
|
||||||
StopSignal os.Signal
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewExpect creates a new process for expect testing.
|
// NewExpect creates a new process for expect testing.
|
||||||
@ -59,7 +56,6 @@ func NewExpect(name string, arg ...string) (ep *ExpectProcess, err error) {
|
|||||||
// NewExpectWithEnv creates a new process with user defined env variables for expect testing.
|
// NewExpectWithEnv creates a new process with user defined env variables for expect testing.
|
||||||
func NewExpectWithEnv(name string, args []string, env []string, serverProcessConfigName string) (ep *ExpectProcess, err error) {
|
func NewExpectWithEnv(name string, args []string, env []string, serverProcessConfigName string) (ep *ExpectProcess, err error) {
|
||||||
ep = &ExpectProcess{
|
ep = &ExpectProcess{
|
||||||
StopSignal: syscall.SIGTERM,
|
|
||||||
cfg: expectConfig{
|
cfg: expectConfig{
|
||||||
name: serverProcessConfigName,
|
name: serverProcessConfigName,
|
||||||
cmd: name,
|
cmd: name,
|
||||||
@ -196,7 +192,7 @@ func (ep *ExpectProcess) close(kill bool) error {
|
|||||||
return ep.err
|
return ep.err
|
||||||
}
|
}
|
||||||
if kill {
|
if kill {
|
||||||
ep.Signal(ep.StopSignal)
|
ep.Signal(syscall.SIGTERM)
|
||||||
}
|
}
|
||||||
|
|
||||||
err := ep.cmd.Wait()
|
err := ep.cmd.Wait()
|
||||||
|
@ -18,7 +18,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"syscall"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -167,7 +166,6 @@ func authGracefulDisableTest(cx ctlCtx) {
|
|||||||
|
|
||||||
// ...and restart the node
|
// ...and restart the node
|
||||||
node0 := cx.epc.Procs[0]
|
node0 := cx.epc.Procs[0]
|
||||||
node0.WithStopSignal(syscall.SIGINT)
|
|
||||||
if rerr := node0.Restart(context.TODO()); rerr != nil {
|
if rerr := node0.Restart(context.TODO()); rerr != nil {
|
||||||
cx.t.Fatal(rerr)
|
cx.t.Fatal(rerr)
|
||||||
}
|
}
|
||||||
@ -1281,7 +1279,6 @@ func authTestRevisionConsistency(cx ctlCtx) {
|
|||||||
oldAuthRevision := sresp.AuthRevision
|
oldAuthRevision := sresp.AuthRevision
|
||||||
|
|
||||||
// restart the node
|
// restart the node
|
||||||
node0.WithStopSignal(syscall.SIGINT)
|
|
||||||
if err := node0.Restart(context.TODO()); err != nil {
|
if err := node0.Restart(context.TODO()); err != nil {
|
||||||
cx.t.Fatal(err)
|
cx.t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -1400,7 +1397,6 @@ func authTestCacheReload(cx ctlCtx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// restart the node
|
// restart the node
|
||||||
node0.WithStopSignal(syscall.SIGINT)
|
|
||||||
if err := node0.Restart(context.TODO()); err != nil {
|
if err := node0.Restart(context.TODO()); err != nil {
|
||||||
cx.t.Fatal(err)
|
cx.t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
|
||||||
"path"
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
@ -524,10 +523,3 @@ func (epc *EtcdProcessCluster) Close() error {
|
|||||||
epc.lg.Info("closed test cluster.")
|
epc.lg.Info("closed test cluster.")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (epc *EtcdProcessCluster) WithStopSignal(sig os.Signal) (ret os.Signal) {
|
|
||||||
for _, p := range epc.Procs {
|
|
||||||
ret = p.WithStopSignal(sig)
|
|
||||||
}
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
|
@ -22,7 +22,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
|
||||||
"path"
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -100,11 +99,6 @@ func (p *proxyEtcdProcess) Close() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *proxyEtcdProcess) WithStopSignal(sig os.Signal) os.Signal {
|
|
||||||
p.proxyV3.WithStopSignal(sig)
|
|
||||||
return p.etcdProc.WithStopSignal(sig)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *proxyEtcdProcess) Logs() LogsExpect {
|
func (p *proxyEtcdProcess) Logs() LogsExpect {
|
||||||
return p.etcdProc.Logs()
|
return p.etcdProc.Logs()
|
||||||
}
|
}
|
||||||
@ -154,12 +148,6 @@ func (pp *proxyProc) Stop() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pp *proxyProc) WithStopSignal(sig os.Signal) os.Signal {
|
|
||||||
ret := pp.proc.StopSignal
|
|
||||||
pp.proc.StopSignal = sig
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
|
|
||||||
func (pp *proxyProc) Close() error { return pp.Stop() }
|
func (pp *proxyProc) Close() error { return pp.Stop() }
|
||||||
|
|
||||||
type proxyV2Proc struct {
|
type proxyV2Proc struct {
|
||||||
|
@ -45,7 +45,6 @@ type EtcdProcess interface {
|
|||||||
Restart(ctx context.Context) error
|
Restart(ctx context.Context) error
|
||||||
Stop() error
|
Stop() error
|
||||||
Close() error
|
Close() error
|
||||||
WithStopSignal(sig os.Signal) os.Signal
|
|
||||||
Config() *EtcdServerProcessConfig
|
Config() *EtcdServerProcessConfig
|
||||||
Logs() LogsExpect
|
Logs() LogsExpect
|
||||||
}
|
}
|
||||||
@ -163,12 +162,6 @@ func (ep *EtcdServerProcess) Close() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ep *EtcdServerProcess) WithStopSignal(sig os.Signal) os.Signal {
|
|
||||||
ret := ep.proc.StopSignal
|
|
||||||
ep.proc.StopSignal = sig
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ep *EtcdServerProcess) waitReady(ctx context.Context) error {
|
func (ep *EtcdServerProcess) waitReady(ctx context.Context) error {
|
||||||
defer close(ep.donec)
|
defer close(ep.donec)
|
||||||
return WaitReadyExpectProc(ctx, ep.proc, EtcdServerReadyLines)
|
return WaitReadyExpectProc(ctx, ep.proc, EtcdServerReadyLines)
|
||||||
|
@ -21,7 +21,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.etcd.io/etcd/client/pkg/v3/fileutil"
|
"go.etcd.io/etcd/client/pkg/v3/fileutil"
|
||||||
@ -69,12 +68,7 @@ func SpawnCmdWithLogger(lg *zap.Logger, args []string, envVars map[string]string
|
|||||||
zap.String("working-dir", wd),
|
zap.String("working-dir", wd),
|
||||||
zap.String("name", name),
|
zap.String("name", name),
|
||||||
zap.Strings("environment-variables", env))
|
zap.Strings("environment-variables", env))
|
||||||
ep, err := expect.NewExpectWithEnv(cmd, allArgs, env, name)
|
return expect.NewExpectWithEnv(cmd, allArgs, env, name)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
ep.StopSignal = syscall.SIGTERM
|
|
||||||
return ep, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getCovArgs() ([]string, error) {
|
func getCovArgs() ([]string, error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user