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

Tests: Fix t.Parallel() errors in data package #4981

Merged
merged 25 commits into from
Jan 9, 2023

Conversation

jdtzmn
Copy link
Contributor

@jdtzmn jdtzmn commented Jan 8, 2023

Summary

This PR parallelizes existing tests within the data package. Tests that could be parallelized and were missing the t.Parallel() demarcation have been fixed and tests that are unable to be parallelized were labelled accordingly.

This is the second PR of several that will reduce test times by parallelizing existing tests within the repository. My initial, basic benchmarking shows an average decrease in data package test times of at least 20%.

Test Plan

All existing data package tests passed locally and the golangci-lint paralleltest linter showed no paralleltest errors within the data package since the initial commit.

Confirming This Locally
First, remove the revision configuration:
...
-        new-from-rev: eb019291beed556ec6ac1ceb4a15114ce4df0c57~25
+        # new-from-rev: eb019291beed556ec6ac1ceb4a15114ce4df0c57~25
...

And remove the data package exclusion within the .golangci.yml:

...
-        - path: (agreement|catchup|cmd|config|crypto|daemon|data|gen|ledger|logging|netdeploy|network|node|protocol|rpcs|shared|stateproof|test|tools|util).*_test\.go
+        - path: (agreement|catchup|cmd|config|crypto|daemon|gen|ledger|logging|netdeploy|network|node|protocol|rpcs|shared|stateproof|test|tools|util).*_test\.go
...

Then run the paralleltest linter with the following command. If nothing is output, then no errors were found.

$ make lint 2>/dev/null | grep "data" | grep "paralleltest"

jdtzmn added 25 commits January 7, 2023 19:47
@jdtzmn jdtzmn force-pushed the paralleltest-data-package branch from 5944381 to 1243316 Compare January 8, 2023 00:47
@codecov
Copy link

codecov bot commented Jan 8, 2023

Codecov Report

Merging #4981 (1243316) into master (19fa6c2) will decrease coverage by 0.00%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #4981      +/-   ##
==========================================
- Coverage   53.65%   53.65%   -0.01%     
==========================================
  Files         432      432              
  Lines       54058    54058              
==========================================
- Hits        29007    29006       -1     
- Misses      22805    22809       +4     
+ Partials     2246     2243       -3     
Impacted Files Coverage Δ
ledger/tracker.go 75.10% <0.00%> (-4.65%) ⬇️
catchup/service.go 69.80% <0.00%> (+0.48%) ⬆️
util/rateLimit.go 83.33% <0.00%> (+0.98%) ⬆️
catchup/peerSelector.go 100.00% <0.00%> (+1.04%) ⬆️
ledger/testing/randomAccounts.go 56.88% <0.00%> (+1.22%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Contributor

@michaeldiamant michaeldiamant left a comment

Choose a reason for hiding this comment

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

@jdtzmn Thanks for your effort here! I successfully re-ran the build to improve my confidence that the changes do not introduce flakiness.

Based on my local runs, the PR reduces go test -count 1 ./data by ~20% (38s vs 31s).

I think more work is needed to vet CI improvements. As an aside, https://app.circleci.com/insights/github/algorand/go-algorand/workflows/circleci_build_and_test/overview?branch=master shows a significant increase in build time since 2023-01-06 (35min vs 20min).

@michaeldiamant
Copy link
Contributor

Merging - There's a large number of diffs making the PR susceptible to merge conflicts. We can address any further feedback in a follow on PR.

@michaeldiamant michaeldiamant merged commit c41cd69 into algorand:master Jan 9, 2023
@michaeldiamant
Copy link
Contributor

For future reviewer reference: A more robust local test is go test -race -count 1 ./data/....

The test I supplied in my earlier comment only tests ./data and not subpackages. Instead, ./data/... ought to be used.

@algorandskiy
Copy link
Contributor

For future reviewer reference: A more robust local test is go test -race -count 1 ./data/....

Use count > 1 as well since a parallel test should be runnable in parallel with self.

@michaeldiamant
Copy link
Contributor

My understanding is that go tests runs each count in isolation.

Nevertheless, my standard test is go test -race -count 10 ./data/.... At a minimum, I agree running with -count > 1 is important because it helps to isolate non-determinism.

gmalouf added a commit that referenced this pull request Jan 10, 2023
onetechnical pushed a commit that referenced this pull request Jan 10, 2023
gmalouf added a commit that referenced this pull request Jan 10, 2023
…stability. the changes here should net improve test reliability and rationale for why several are not marked parallel.
gmalouf added a commit that referenced this pull request Jan 10, 2023
…stability. the changes here should net improve test reliability and rationale for why several are not marked parallel.
gmalouf added a commit that referenced this pull request Jan 10, 2023
…stability. the changes here should net improve test reliability and rationale for why several are not marked parallel. (#4996)
winder pushed a commit to winder/go-algorand that referenced this pull request Jan 18, 2023
winder pushed a commit to winder/go-algorand that referenced this pull request Jan 18, 2023
winder pushed a commit to winder/go-algorand that referenced this pull request Jan 18, 2023
…ue to instability. the changes here should net improve test reliability and rationale for why several are not marked parallel. (algorand#4996)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants