Skip to content

Commit

Permalink
Implement terminate failpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
  • Loading branch information
serathius committed Nov 27, 2023
1 parent 62b772c commit 3881e06
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
3 changes: 2 additions & 1 deletion tests/robustness/failpoint/failpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const (

var (
allFailpoints = []Failpoint{
KillFailpoint, BeforeCommitPanic, AfterCommitPanic, RaftBeforeSavePanic, RaftAfterSavePanic,
ForcefulShutdown, BeforeCommitPanic, AfterCommitPanic, RaftBeforeSavePanic, RaftAfterSavePanic,
DefragBeforeCopyPanic, DefragBeforeRenamePanic, BackendBeforePreCommitHookPanic, BackendAfterPreCommitHookPanic,
BackendBeforeStartDBTxnPanic, BackendAfterStartDBTxnPanic, BackendBeforeWritebackBufPanic,
BackendAfterWritebackBufPanic, CompactBeforeCommitScheduledCompactPanic, CompactAfterCommitScheduledCompactPanic,
Expand All @@ -50,6 +50,7 @@ var (
DropPeerNetwork,
RaftBeforeSaveSleep,
RaftAfterSaveSleep,
GracefulShutdown,
}
)

Expand Down
28 changes: 22 additions & 6 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{}
ForcefulShutdown Failpoint = forcefulShutdownFailpoint{}
GracefulShutdown Failpoint = gracefulShutdownFailpoint{}
)

type killFailpoint struct{}
type forcefulShutdownFailpoint struct{}

func (f killFailpoint) Inject(ctx context.Context, t *testing.T, lg *zap.Logger, clus *e2e.EtcdProcessCluster) error {
func (f forcefulShutdownFailpoint) 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 {
return "Kill"
func (f forcefulShutdownFailpoint) Name() string {
return "forceful-shutdown"
}

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

type gracefulShutdownFailpoint struct{}

func (f gracefulShutdownFailpoint) 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 gracefulShutdownFailpoint) Name() string {
return "graceful-shutdown"
}

func (f gracefulShutdownFailpoint) Available(e2e.EtcdProcessClusterConfig, e2e.EtcdProcess) bool {
return true
}
2 changes: 1 addition & 1 deletion tests/robustness/scenarios.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func scenarios(t *testing.T) []testScenario {
})
scenarios = append(scenarios, testScenario{
name: "Issue13766",
failpoint: failpoint.KillFailpoint,
failpoint: failpoint.ForcefulShutdown,
profile: traffic.HighTrafficProfile,
traffic: traffic.EtcdPut,
cluster: *e2e.NewConfig(
Expand Down

0 comments on commit 3881e06

Please sign in to comment.