Skip to content

Commit

Permalink
tests: natively support nextest (tikv#12799)
Browse files Browse the repository at this point in the history
close tikv#12769

Signed-off-by: tabokie <xy.tao@outlook.com>
Signed-off-by: Xinye Tao <xy.tao@outlook.com>
  • Loading branch information
tabokie authored Jun 30, 2022
1 parent d356be1 commit ed1c6a0
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 11 deletions.
7 changes: 7 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[profile.ci]
retries = 1 # Run at most 2 times
fail-fast = false
slow-timeout = { period = "60s", terminate-after = 2 } # Timeout=120s

[profile.ci.junit]
path = "junit.xml"
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ make test
env EXTRA_CARGO_ARGS=$TESTNAME make test
```

Alternatively, you can use [nextest](https://github.com/nextest-rs/nextest) to run tests:

```bash
env EXTRA_CARGO_ARGS=$TESTNAME make test_with_nextest
```

TiKV follows the Rust community coding style. We use Rustfmt and [Clippy](https://github.com/Manishearth/rust-clippy) to automatically format and lint our code. Using these tools is checked in our CI. These are as part of `make dev`, you can also run them alone:

```bash
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,14 @@ run:
# Run tests under a variety of conditions. This should pass before
# submitting pull requests.
test:
./scripts/test-all -- --nocapture

# Run tests with nextest.
ifndef CUSTOM_TEST_COMMAND
test_with_nextest: export CUSTOM_TEST_COMMAND=nextest run
endif
test_with_nextest: export RUSTDOCFLAGS="-Z unstable-options --persist-doctests"
test_with_nextest:
./scripts/test-all

## Static analysis
Expand Down
10 changes: 6 additions & 4 deletions scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ set -euo pipefail
# Run from the Makefile environment
MAKEFILE_RUN=${MAKEFILE_RUN:-""}
if [[ -z $MAKEFILE_RUN ]] ; then
COMMAND="$0 $*" exec make run
COMMAND="$0 $*" exec make run
fi
SHELL_DEBUG=${SHELL_DEBUG:-""}
if [[ -n "$SHELL_DEBUG" ]] ; then
set -x
set -x
fi

DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH:-""}
LOCAL_DIR=${LOCAL_DIR:-""}
TIKV_ENABLE_FEATURES=${TIKV_ENABLE_FEATURES:-""}
CUSTOM_TEST_COMMAND=${CUSTOM_TEST_COMMAND:-"test"}
# EXTRA_CARGO_ARGS is unecessary now: this can just be given as arguments to ./scripts/test-all or ./scripts/test
EXTRA_CARGO_ARGS=${EXTRA_CARGO_ARGS:-""}

Expand All @@ -27,6 +28,7 @@ export DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH}:${LOCAL_DIR}/lib"
export LOG_LEVEL=DEBUG
export RUST_BACKTRACE=full

cargo test --workspace \
--exclude fuzzer-honggfuzz --exclude fuzzer-afl --exclude fuzzer-libfuzzer \
cargo $CUSTOM_TEST_COMMAND --workspace \
--exclude fuzz --exclude fuzzer-afl --exclude fuzzer-honggfuzz \
--exclude fuzzer-libfuzzer --exclude fuzz-targets \
--features "${TIKV_ENABLE_FEATURES}" ${EXTRA_CARGO_ARGS} "$@"
12 changes: 6 additions & 6 deletions scripts/test-all
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ set -euo pipefail
# Run from the Makefile environment
MAKEFILE_RUN=${MAKEFILE_RUN:-""}
if [[ -z $MAKEFILE_RUN ]] ; then
COMMAND="$0 $*" exec make run
COMMAND="$0 $*" exec make run
fi

./scripts/test "$@" -- --nocapture
./scripts/test "$@" && echo
# Re-run tests that requires specific environment variables.
if [[ "$(uname)" == "Linux" ]]; then
export MALLOC_CONF=prof:true
./scripts/test ifdef_malloc_conf "$@" -- --nocapture
./scripts/test ifdef_malloc_conf "$@" && echo
fi

if [[ "$(uname)" = "Linux" ]]; then
EXTRA_CARGO_ARGS="" ./scripts/test --message-format=json-render-diagnostics -q --no-run -- --nocapture |
python scripts/check-bins.py --features "${TIKV_ENABLE_FEATURES}" --check-tests
fi
CUSTOM_TEST_COMMAND="" EXTRA_CARGO_ARGS="" ./scripts/test --message-format=json-render-diagnostics -q --no-run |
python scripts/check-bins.py --features "${TIKV_ENABLE_FEATURES}" --check-tests
fi
2 changes: 2 additions & 0 deletions tests/failpoints/cases/test_split_region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,8 @@ fn test_split_pessimistic_locks_with_concurrent_prewrite() {
fail::remove("txn_before_process_write");
let resp = resp.join().unwrap();
assert!(resp.get_region_error().has_epoch_not_match(), "{:?}", resp);

fail::remove("on_split_invalidate_locks");
}

/// Logs are gced asynchronously. If an uninitialized peer is destroyed before being replaced by
Expand Down
3 changes: 2 additions & 1 deletion tests/failpoints/cases/test_unsafe_recovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,10 @@ fn test_unsafe_recovery_wait_for_snapshot_apply() {
sleep_ms(100);
}
assert_ne!(store_report, None);

fail::remove("worker_gc_raft_log");
fail::remove("worker_gc_raft_log_finished");
fail::remove("raft_before_apply_snap_callback");
fail::remove("region_apply_snap");
}

#[test]
Expand Down

0 comments on commit ed1c6a0

Please sign in to comment.