Open adamchalmers opened 3 months ago
Current plan is:
cargo run kcl-test-server
.Nextest has experimental support for setup scripts (docs, tracking issue: https://github.com/nextest-rs/nextest/issues/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: https://github.com/KittyCAD/modeling-app/pull/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!
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.