Behavior tests are used to make sure every service works correctly.
To support different testing backends simultaneously, we use environment value to carry the backend config.
Currently, opendal uses Docker to set up environment for behaviour tests. If you are a MacOS user, The docker does not work properly by default(Docker Desktop) in the MacOS environment. It is strongly recommended to use OrbStack instead of Docker Desktop. You can install orbstack using Homebrew.
brew install orbstackTo run the behavior tests, please copy the .env.example, which is at project root, to .env and change the values on need.
Take fs for example, we need to change to enable behavior test on fs on /tmp.
OPENDAL_FS_ROOT=/path/to/dir/into
OPENDAL_FS_ROOT=/tmp/
Notice: If the env variables are not set, all behavior tests will be skipped by default.
Use OPENDAL_TEST to control which service to test:
OPENDAL_TEST=fs cargo test behavior --features testsTo run certain types of tests(such as write), we use behavior::test_write.
OPENDAL_TEST=fs cargo test behavior::test_write --features testsYou can also run specific test(such as test_stat_dir) for specific backend.
OPENDAL_TEST=fs cargo test behavior::test_stat_dir --features testsTo debug a behavior test, you can:
- Add env
RUST_LOG=debugto enable logging - Add env
RUST_BACKTRACE=fullto enable the full backtrace - Add
--show-outputto show the whole output even when test succeeded.
Take memory service as an example, the full command will be:
RUST_LOG=debug RUST_BACKTRACE=full OPENDAL_TEST=memory cargo test behavior --features tests -- --show-outputYou use export to avoid set env every time:
export RUST_LOG=debug
export RUST_BACKTRACE=full
OPENDAL_TEST=memory cargo test behavior --features tests -- --show-outputFor more details, please visit cargo test or run the command cargo test --help.