mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
tests: Make EtcdServerProcess substruct of proxyEtcdProcess to dummy methods when extending EtcdProcess interface
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
This commit is contained in:
parent
6aad5084b0
commit
828e789c18
@ -28,12 +28,11 @@ import (
|
||||
"go.uber.org/zap"
|
||||
|
||||
"go.etcd.io/etcd/pkg/v3/expect"
|
||||
"go.etcd.io/etcd/pkg/v3/proxy"
|
||||
"go.etcd.io/etcd/tests/v3/framework/config"
|
||||
)
|
||||
|
||||
type proxyEtcdProcess struct {
|
||||
etcdProc EtcdProcess
|
||||
*EtcdServerProcess
|
||||
// TODO(ahrtr): We need to remove `proxyV2` and v2discovery when the v2client is removed.
|
||||
proxyV2 *proxyV2Proc
|
||||
proxyV3 *proxyV3Proc
|
||||
@ -49,15 +48,13 @@ func NewProxyEtcdProcess(cfg *EtcdServerProcessConfig) (*proxyEtcdProcess, error
|
||||
return nil, err
|
||||
}
|
||||
pep := &proxyEtcdProcess{
|
||||
etcdProc: ep,
|
||||
proxyV2: newProxyV2Proc(cfg),
|
||||
proxyV3: newProxyV3Proc(cfg),
|
||||
EtcdServerProcess: ep,
|
||||
proxyV2: newProxyV2Proc(cfg),
|
||||
proxyV3: newProxyV3Proc(cfg),
|
||||
}
|
||||
return pep, nil
|
||||
}
|
||||
|
||||
func (p *proxyEtcdProcess) Config() *EtcdServerProcessConfig { return p.etcdProc.Config() }
|
||||
|
||||
func (p *proxyEtcdProcess) EndpointsHTTP() []string { return p.proxyV2.endpoints() }
|
||||
func (p *proxyEtcdProcess) EndpointsGRPC() []string { return p.proxyV3.endpoints() }
|
||||
func (p *proxyEtcdProcess) EndpointsMetrics() []string {
|
||||
@ -65,14 +62,14 @@ func (p *proxyEtcdProcess) EndpointsMetrics() []string {
|
||||
}
|
||||
|
||||
func (p *proxyEtcdProcess) Start(ctx context.Context) error {
|
||||
if err := p.etcdProc.Start(ctx); err != nil {
|
||||
if err := p.EtcdServerProcess.Start(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return p.proxyV3.Start(ctx)
|
||||
}
|
||||
|
||||
func (p *proxyEtcdProcess) Restart(ctx context.Context) error {
|
||||
if err := p.etcdProc.Restart(ctx); err != nil {
|
||||
if err := p.EtcdServerProcess.Restart(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return p.proxyV3.Restart(ctx)
|
||||
@ -80,7 +77,7 @@ func (p *proxyEtcdProcess) Restart(ctx context.Context) error {
|
||||
|
||||
func (p *proxyEtcdProcess) Stop() error {
|
||||
err := p.proxyV3.Stop()
|
||||
if eerr := p.etcdProc.Stop(); eerr != nil && err == nil {
|
||||
if eerr := p.EtcdServerProcess.Stop(); eerr != nil && err == nil {
|
||||
// fails on go-grpc issue #1384
|
||||
if !strings.Contains(eerr.Error(), "exit status 2") {
|
||||
err = eerr
|
||||
@ -91,7 +88,7 @@ func (p *proxyEtcdProcess) Stop() error {
|
||||
|
||||
func (p *proxyEtcdProcess) Close() error {
|
||||
err := p.proxyV3.Close()
|
||||
if eerr := p.etcdProc.Close(); eerr != nil && err == nil {
|
||||
if eerr := p.EtcdServerProcess.Close(); eerr != nil && err == nil {
|
||||
// fails on go-grpc issue #1384
|
||||
if !strings.Contains(eerr.Error(), "exit status 2") {
|
||||
err = eerr
|
||||
@ -101,37 +98,13 @@ func (p *proxyEtcdProcess) Close() error {
|
||||
}
|
||||
|
||||
func (p *proxyEtcdProcess) Etcdctl(opts ...config.ClientOption) *EtcdctlV3 {
|
||||
etcdctl, err := NewEtcdctl(p.etcdProc.Config().Client, p.etcdProc.EndpointsGRPC(), opts...)
|
||||
etcdctl, err := NewEtcdctl(p.EtcdServerProcess.Config().Client, p.EtcdServerProcess.EndpointsGRPC(), opts...)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return etcdctl
|
||||
}
|
||||
|
||||
func (p *proxyEtcdProcess) Logs() LogsExpect {
|
||||
return p.etcdProc.Logs()
|
||||
}
|
||||
|
||||
func (p *proxyEtcdProcess) Kill() error {
|
||||
return p.etcdProc.Kill()
|
||||
}
|
||||
|
||||
func (p *proxyEtcdProcess) IsRunning() bool {
|
||||
return p.etcdProc.IsRunning()
|
||||
}
|
||||
|
||||
func (p *proxyEtcdProcess) Wait(ctx context.Context) error {
|
||||
return p.etcdProc.Wait(ctx)
|
||||
}
|
||||
|
||||
func (p *proxyEtcdProcess) PeerProxy() proxy.Server {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *proxyEtcdProcess) Failpoints() *BinaryFailpoints {
|
||||
return p.etcdProc.Failpoints()
|
||||
}
|
||||
|
||||
type proxyProc struct {
|
||||
lg *zap.Logger
|
||||
name string
|
||||
|
Loading…
x
Reference in New Issue
Block a user