Compare commits
1
Commits
next
...
dd4a3d85f4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dd4a3d85f4 |
No files matched your search
@@ -26,7 +26,11 @@ const (
|
|||||||
(SELECT 1 UNION ALL SELECT x + 1 FROM n)
|
(SELECT 1 UNION ALL SELECT x + 1 FROM n)
|
||||||
SELECT COUNT(*) FROM n`
|
SELECT COUNT(*) FROM n`
|
||||||
|
|
||||||
endlessQueryTimeout = 100 * time.Millisecond
|
// endlessQueryTimeout is how long the endless query runs
|
||||||
|
// before its context ends. A query whose context ends before
|
||||||
|
// it starts is never run, and the pool keeps its connection,
|
||||||
|
// so the timeout leaves a loaded host time to start it.
|
||||||
|
endlessQueryTimeout = 2 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestDefaultDBURLSetsWALAndBusyTimeout opens a file database
|
// TestDefaultDBURLSetsWALAndBusyTimeout opens a file database
|
||||||
|
|||||||
@@ -30,7 +30,10 @@ import (
|
|||||||
_ "modernc.org/sqlite"
|
_ "modernc.org/sqlite"
|
||||||
)
|
)
|
||||||
|
|
||||||
const testTimeout = 5 * time.Second
|
// testTimeout is how long a test waits for something before it
|
||||||
|
// fails. A passing test never waits this long, so it is generous
|
||||||
|
// enough for a heavily loaded host.
|
||||||
|
const testTimeout = 30 * time.Second
|
||||||
|
|
||||||
// testEnv holds the shared test infrastructure.
|
// testEnv holds the shared test infrastructure.
|
||||||
type testEnv struct {
|
type testEnv struct {
|
||||||
@@ -553,27 +556,49 @@ func TestQuietClientAnsweringPingStaysConnected(t *testing.T) {
|
|||||||
func TestQuietClientNotAnsweringPingIsClosed(t *testing.T) {
|
func TestQuietClientNotAnsweringPingIsClosed(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
// latest leaves room for a loaded host, but is sooner than
|
// A read deadline of two ping intervals would close the
|
||||||
// a read deadline of two ping intervals would close it.
|
// connection a second after latest. The ping interval is
|
||||||
|
// longer than testPingInterval, so that the time between
|
||||||
|
// the expected close and latest leaves room for a loaded
|
||||||
|
// host.
|
||||||
const (
|
const (
|
||||||
earliest = testPingInterval + testPongDeadline
|
interval = 4 * time.Second
|
||||||
latest = 2 * testPingInterval
|
earliest = interval + testPongDeadline
|
||||||
|
latest = 2*interval - time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
env := newTestEnvWithShortPings(t)
|
env := newTestEnvWithPingTimes(
|
||||||
|
t,
|
||||||
|
&config.Config{ServerName: testServerName},
|
||||||
|
interval, testPongDeadline,
|
||||||
|
)
|
||||||
client := env.dial(t)
|
client := env.dial(t)
|
||||||
|
|
||||||
lastSent := time.Now()
|
lastSent := time.Now()
|
||||||
|
|
||||||
client.register("silent")
|
client.register("silent")
|
||||||
client.readServerPing(lastSent)
|
|
||||||
|
// The server starts both waits once it has handled the
|
||||||
|
// registration, so the time registration took does not
|
||||||
|
// count against latest.
|
||||||
|
registered := time.Now()
|
||||||
|
|
||||||
|
client.readUntil(isServerPing)
|
||||||
client.readUntilClosed()
|
client.readUntilClosed()
|
||||||
|
|
||||||
waited := time.Since(lastSent)
|
waited := time.Since(lastSent)
|
||||||
if waited < earliest || waited >= latest {
|
if waited < earliest {
|
||||||
t.Errorf(
|
t.Errorf(
|
||||||
"closed %v after the client's last line, want %v to %v",
|
"closed %v after the client's last line, want at least %v",
|
||||||
waited, earliest, latest,
|
waited, earliest,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
sinceRegistered := time.Since(registered)
|
||||||
|
if sinceRegistered >= latest {
|
||||||
|
t.Errorf(
|
||||||
|
"closed %v after registration, want less than %v",
|
||||||
|
sinceRegistered, latest,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user