-
Notifications
You must be signed in to change notification settings - Fork 20
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
Rust tests should use 1 engine instance #2580
Comments
Current plan is:
Nextest has experimental support for setup scripts (docs, tracking issue: nextest-rs/nextest#978). If we use it, then Nextest would automatically start the test server if you run a test that requires it. Could be nice. If we don't want to use the experimental nextest feature, then we just kcl-test-server in GitHub Actions, and print a nice error message in the unit tests if the server isn't found. I've got a POC here: #2627 |
Good news, on my POC, tests run in only 56% of the time they used to take (2.4s vs 1.4s). This adds up to quite a lot of savings when spread over 100 tests! |
Adds a new library, the kcl-test-server. It lets you easily start a HTTP server with one endpoint, which accepts JSON. The JSON body contains a KCL program and a test name. The server has a pool of active engine sessions, and when it gets a KCL program, it executes it on one of those engine sessions. This addresses part of #2580 but currently the sketch-on-face tests don't pass with this new test server yet. This is a library, not a binary, because I want to use it in both the wasm-lib unit tests and in the zoo CLI.
Background
Currently every Rust unit test creates a new kittycad client, starting a new session with the engine.
Problem
This seems inefficient -- it would add a lot of latency from starting and stopping engine sessions.
Solution
Before running any tests, start a test server. The test server has one HTTP endpoint which takes a KCL program, executes it, and responds with a PNG snapshot. It does this by running a KCL executor.
Each test, instead of making its own KCL executor, just sends programs to this HTTP server. This way our suite of 100 tests only connects to the engine once, instead of 100 times -- should be much faster.
The text was updated successfully, but these errors were encountered: