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

x/pkgsite: ./all.bash should attempt to run postgres tests by default #39713

Closed
julieqiu opened this issue Jun 19, 2020 · 3 comments
Closed

x/pkgsite: ./all.bash should attempt to run postgres tests by default #39713

julieqiu opened this issue Jun 19, 2020 · 3 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. pkgsite
Milestone

Comments

@julieqiu
Copy link
Member

julieqiu commented Jun 19, 2020

Follow up to #39598:

When running ./all.bash, it's not clear whether the postgres tests are running or not. Users will just see that tests succeeded, even when the change results in postgres failures. For example, here's./all.bash output on the same patchset:

./all.bash output with postgres setup:
https://gist.github.com/julieqiu/c279934ee6054e7d5900274569c5c0d2

./all.bash output without postgres setup:
https://gist.github.com/bharaththiruveedula/dcfb9770fe99b3ecb8ee7891d8343631

I think we should do the following:

  • Run all tests by default
  • Provide users with an option to skip postgres tests
  • When running ./all.bash, first check if we can connect to the test databases, before running tests. If not, exit and inform users about the option to bypass postgres tests.

/cc @jba @mvdan @bharaththiruveedula

@gopherbot gopherbot added this to the Unreleased milestone Jun 19, 2020
@julieqiu julieqiu added pkgsite NeedsFix The path to resolution is known, but the work has not been done. labels Jun 19, 2020
@mvdan
Copy link
Member

mvdan commented Jun 19, 2020

Hmm, I'm not sure if I agree. This would once again break go test ./... on a clean clone.

It's true that some test successes are different from others, but that will generally be true for many other reasons. Some tests will require specific programs to be installed, or they might require Linux or Windows to run. Should all of those also fail unless they're actually running properly?

I think you should go the other way around. In all.bash, also run by CI, you could ensure that none of the portable tests are being skipped. You could do this with something like:

NO_DB_SKIP=true go test ./...

and in the Go code to handle the case where the DB isn't available:

if noDB {
    if os.Getenv("NO_DB_SKIP") != "true" {
        t.Fatal("some error")
    }
    t.Skip("skipping")
}

That way, you have the best of both worlds. It's possible for "run all the tests properly" to be done, and you're not messing with people who just want to run the tests on a best-effort basis.

A slight variant is what @bcmills suggested in the original issue, which is to make each TestMain start up a temporary postgres on-demand, and only do the skip-or-error dance when postgres isn't installed, which is less likely to be true than "postgres isn't running".

@julieqiu
Copy link
Member Author

Ah nice, thanks! I like the NO_DB_SKIP suggestion 👍

@jba jba self-assigned this Jun 22, 2020
@gopherbot
Copy link

Change https://golang.org/cl/239257 mentions this issue: all.bash,internal: force DB testing in CI

@golang golang locked and limited conversation to collaborators Jun 22, 2021
@rsc rsc unassigned jba Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. pkgsite
Projects
None yet
Development

No branches or pull requests

4 participants