Closed rgee0 closed 5 days ago
Is there a way to do this via the CLI instead, to test each of the fixtures in parallel?
We took a look at this on the community call, and saw that the unit tests ran very quickly, even with -test.count
set to a higher number.
make e2e
will take longer due to network connections - it cannot be run in massive concurrency due to opening files, and network connections that could look like a DOS attack.
From the docs for the Go test command:
-p n
the number of programs, such as build commands or
test binaries, that can be run in parallel.
The default is the number of CPUs available.
The makefile should be updated to add i.e. -p 4
or similar to prevent the above.
Then I think it can make sense for the e2e tests to have the change, but I am not sure it's needed for the unit tests? Did you see differently?
func Test_CheckTools(t *testing.T) {
already runs with a t.Parallel
setting:
t.Run("Download of "+tool.Name, func(t *testing.T) {
t.Parallel()
quiet := true
Also - we could probably refine the Makefile target for e2e
to only run the fixture named Test_CheckTools
For instance, I ran this on a slow n100 machine:
time CGO_ENABLED=0 go test github.com/alexellis/arkade/pkg/get -cover --tags e2e -run "^Test_CheckTools$" -test.count=1
ok github.com/alexellis/arkade/pkg/get 26.350s coverage: 52.1% of statements
real 0m26.651s
user 0m2.154s
sys 0m0.556s
In parallel with 32 at the same time:
time CGO_ENABLED=0 go test github.com/alexellis/arkade/pkg/get -cover --tags e2e -run "^Test_CheckTools$" -test.count=1 -p 32
ok github.com/alexellis/arkade/pkg/get 15.121s coverage: 52.1% of statements
real 0m15.451s
user 0m2.063s
sys 0m0.588s
On my fast Ryzen machine with 16 cores 32 vCPU:
time CGO_ENABLED=0 go test github.com/alexellis/arkade/pkg/get -cover --tags e2e -run "^Test_CheckTools$" -test.count=1 -p 32
ok github.com/alexellis/arkade/pkg/get 2.000s coverage: 52.1% of statements
real 0m2.456s
user 0m2.509s
sys 0m0.746s
Reading more, it seems like test.count
- used to bust the test cache, disables parallel execution, but we have parallel execution already in place for the e2e tests.
The -parallel
option could also be set, but is already set to the max number of threads/cores in a machine:
https://engineering.mercari.com/en/blog/entry/20220408-how_to_use_t_parallel/
It seems like the best combination was:
time CGO_ENABLED=0 go test github.com/alexellis/arkade/pkg/get --tags e2e -run "^Test_CheckTools$" -parallel 32
Description
There is a significant number of tool tests and each test has multiple cases. This change enables
t.Parallel()
in an attempt to improve the speed of execution of the tests.Initial testing showed the elapsed time of make e2e reduced from ~12sec to ~7sec
Motivation and Context
design/approved
by a maintainer (required)How Has This Been Tested?
make e2e prior
make e2e post
Types of changes
Documentation
./arkade get --format markdown
./arkade install --help
Checklist:
git commit -s