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

skip tests when -short #12869

Merged
merged 1 commit into from
Apr 18, 2024
Merged

skip tests when -short #12869

merged 1 commit into from
Apr 18, 2024

Conversation

jmank88
Copy link
Contributor

@jmank88 jmank88 commented Apr 17, 2024

Running go test -short used to skip all DB dependent tests, among others. This PR restores that behavior, and tweaks a few others things that have made it difficult to run -short. Now go test -short ./... completes in ~40s, and just ~10s if cached.

I also added an early step to the ci-core workflow to execute these tests as a spot check. This will provide quicker feedback than waiting for the full suite to fail, and shouldn't actually cost us any extra time in theory 🧮

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parent test would fail with -short because it registered expectations that a sub-test fulfills, and only the sub-tests are skipped.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Evidently you can't call testing.Short() from a func init(), but this works the same.

main_test.go Outdated
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these use the DB, but mostly they can just be slow.

@pavel-raykov
Copy link
Collaborator

pavel-raykov commented Apr 18, 2024

Running go test -short used to skip all DB dependent tests, among others. This PR restores that behavior, and tweaks a few others things that have made it difficult to run -short. Now go test -short ./... completes in ~1 minutes, and just ~10s if cached.

Btw, if someone writes a new DB-dependent test, is there any way for them to recognize that they should also probably use the "SkipShortDB" method in their test? For example, do we run "go test -short" on presubmit [if yes, can we fail if it takes significantly longer than before]?

@jmank88
Copy link
Contributor Author

jmank88 commented Apr 18, 2024

Running go test -short used to skip all DB dependent tests, among others. This PR restores that behavior, and tweaks a few others things that have made it difficult to run -short. Now go test -short ./... completes in ~1 minutes, and just ~10s if cached.

Btw, if someone writes a new DB-dependent test, is there any way for them to recognize that they should also probably use the "SkipShortDB" method in their test? For example, do we run "go test -short" on presubmit [if yes, can we fail if it takes significantly longer than before]?

I was hoping to run it in CI so they would see it when they push. I reduced the runtime from 60s to 40s, which might be OK for CI, but still seems quite slow for a presumbit hook 🤔

@pavel-raykov
Copy link
Collaborator

Running go test -short used to skip all DB dependent tests, among others. This PR restores that behavior, and tweaks a few others things that have made it difficult to run -short. Now go test -short ./... completes in ~1 minutes, and just ~10s if cached.

Btw, if someone writes a new DB-dependent test, is there any way for them to recognize that they should also probably use the "SkipShortDB" method in their test? For example, do we run "go test -short" on presubmit [if yes, can we fail if it takes significantly longer than before]?

I was hoping to run it in CI so they would see it when they push. I reduced the runtime from 60s to 40s, which might be OK for CI, but still seems quite slow for a presumbit hook 🤔

Sorry, is it possible to see how long the presubmit takes now on average.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This takes a little over 1 minute to run. However, the net time added should be much less, and could be 0, since several things are cached, meaning that time spent here is saved later:

  • downloading deps
  • compiling packages
  • tests results

@cl-sonarqube-production
Copy link

@jmank88
Copy link
Contributor Author

jmank88 commented Apr 18, 2024

Sorry, is it possible to see how long the presubmit takes now on average.

I was thinking about git pre-commit hooks. Do you mean something in the CI pipeline?

@jmank88 jmank88 marked this pull request as ready for review April 18, 2024 15:50
@jmank88 jmank88 requested review from a team as code owners April 18, 2024 15:50
@jmank88 jmank88 added this pull request to the merge queue Apr 18, 2024
Merged via the queue into develop with commit aa57182 Apr 18, 2024
105 checks passed
@jmank88 jmank88 deleted the short branch April 18, 2024 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants