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: local test speed optimizations, add cargo hack feature powerset #176

Merged
merged 5 commits into from
Sep 13, 2023

Conversation

cpu
Copy link
Member

@cpu cpu commented Sep 13, 2023

Recently our unit test runtime has been bogging down. Three tests in particular were slow relative to the rest: test_too_many_path_calls from verify_cert.rs, and the path building and name constraint test suites from the bettertls based integration test. Our entire project test suite minus those three tests completes in <0.5s. Running test_too_many_path_calls alone takes ~3s, and the better tls suite was ~8s.

This branch does a few things to remedy this:

  • It makes test_too_many_path_calls run faster by setting a lower build_chain_calls budget.
  • It makes the better tls test suite opt-in by ignoring both tests by default.
  • It updates CI to run ignored tests.
  • It adds a cargo hack feature powerset test to CI.

This should help keep regular development fast while still maintaining good coverage.

src/verify_cert.rs Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Sep 13, 2023

Codecov Report

Merging #176 (dc8f5d8) into main (2ed9a43) will decrease coverage by 0.38%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #176      +/-   ##
==========================================
- Coverage   96.69%   96.31%   -0.38%     
==========================================
  Files          17       17              
  Lines        4506     4510       +4     
==========================================
- Hits         4357     4344      -13     
- Misses        149      166      +17     
Files Changed Coverage Δ
src/verify_cert.rs 97.39% <100.00%> (-0.42%) ⬇️

... and 2 files with indirect coverage changes

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

@cpu cpu requested a review from djc September 13, 2023 01:40
Copy link
Member

@djc djc left a comment

Choose a reason for hiding this comment

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

Thanks for jumping on this, will definitely improve my life when working on webpki!

tests/better_tls.rs Outdated Show resolved Hide resolved
.github/workflows/daily-tests.yml Outdated Show resolved Hide resolved
src/verify_cert.rs Outdated Show resolved Hide resolved
The `test_too_many_path_calls` unit test artificially inflates the
budget for signature validation operations so that it can easily force
quadratic path building runtime, up to the default `build_chain_calls`
budget.

As a result this test takes a long time relative to our other unit
tests: it completes in ~3s while the entire project test suite without
this test and the bettertls tests in 0.6s.

This commit adjusts the test to use a lower-than-default
`build_chain_calls` budget. This lets us test the mechanics of the
budget are working as intended, without having to expend a lot of
runtime to run up the budget to the large default.
The Netflix bettertls test suite for pathbuilding and name constraint
validation take an outsized amount of runtime compared to our other
tests. These tests can take ~8s locally and the entire project test
suite with these tests ignored can be run in 0.6s.

This commit adds an `#[ignore]` flag so it won't be run by
default. We will opt-in to running this test in CI w/ `cargo test --
--ignored`.
The `better_tls` unit test in the `better_tls.rs` integration test
module was named before we added the `name_constraints` unit test. This
commit renames the `better_tls` unit test to `path_building` to reflect
that it runs the path building testsuite from bettertls.
We ignore the bettertls path building and name constraint test suites
because they take longer than the rest of the webpki test suite, bogging
down local development.

In the context of CI we don't mind that extra runtime (on the order of
~15..30s) so this commit updates the CI configuration to always run
ignored tests alongside the rest of the test suite.
This commit updates CI to use `cargo hack` to test the feature powerset,
ensuring that we can catch feature interplay related breakages early.

Unlike w/ the main Rustls repo the webpki powerset is small and the test
completes in <30s, so it's fair to include in the default CI instead of
needing to be separated into a separate daily tests workflow.
@cpu cpu changed the title tests: ignore slow tests, add daily tests config to CI tests: ignore bettertls locally, add cargo hack feature powerset Sep 13, 2023
@cpu cpu changed the title tests: ignore bettertls locally, add cargo hack feature powerset tests: local test speed optimizations, add cargo hack feature powerset Sep 13, 2023
@cpu
Copy link
Member Author

cpu commented Sep 13, 2023

Going to merge, but as always happy to tweak further.

@cpu cpu added this pull request to the merge queue Sep 13, 2023
Merged via the queue into rustls:main with commit 239a6e0 Sep 13, 2023
24 of 25 checks passed
@cpu cpu deleted the cpu-retain-quick-test-flow branch September 13, 2023 15:05
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