Skip to content

Commit

Permalink
Implement terminate failpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Marek Siarkowicz <[email protected]>
  • Loading branch information
serathius committed Oct 17, 2023
1 parent be83fff commit b97380f
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions tests/robustness/failpoint/kill.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ import (
)

var (
KillFailpoint Failpoint = killFailpoint{}
KillFailpoint Failpoint = sigkillFailpoint{}
TerminateFailpoint Failpoint = sigtermFailpoint{}
)

type killFailpoint struct{}
type sigkillFailpoint struct{}

func (f killFailpoint) Inject(ctx context.Context, t *testing.T, lg *zap.Logger, clus *e2e.EtcdProcessCluster) error {
func (f sigkillFailpoint) Inject(ctx context.Context, t *testing.T, lg *zap.Logger, clus *e2e.EtcdProcessCluster) error {
member := clus.Procs[rand.Int()%len(clus.Procs)]

for member.IsRunning() {
Expand Down Expand Up @@ -60,10 +61,25 @@ func (f killFailpoint) Inject(ctx context.Context, t *testing.T, lg *zap.Logger,
return nil
}

func (f killFailpoint) Name() string {
func (f sigkillFailpoint) Name() string {
return "Kill"
}

func (f killFailpoint) Available(e2e.EtcdProcessClusterConfig, e2e.EtcdProcess) bool {
func (f sigkillFailpoint) Available(e2e.EtcdProcessClusterConfig, e2e.EtcdProcess) bool {
return true
}

type sigtermFailpoint struct{}

func (f sigtermFailpoint) Inject(ctx context.Context, t *testing.T, lg *zap.Logger, clus *e2e.EtcdProcessCluster) error {
member := clus.Procs[rand.Int()%len(clus.Procs)]
return member.Restart(ctx)
}

func (f sigtermFailpoint) Name() string {
return "Terminate"
}

func (f sigtermFailpoint) Available(e2e.EtcdProcessClusterConfig, e2e.EtcdProcess) bool {
return true
}

0 comments on commit b97380f

Please sign in to comment.