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

Speed up UI tests #342

Merged
merged 17 commits into from
Sep 26, 2024
Merged

Speed up UI tests #342

merged 17 commits into from
Sep 26, 2024

Conversation

LukeMathWalker
Copy link
Owner

@LukeMathWalker LukeMathWalker commented Sep 22, 2024

We currently have ~140 different test projects, with the fastest platform taking almost 10 minutes to run the whole UI test suite. That's not sustainable.
This PR significantly restructures pavex_test_runner, the custom test harness used to write UI tests for Pavex.

The main obstacle is cargo's locking system—each test needs to compile some crates (the generated app, sometimes an integration test) as well as generate some JSON documentation via rustdoc. All these activities compete for the lock.

This PR rearchitects pavex_test_runner to minimise lock contention and maximise core usage.
In particular:

  • All JSON docs are generated upfront, in batch, ensuring that each test hits the SQLite cache rather than invoking cargo directly, thus avoid contention;
  • All UI tests now live in the same (separate) workspace, under ui_tests. They share a single target folder and their features are unified via a dedicated workspace hack crate. This ensures that we get full cache re-use across tests.
  • All compilation jobs (e.g. generated apps or integration tests) are batched to maximise core utilisation

The speed-up has been substantial. In CI, we now run UI tests on Linux in ~7m compared to the ~11m we were seeing on main. The difference is even more extreme on Windows: from 16m to 9m. We also scored further wins there, by carving out some particularly slow tests, saving 5 minutes on executing unit tests.

Some leftover work to be done in followup PRs:

  • Fix all warnings in UI test code
  • Ensure that all test_config.toml files are only using valid keys
  • Enforce programmatically the crate naming structure ({prefix}_{hash}) to avoid divergence over time
  • Add utilities to generate the scaffolding for a new test

@LukeMathWalker
Copy link
Owner Author

/ok-to-test sha=7ea7aa7

@LukeMathWalker
Copy link
Owner Author

/ok-to-test sha=e248d9d

@LukeMathWalker
Copy link
Owner Author

/ok-to-test sha=e617916

@LukeMathWalker
Copy link
Owner Author

/ok-to-test sha=a14b195

@LukeMathWalker
Copy link
Owner Author

/ok-to-test sha=07a0248

@LukeMathWalker
Copy link
Owner Author

/ok-to-test sha=0bef47b

@LukeMathWalker LukeMathWalker marked this pull request as ready for review September 26, 2024 13:28
@LukeMathWalker LukeMathWalker merged commit c6f10c5 into main Sep 26, 2024
22 checks passed
@LukeMathWalker LukeMathWalker deleted the faster-tests branch September 26, 2024 13:28
@pavex-releaser pavex-releaser bot mentioned this pull request Oct 23, 2024
LukeMathWalker added a commit that referenced this pull request Oct 23, 2024
## 🤖 New release
* `pavex`: 0.1.48 -> 0.1.49
* `pavex_bp_schema`: 0.1.48 -> 0.1.49
* `pavex_reflection`: 0.1.48 -> 0.1.49
* `pavex_macros`: 0.1.48 -> 0.1.49
* `persist_if_changed`: 0.1.48 -> 0.1.49
* `pavex_tracing`: 0.1.48 -> 0.1.49
* `pavex_cli`: 0.1.48 -> 0.1.49
* `pavex_cli_deps`: 0.1.48 -> 0.1.49
* `pavex_miette`: 0.1.48 -> 0.1.49
* `pavexc_cli_client`: 0.1.48 -> 0.1.49
* `pavexc`: 0.1.48 -> 0.1.49
* `pavex_cli_client`: 0.1.48 -> 0.1.49
* `pavex_session`: 0.1.48 -> 0.1.49
* `pavex_session_memory_store`: 0.1.48 -> 0.1.49
* `pavexc_cli`: 0.1.48 -> 0.1.49
* `generate_from_path`: 0.1.48 -> 0.1.49

<details><summary><i><b>Changelog</b></i></summary><p>

## `pavex`
<blockquote>

##
[0.1.49](0.1.48...0.1.49)
- 2024-10-23

### Added

- Distinguish between methods and functions in error messages
([#344](#344))
- Start caching path dependencies. Use the hash of their contents to
avoid serving stale data
- Pavex deduplicates diagnostics, thus reducing visual noise when code
generation fails

### Fixed

- Pavex always uses a public path to refer to public items, even if they
are defined in a private module
- Detect infinite paths and break early to avoid stalls when generating
server SDK crates
- Ensure error observers are correctly added when dealing with errors in
the call graph of a middleware of any kind
- Perform cross-call-graph analysis to determine if additional .clone()
statements are needed before invoking a middleware.
- Don't discard spans if they match the provided log filter in pavexc

### Other

- update Cargo.toml dependencies
- Disable workspace hack before a release
- Formatting
- Speed up UI tests
([#342](#342))
- Update to latest cargo-deny
([#339](#339))
- HTTP sessions
([#338](#338))
- Update dependencies to latest possible version. In particular, update
'rustdoc-types' and the nightly version used by 'pavexc'
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/MarcoIeni/release-plz/).

---------

Co-authored-by: pavex-releaser[bot] <ci@pavex.dev>
Co-authored-by: pavex-releaser[bot] <167640712+pavex-releaser[bot]@users.noreply.github.com>
Co-authored-by: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com>
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.

1 participant