From 357f70dd63c0f6653025c9aa97f50f5e702d5807 Mon Sep 17 00:00:00 2001 From: AngstyDuck Date: Thu, 7 Sep 2023 01:25:14 +0800 Subject: [PATCH] client: introduced test that restarts cluster and ensures that ongoing Put finishes. Is flaky though Signed-off-by: AngstyDuck --- .../clientv3/concurrency/session_test.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/integration/clientv3/concurrency/session_test.go b/tests/integration/clientv3/concurrency/session_test.go index 562d4db6bdb5..8aad8df25ed9 100644 --- a/tests/integration/clientv3/concurrency/session_test.go +++ b/tests/integration/clientv3/concurrency/session_test.go @@ -145,13 +145,14 @@ func TestCreationTimeout(t *testing.T) { assert.Nil(t, err) } -// TestCreationTimeout checks that the option WithCreationTimeout -// sets a timeout for the creation of new sessions +// TestTimeoutDoesntAffectSubsequentConnections checks that the option WithCreationTimeout +// is only used when Session is created func TestTimeoutDoesntAffectSubsequentConnections(t *testing.T) { integration2.BeforeTest(t) // create new cluster clus := integration2.NewCluster(t, &integration2.ClusterConfig{Size: 1}) + defer clus.Terminate(t) // create new client cli, err := integration2.NewClient(t, clientv3.Config{Endpoints: []string{clus.Members[0].GRPCURL()}}) @@ -167,7 +168,7 @@ func TestTimeoutDoesntAffectSubsequentConnections(t *testing.T) { s, err := concurrency.NewSession(cli, concurrency.WithCreationTimeout(1*time.Second)) // terminating the cluster - clus.Terminate(t) + clus.Members[0].Terminate(t) donec := make(chan struct{}) go func() { @@ -182,4 +183,12 @@ func TestTimeoutDoesntAffectSubsequentConnections(t *testing.T) { // that timeout is not used by the Put operation case <-time.After(2 * time.Second): } + + // restarting and ensuring that the Put operation will eventually succeed + clus.Members[0].Restart(t) + select { + case <-donec: + case <-time.After(1 * time.Second): + t.Fatal("Put function hung even after restarting cluster") + } }