tests: Separate retries count from failure trigger count

Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
dependabot/go_modules/go.uber.org/atomic-1.10.0
Marek Siarkowicz 2022-12-02 16:05:56 +01:00
parent df2d075e1a
commit 7f70b8cf76
1 changed files with 5 additions and 3 deletions

View File

@ -79,6 +79,7 @@ func TestLinearizability(t *testing.T) {
failpoint := FailpointConfig{ failpoint := FailpointConfig{
failpoint: tc.failpoint, failpoint: tc.failpoint,
count: 1, count: 1,
retries: 3,
waitBetweenTriggers: waitBetweenFailpointTriggers, waitBetweenTriggers: waitBetweenFailpointTriggers,
} }
traffic := trafficConfig{ traffic := trafficConfig{
@ -119,7 +120,7 @@ func triggerFailpoints(ctx context.Context, t *testing.T, clus *e2e.EtcdProcessC
var err error var err error
successes := 0 successes := 0
failures := 0 failures := 0
for successes < config.count && failures < config.count { for successes < config.count && failures < config.retries {
time.Sleep(config.waitBetweenTriggers) time.Sleep(config.waitBetweenTriggers)
err = config.failpoint.Trigger(t, ctx, clus) err = config.failpoint.Trigger(t, ctx, clus)
if err != nil { if err != nil {
@ -129,16 +130,17 @@ func triggerFailpoints(ctx context.Context, t *testing.T, clus *e2e.EtcdProcessC
} }
successes++ successes++
} }
time.Sleep(config.waitBetweenTriggers) if successes < config.count || failures >= config.retries {
if successes < config.count || failures >= config.count {
return fmt.Errorf("failed to trigger failpoints enough times, err: %v", err) return fmt.Errorf("failed to trigger failpoints enough times, err: %v", err)
} }
time.Sleep(config.waitBetweenTriggers)
return nil return nil
} }
type FailpointConfig struct { type FailpointConfig struct {
failpoint Failpoint failpoint Failpoint
count int count int
retries int
waitBetweenTriggers time.Duration waitBetweenTriggers time.Duration
} }