Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

test: ignore bad connection errors for TestServer cases that don't use the db#19957

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
spikecurtis merged 1 commit intomainfromspike/internal-946-bad-connection
Sep 26, 2025
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletionscli/server_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,6 +10,7 @@ import (
"crypto/tls"
"crypto/x509"
"crypto/x509/pkix"
"database/sql/driver"
"encoding/json"
"encoding/pem"
"fmt"
Expand All@@ -35,6 +36,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/goleak"
"golang.org/x/xerrors"
"gopkg.in/yaml.v3"
"tailscale.com/derp/derphttp"
"tailscale.com/types/key"
Expand DownExpand Up@@ -1836,7 +1838,7 @@ func TestServer_Logging_NoParallel(t *testing.T) {
// fails.
pty := ptytest.New(t).Attach(inv)

clitest.Start(t, inv.WithContext(ctx))
startIgnoringPostgresQueryCancel(t, inv.WithContext(ctx))

// Wait for server to listen on HTTP, this is a good
// starting point for expecting logs.
Expand DownExpand Up@@ -1873,7 +1875,7 @@ func TestServer_Logging_NoParallel(t *testing.T) {
// fails.
pty := ptytest.New(t).Attach(inv)

clitest.Start(t, inv)
startIgnoringPostgresQueryCancel(t, inv)

// Wait for server to listen on HTTP, this is a good
// starting point for expecting logs.
Expand DownExpand Up@@ -2397,6 +2399,13 @@ func startIgnoringPostgresQueryCancel(t *testing.T, inv *serpent.Invocation) {
if database.IsQueryCanceledError(err) {
return
}
// specifically when making our initial connection to PostgreSQL, we ping the database.
// Database driver.Conn instances can return driver.ErrBadConn on ping to remove the connection from the pool.
// lib/pq does this no matter what the error is, including context.Canceled.
// c.f. https://pkg.go.dev/database/sql/driver#Pinger
if xerrors.Is(err, driver.ErrBadConn) {
return
}
assert.NoError(t, err)
})
}
Loading

[8]ページ先頭

©2009-2025 Movatter.jp