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 5201d18
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions tests/robustness/failpoint/failpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var (
RaftBeforeSaveSnapPanic, RaftAfterSaveSnapPanic, BlackholeUntilSnapshot,
beforeApplyOneConfChangeSleep,
MemberReplace,
TerminateFailpoint,
}
)

Expand Down
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 5201d18

Please sign in to comment.