Skip to content

Commit 4ea6ef6

Browse files
authored
*: speed up test build (tikv#7012)
Tests has been built slowly lately. That's because we use multiple compile command to build tests for different crates. Things go worse when cdc is split as a component. On my local machine, running `make test`, cargo will be invoked 6 times. 4 of them takes minutes to finish. The reason why we try to run multiple compile command is to get around the problem mentioned in tikv#6097, which is introduced when trying to support prost and protobuf in tests at the same time. But in practice, we don't run tests with prost. Hence overhead is introduced with just potential benefit. In fact, after tikv#6317, it's impossible to run tests by `PROST=1 make test` due to rust-lang/cargo#6669. It's still possible to build, clippy check or release with prost. Given that tests with PROST=1 does not work, this PR combines all the cargo commands into single one, which save a lot of compile time. Signed-off-by: Jay Lee <[email protected]>
1 parent 6c7d159 commit 4ea6ef6

File tree

4 files changed

+16
-27
lines changed

4 files changed

+16
-27
lines changed

Makefile

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ docker-tag-with-git-tag:
215215
# Run tests under a variety of conditions. This should pass before
216216
# submitting pull requests. Note though that the CI system tests TiKV
217217
# through its own scripts and does not use this rule.
218-
test:
218+
.PHONY: run-test
219+
run-test:
219220
# When SIP is enabled, DYLD_LIBRARY_PATH will not work in subshell, so we have to set it
220221
# again here. LOCAL_DIR is defined in .travis.yml.
221222
# The special linux case below is testing the mem-profiling
@@ -227,31 +228,15 @@ test:
227228
export DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH}:${LOCAL_DIR}/lib" && \
228229
export LOG_LEVEL=DEBUG && \
229230
export RUST_BACKTRACE=1 && \
230-
cargo test --no-default-features --features "${ENABLE_FEATURES}" --all --exclude tests --exclude \
231-
cdc --exclude fuzz-targets --exclude fuzzer-honggfuzz --exclude fuzzer-afl --exclude fuzzer-libfuzzer \
232-
${EXTRA_CARGO_ARGS} -- --nocapture && \
233-
cd tests && cargo test --features "${ENABLE_FEATURES}" ${EXTRA_CARGO_ARGS} -- --nocapture && cd .. && \
234-
cargo test --no-default-features --features "${ENABLE_FEATURES}" -p tests --bench misc ${EXTRA_CARGO_ARGS} -- --nocapture && \
235-
cd components/cdc && cargo test --no-default-features --features "${ENABLE_FEATURES}" -p cdc ${EXTRA_CARGO_ARGS} -- --nocapture && cd ../.. && \
236-
cd components/cdc && cargo test --no-default-features --features "${ENABLE_FEATURES}" ${EXTRA_CARGO_ARGS} -- --nocapture && cd ../.. && \
231+
cargo test --workspace --features "${ENABLE_FEATURES} mem-profiling" ${EXTRA_CARGO_ARGS} -- --nocapture && \
237232
if [[ "`uname`" == "Linux" ]]; then \
238233
export MALLOC_CONF=prof:true,prof_active:false && \
239-
cargo test --no-default-features --features "${ENABLE_FEATURES},mem-profiling" ${EXTRA_CARGO_ARGS} --bin tikv-server -- --nocapture --ignored; \
234+
cargo test --features "${ENABLE_FEATURES} mem-profiling" ${EXTRA_CARGO_ARGS} -p tikv_alloc -- --nocapture --ignored; \
240235
fi
241-
bash scripts/check-bins-for-jemalloc.sh
242-
bash scripts/check-udeps.sh
243-
244-
# This is used for CI test
245-
ci_test: ci_doc_test
246-
cargo test --no-default-features --features "${ENABLE_FEATURES}" --all --exclude tests --exclude cdc \
247-
--exclude fuzz-targets --exclude fuzzer-honggfuzz --exclude fuzzer-afl --exclude fuzzer-libfuzzer \
248-
--all-targets --no-run --message-format=json
249-
cd tests && cargo test --no-default-features --features "${ENABLE_FEATURES}" --no-run --message-format=json
250-
cd components/cdc && cargo test --no-default-features --features "${ENABLE_FEATURES}" --no-run --message-format=json
251236

252-
ci_doc_test:
253-
cargo test --no-default-features --features "${ENABLE_FEATURES}" --all --exclude tests --exclude cdc \
254-
--exclude fuzz-targets --exclude fuzzer-honggfuzz --exclude fuzzer-afl --exclude fuzzer-libfuzzer --doc
237+
.PHONY: test
238+
test: run-test
239+
bash scripts/check-bins-for-jemalloc.sh
255240

256241
## Static analysis
257242
## ---------------
@@ -308,6 +293,10 @@ pre-audit:
308293
audit: pre-audit
309294
cargo audit
310295

296+
.PHONY: check-udeps
297+
check-udeps:
298+
bash scripts/check-udeps.sh
299+
311300
FUZZER ?= Honggfuzz
312301

313302
.PHONY: fuzz

components/sst_importer/src/sst_importer.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -917,8 +917,6 @@ mod tests {
917917
.unwrap()
918918
.unwrap();
919919

920-
dbg!(&range);
921-
922920
assert_eq!(range.get_start(), b"t123_r01");
923921
assert_eq!(range.get_end(), b"t123_r13");
924922

components/tikv_alloc/src/jemalloc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,11 @@ mod profiling {
161161

162162
let os_path = dir.path().to_path_buf().join("test1.dump").into_os_string();
163163
let path = os_path.into_string().unwrap();
164-
super::dump_prof(&path);
164+
super::dump_prof(&path).unwrap();
165165

166166
let os_path = dir.path().to_path_buf().join("test2.dump").into_os_string();
167167
let path = os_path.into_string().unwrap();
168-
super::dump_prof(&path);
168+
super::dump_prof(&path).unwrap();
169169

170170
let files = fs::read_dir(dir.path()).unwrap().count();
171171
assert_eq!(files, 2);

tests/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ path = "benches/hierarchy/mod.rs"
3232
[[bench]]
3333
name = "misc"
3434
path = "benches/misc/mod.rs"
35+
test = true
3536

3637
[[bench]]
3738
name = "deadlock_detector"
@@ -41,9 +42,10 @@ path = "benches/deadlock_detector/mod.rs"
4142
[[bench]]
4243
name = "channel"
4344
path = "benches/channel/mod.rs"
45+
test = true
4446

4547
[features]
46-
default = ["failpoints", "testexport"]
48+
default = ["failpoints", "testexport", "protobuf-codec"]
4749
failpoints = ["fail/failpoints", "tikv/failpoints"]
4850
testexport = ["raftstore/testexport", "tikv/testexport"]
4951
profiling = ["profiler/profiling"]

0 commit comments

Comments
 (0)