Third take on the FAF replay server, this time in Rust.
See docs/usage.rst. If you want to build the documentation, you'll need sphinx and dia.
To run database query unit tests, do the following:
- Setup a local database from faf-stack. See here.
- Clear the local database and load test data:
./test/clear_and_populate_db.sh <DB arguments to mysql>
- Run
cargo test
as follows:env DB_HOST=<db_host> DB_PORT=<db_port> cargo test --features local_db_tests
A few tests run outside cargo test
, since they manipulate process-global
state. You can run them like so:
cargo build --features process_tests
./test/run_process_tests.sh
Database queries are checked for correctness at compile time. You'll need to run FAF database from faf-stack and set DATABASE_URL env var to "mysql://root:[email protected]:3306/faf" for compilation to work.
Results of compile-time checking are saved to sqlx-data.json, which lets us compile on CI without setting up faf-stack. If you're changing DB queries, run the following command:
env DATABASE_URL="mysql://root:[email protected]:3306/faf" cargo sqlx prepare -- --lib
In order to regenerate the file.
To do code coverage, first configure grcov, as described at
https://github.com/mozilla/grcov. One this is done, run test/run_coverage.sh
.
Generated coverage is available under ./coverage.
- More tests in src/replay.
Code that needs no real improvement is marked with ✓.
├── accept ✓
├── config.rs ✓ (could add validation)
├── database ✓
├── error.rs ✓
├── main.rs ✓
├── metrics.rs ✓
├── process_test ✓
├── replay
│ ├── receive
│ │ ├── merger.rs
│ │ ├── merge_strategy.rs
│ │ ├── quorum_merge_strategy.rs
│ │ └── replay_delay.rs
│ ├── replay.rs ✓ (maybe more tests)
│ ├── replays.rs ✓
│ ├── save ✓
│ ├── send ✓
│ ├── streams
│ │ ├── header.rs ✓
│ │ ├── merged_replay_reader.rs
│ │ ├── merged_replay.rs
│ │ └── writer_replay.rs
│ └── runner.rs ✓
├── server
│ ├── connection.rs ✓
│ └── server.rs ✓ (maybe more tests)
├── util ✓
TL; DR the only thing that still feels bad is the whole state machine of replays.