-
Notifications
You must be signed in to change notification settings - Fork 0
Add test for Issue1567 #10
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
base: master
Are you sure you want to change the base?
Changes from all commits
00727fe
93f1a64
d05ec23
73abfe6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -20,6 +20,7 @@ import ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"io" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"log" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"math" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
mrand "math/rand" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"net" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"net/url" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"os" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -3577,3 +3578,35 @@ func runCallCommand(dbt *DBTest, query, name string) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
func TestIssue1567(t *testing.T) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// enable TLS. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
runTests(t, dsn+"&tls=skip-verify", func(dbt *DBTest) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// disable connection pooling. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// data race happens when new connection is created. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
dbt.db.SetMaxIdleConns(0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// estimate round trip time. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
start := time.Now() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if err := dbt.db.PingContext(context.Background()); err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
t.Fatal(err) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rtt := time.Since(start) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if rtt <= 0 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// In some environments, rtt may become 0, so set it to at least 1ms. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rtt = time.Millisecond | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+3584
to
+3598
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test function To enhance security, consider specifying TLS 1.3 as the minimum version. This change ensures that the connection uses the most secure and up-to-date protocol version, providing better security guarantees. tls.Config{ InsecureSkipVerify: true, +MinVersion: tls.VersionTLS13 } Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
count := 1000 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if testing.Short() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
count = 10 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
for i := 0; i < count; i++ { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
timeout := time.Duration(mrand.Int63n(int64(rtt))) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ctx, cancel := context.WithTimeout(context.Background(), timeout) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
dbt.db.PingContext(ctx) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cancel() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider enabling TLS 1.3 as the minimum version for enhanced security. This can be achieved by adding
MinVersion: tls.VersionTLS13
to the TLS configuration. This ensures that the connection uses the most secure and up-to-date protocol version.Committable suggestion