Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing flaky TestLeasingDeleteRangeContendTxn #15401

Merged
merged 1 commit into from
Mar 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions tests/integration/clientv3/lease/leasing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package lease_test

import (
"context"
"errors"
"fmt"
"math/rand"
"reflect"
Expand Down Expand Up @@ -1270,7 +1271,8 @@ func testLeasingDeleteRangeContend(t *testing.T, op clientv3.Op) {
testutil.AssertNil(t, err)
defer closePutKV()

for i := 0; i < 8; i++ {
const maxKey = 8
for i := 0; i < maxKey; i++ {
key := fmt.Sprintf("key/%d", i)
if _, err = clus.Client(0).Put(context.TODO(), key, "123"); err != nil {
t.Fatal(err)
Expand All @@ -1282,14 +1284,17 @@ func testLeasingDeleteRangeContend(t *testing.T, op clientv3.Op) {

ctx, cancel := context.WithCancel(context.TODO())
donec := make(chan struct{})
go func() {
go func(t *testing.T) {
defer close(donec)
for i := 0; ctx.Err() == nil; i++ {
for i := 0; (i < maxKey) && (ctx.Err() == nil); i++ {
key := fmt.Sprintf("key/%d", i%8)
putkv.Put(ctx, key, "123")
putkv.Get(ctx, key)
if _, err = putkv.Put(ctx, key, "123"); err != nil {
if !errors.Is(err, context.Canceled) {
t.Errorf("fail putting key %s, err was: %v", key, err)
}
}
}
}()
}(t)

_, delErr := delkv.Do(context.TODO(), op)
cancel()
Expand All @@ -1299,7 +1304,7 @@ func testLeasingDeleteRangeContend(t *testing.T, op clientv3.Op) {
}

// confirm keys on non-deleter match etcd
for i := 0; i < 8; i++ {
for i := 0; i < maxKey; i++ {
key := fmt.Sprintf("key/%d", i)
resp, err := putkv.Get(context.TODO(), key)
if err != nil {
Expand Down