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

tests: deflakey TestLeaseGrantTimeToLiveExpired #19476

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fuweid
Copy link
Member

@fuweid fuweid commented Feb 24, 2025

The following change can reproduce the issue #17504 by TESTCASE=TestLeaseGrantTimeToLiveExpired/PeerAutoTLS make test-e2e. We can retry it to reduce flakey possibility, if there is leader change.

diff --git a/tests/common/lease_test.go b/tests/common/lease_test.go
index afb27c330..dea8459dc 100644
--- a/tests/common/lease_test.go
+++ b/tests/common/lease_test.go
@@ -16,6 +16,7 @@ package common

 import (
        "context"
+       "sync"
        "testing"
        "time"

@@ -139,6 +140,18 @@ func TestLeaseGrantTimeToLiveExpired(t *testing.T) {
                                require.NoError(t, err)
                                require.Equal(t, int64(1), getResp.Count)

+                               var wg sync.WaitGroup
+                               defer wg.Wait()
+
+                               wg.Add(1)
+                               go func() {
+                                       defer wg.Done()
+                                       time.Sleep(1000 * time.Millisecond)
+                                       clus.(interface {
+                                               MoveLeader(ctx context.Context, t testing.TB, i int) error
+                                       }).MoveLeader(ctx, t, (clus.WaitLeader(t)+1)%len(clus.Members()))
+                               }()
+
                                time.Sleep(3 * time.Second)

                                ttlResp, err := cc.TimeToLive(ctx, leaseResp.ID, config.LeaseOption{})

Please read https://github.com/etcd-io/etcd/blob/main/CONTRIBUTING.md#contribution-flow.

@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: fuweid
Once this PR has been reviewed and has the lgtm label, please assign jmhbnz for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@fuweid
Copy link
Member Author

fuweid commented Feb 24, 2025

The following change can reproduce the issue etcd-io#17504 by
`TESTCASE=TestLeaseGrantTimeToLiveExpired/PeerAutoTLS make test-e2e`. We
can retry it to reduce flakey possibility, if there is leader change.

```diff
diff --git a/tests/common/lease_test.go b/tests/common/lease_test.go
index afb27c330..dea8459dc 100644
--- a/tests/common/lease_test.go
+++ b/tests/common/lease_test.go
@@ -16,6 +16,7 @@ package common

 import (
        "context"
+       "sync"
        "testing"
        "time"

@@ -139,6 +140,18 @@ func TestLeaseGrantTimeToLiveExpired(t *testing.T) {
                                require.NoError(t, err)
                                require.Equal(t, int64(1), getResp.Count)

+                               var wg sync.WaitGroup
+                               defer wg.Wait()
+
+                               wg.Add(1)
+                               go func() {
+                                       defer wg.Done()
+                                       time.Sleep(1000 * time.Millisecond)
+                                       clus.(interface {
+                                               MoveLeader(ctx context.Context, t testing.TB, i int) error
+                                       }).MoveLeader(ctx, t, (clus.WaitLeader(t)+1)%len(clus.Members()))
+                               }()
+
                                time.Sleep(3 * time.Second)

                                ttlResp, err := cc.TimeToLive(ctx, leaseResp.ID, config.LeaseOption{})

```

Signed-off-by: Wei Fu <fuweid89@gmail.com>
Copy link

codecov bot commented Feb 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.91%. Comparing base (d83346b) to head (c81fb87).
Report is 1 commits behind head on main.

Additional details and impacted files

see 17 files with indirect coverage changes

@@            Coverage Diff             @@
##             main   #19476      +/-   ##
==========================================
- Coverage   69.07%   68.91%   -0.17%     
==========================================
  Files         420      420              
  Lines       35762    35762              
==========================================
- Hits        24704    24646      -58     
- Misses       9647     9690      +43     
- Partials     1411     1426      +15     

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 498bbc5...c81fb87. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants