From 011d138809247d1bd6fad5bf71bef08ef84489f3 Mon Sep 17 00:00:00 2001 From: AngstyDuck Date: Thu, 7 Sep 2023 01:22:26 +0800 Subject: [PATCH] added test case where server is restarted and ongoing Put succeeds --- .../clientv3/concurrency/session_test.go | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/tests/integration/clientv3/concurrency/session_test.go b/tests/integration/clientv3/concurrency/session_test.go index 562d4db6bdb5..680cc9a9a2cc 100644 --- a/tests/integration/clientv3/concurrency/session_test.go +++ b/tests/integration/clientv3/concurrency/session_test.go @@ -15,17 +15,18 @@ package concurrency_test import ( - "context" + // "context" "testing" "time" - "github.com/stretchr/testify/assert" + // "github.com/stretchr/testify/assert" clientv3 "go.etcd.io/etcd/client/v3" "go.etcd.io/etcd/client/v3/concurrency" integration2 "go.etcd.io/etcd/tests/v3/framework/integration" clientv3test "go.etcd.io/etcd/tests/v3/integration/clientv3" ) +/* func TestSessionOptions(t *testing.T) { cli, err := integration2.NewClient(t, clientv3.Config{Endpoints: exampleEndpoints()}) if err != nil { @@ -144,14 +145,16 @@ func TestCreationTimeout(t *testing.T) { _, err = logOb.Expect(context.Background(), "Subchannel Connectivity change to TRANSIENT_FAILURE", 3) 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 +170,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 +185,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") + } }