Skip to content

Commit

Permalink
client: introduced test that restarts cluster and ensures that ongoin…
Browse files Browse the repository at this point in the history
…g Put finishes. Is flaky though

Signed-off-by: AngstyDuck <[email protected]>
  • Loading branch information
AngstyDuck committed Sep 6, 2023
1 parent 976cff5 commit 357f70d
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions tests/integration/clientv3/concurrency/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()}})
Expand All @@ -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() {
Expand All @@ -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")
}
}

0 comments on commit 357f70d

Please sign in to comment.