Skip to content

Commit

Permalink
tests: Make EtcdServerProcess substruct of proxyEtcdProcess to dummy …
Browse files Browse the repository at this point in the history
…methods when extending EtcdProcess interface

Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
  • Loading branch information
serathius committed Jul 27, 2023
1 parent 6aad508 commit 828e789
Showing 1 changed file with 9 additions and 36 deletions.
45 changes: 9 additions & 36 deletions tests/framework/e2e/cluster_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -49,38 +48,36 @@ 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 {
panic("not implemented; proxy doesn't provide health information")
}

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)
}

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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 828e789

Please sign in to comment.