Skip to content
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

Fix flaky TestConnPrepareContext #1061

Merged
merged 1 commit into from Nov 7, 2021
Merged

Conversation

@mjl-
Copy link
Contributor

@mjl- mjl- commented Oct 19, 2021

TestConnPrepareContext checks it receives an context.DeadlineExceeded. However,
the context isn't necessarily always expired. This causes most of the test runs
to fail for me, only occasionally succeeding. This change ensures the context
used in the test is actually context.DeadlineExceeded. The negative duration
causes the context package to return an already canceled context.

TestConnPrepareContext checks it receives an context.DeadlineExceeded. However,
the context isn't necessarily always expired. This causes most of the test runs
to fail for me, only occasionally succeeding. This change ensures the context
used in the test is actually context.DeadlineExceeded. The negative duration
causes the context package to return an already canceled context.
@mjl-
Copy link
Contributor Author

@mjl- mjl- commented Oct 19, 2021

This is the result I am seeing (on lib/pq master, with go1.17.2 linux/amd64) without this PR applied:

$ PGHOST=localhost go test -count=1 -run TestConnPrepareContext github.com/lib/pq
--- FAIL: TestConnPrepareContext (0.01s)
    --- FAIL: TestConnPrepareContext/context.WithTimeout_exceeded (0.00s)
        conn_test.go:1854: conn.PrepareContext() unexpected nil err got = <nil>, exp
FAIL
FAIL    github.com/lib/pq       0.009s
FAIL

For completeness, I'm starting my postgres like this:

export PG=/usr/lib/postgresql/13
$PG/bin/initdb -D postgres13
$PG/bin/postgres -D postgres13 -p 5432 -k '' 2>&1 | tee postgres13/postgres.log
$PG/bin/createdb -h localhost pqgotest

@otan otan merged commit a54251e into lib:master Nov 7, 2021
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants