-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
98851: roachtest: added connection timeout to loq recovery ops r=tbg a=aliher1911 When working with cluster that failed recovery, db connections could get stuck indefinitely preventing test completion. This is caused by driver ignoring context cancellation when attempting to establish connection. This commit adds a connect timeout option to the driver to prevent this behaviour. Epic: none Release note: None Fixes #98639 Co-authored-by: Oleg Afanasyev <[email protected]>
- Loading branch information
Showing
6 changed files
with
98 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2023 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package option | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestFirstOptionCreatesMap(t *testing.T) { | ||
var opts ConnOption | ||
o := ConnectionOption("a", "b") | ||
o(&opts) | ||
require.NotNil(t, opts.Options) | ||
} | ||
|
||
func TestTimeoutCalculation(t *testing.T) { | ||
var opts ConnOption | ||
for _, d := range []struct { | ||
t time.Duration | ||
o string | ||
}{ | ||
{ | ||
t: time.Second, | ||
o: "1", | ||
}, | ||
{ | ||
t: time.Millisecond, | ||
o: "1", | ||
}, | ||
{ | ||
t: time.Minute, | ||
o: "60", | ||
}, | ||
} { | ||
t.Run(d.t.String(), func(t *testing.T) { | ||
o := ConnectTimeout(d.t) | ||
o(&opts) | ||
require.Equal(t, d.o, opts.Options["connect_timeout"]) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters