mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
test: enhance StartNewProc to accept one more parameter: EtcdProcessClusterConfig
Signed-off-by: Benjamin Wang <wachao@vmware.com>
This commit is contained in:
parent
49ecea5dae
commit
080effc935
@ -65,7 +65,7 @@ func TestAuthCluster(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// start second process
|
// start second process
|
||||||
if err := epc.StartNewProc(ctx, t, rootUserClientOpts); err != nil {
|
if err := epc.StartNewProc(ctx, nil, t, rootUserClientOpts); err != nil {
|
||||||
t.Fatalf("could not start second etcd process (%v)", err)
|
t.Fatalf("could not start second etcd process (%v)", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ func TestGrpcProxyAutoSync(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Add and start second member
|
// Add and start second member
|
||||||
err = epc.StartNewProc(ctx, t)
|
err = epc.StartNewProc(ctx, nil, t)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Wait for auto sync of endpoints
|
// Wait for auto sync of endpoints
|
||||||
|
@ -604,12 +604,16 @@ func (epc *EtcdProcessCluster) Endpoints(f func(ep EtcdProcess) []string) (ret [
|
|||||||
|
|
||||||
func (epc *EtcdProcessCluster) CloseProc(ctx context.Context, finder func(EtcdProcess) bool, opts ...config.ClientOption) error {
|
func (epc *EtcdProcessCluster) CloseProc(ctx context.Context, finder func(EtcdProcess) bool, opts ...config.ClientOption) error {
|
||||||
procIndex := -1
|
procIndex := -1
|
||||||
|
if finder != nil {
|
||||||
for i := range epc.Procs {
|
for i := range epc.Procs {
|
||||||
if finder(epc.Procs[i]) {
|
if finder(epc.Procs[i]) {
|
||||||
procIndex = i
|
procIndex = i
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
procIndex = len(epc.Procs) - 1
|
||||||
|
}
|
||||||
|
|
||||||
if procIndex == -1 {
|
if procIndex == -1 {
|
||||||
return fmt.Errorf("no process found to stop")
|
return fmt.Errorf("no process found to stop")
|
||||||
@ -651,8 +655,14 @@ func (epc *EtcdProcessCluster) CloseProc(ctx context.Context, finder func(EtcdPr
|
|||||||
return proc.Close()
|
return proc.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (epc *EtcdProcessCluster) StartNewProc(ctx context.Context, tb testing.TB, opts ...config.ClientOption) error {
|
func (epc *EtcdProcessCluster) StartNewProc(ctx context.Context, cfg *EtcdProcessClusterConfig, tb testing.TB, opts ...config.ClientOption) error {
|
||||||
serverCfg := epc.Cfg.EtcdServerProcessConfig(tb, epc.nextSeq)
|
var serverCfg *EtcdServerProcessConfig
|
||||||
|
if cfg != nil {
|
||||||
|
serverCfg = cfg.EtcdServerProcessConfig(tb, epc.nextSeq)
|
||||||
|
} else {
|
||||||
|
serverCfg = epc.Cfg.EtcdServerProcessConfig(tb, epc.nextSeq)
|
||||||
|
}
|
||||||
|
|
||||||
epc.nextSeq++
|
epc.nextSeq++
|
||||||
|
|
||||||
initialCluster := []string{
|
initialCluster := []string{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user