Skip to content

Commit 32b0cff

Browse files
authored
tests: Improve integration tests (#481)
Signed-off-by: Ping Yu <[email protected]>
1 parent 070af41 commit 32b0cff

File tree

5 files changed

+42
-12
lines changed

5 files changed

+42
-12
lines changed

.github/workflows/ci.yml

+19-4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
name: unit test
3636
env:
3737
CARGO_INCREMENTAL: 0
38+
NEXTEST_PROFILE: ci
3839
runs-on: ubuntu-latest
3940
steps:
4041
- uses: actions/checkout@v4
@@ -52,8 +53,14 @@ jobs:
5253

5354
integration-test:
5455
name: integration test
56+
strategy:
57+
fail-fast: false
58+
matrix:
59+
case: ["integration-test-txn", "integration-test-raw"]
5560
env:
5661
CARGO_INCREMENTAL: 0
62+
NEXTEST_PROFILE: ci
63+
TIKV_VERSION: v8.5.1
5764
runs-on: ubuntu-latest
5865
steps:
5966
- uses: actions/checkout@v4
@@ -69,14 +76,22 @@ jobs:
6976
- name: start tiup playground
7077
run: |
7178
# use latest stable version
72-
~/.tiup/bin/tiup install tikv pd
73-
~/.tiup/bin/tiup playground --mode tikv-slim --kv 3 --without-monitor --kv.config config/tikv.toml --pd.config config/pd.toml &
79+
~/.tiup/bin/tiup install tikv:${{ env.TIKV_VERSION }} pd:${{ env.TIKV_VERSION }}
80+
~/.tiup/bin/tiup playground ${{ env.TIKV_VERSION }} --mode tikv-slim --kv 3 --tag cluster --without-monitor --kv.config config/tikv.toml --pd.config config/pd.toml &
7481
while :; do
7582
echo "waiting cluster to be ready"
7683
[[ "$(curl -I http://127.0.0.1:2379/pd/api/v1/regions 2>/dev/null | head -n 1 | cut -d$' ' -f2)" -ne "405" ]] || break
7784
sleep 1
7885
done
7986
- name: Install latest nextest release
8087
uses: taiki-e/install-action@nextest
81-
- name: integration test
82-
run: MULTI_REGION=1 make integration-test
88+
- name: Integration test
89+
run: MULTI_REGION=1 make ${{ matrix.case }}
90+
- name: Upload logs
91+
if: failure()
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: cluster-logs
95+
path: |
96+
~/.tiup/data/cluster/tikv*/*.log
97+
~/.tiup/data/cluster/pd*/*.log

Makefile

+14-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
export RUSTFLAGS=-Dwarnings
22

3-
.PHONY: default check unit-test integration-tests test doc docker-pd docker-kv docker all
3+
.PHONY: default check unit-test generate integration-tests integration-tests-txn integration-tests-raw test doc docker-pd docker-kv docker all
44

55
export PD_ADDRS ?= 127.0.0.1:2379
66
export MULTI_REGION ?= 1
77

88
ALL_FEATURES := integration-tests
99

10-
INTEGRATION_TEST_ARGS := --features "integration-tests"
10+
NEXTEST_ARGS := --config-file $(shell pwd)/config/nextest.toml
11+
12+
INTEGRATION_TEST_ARGS := --features "integration-tests" --test-threads 1
13+
14+
RUN_INTEGRATION_TEST := cargo nextest run ${NEXTEST_ARGS} --all ${INTEGRATION_TEST_ARGS}
1115

1216
default: check
1317

@@ -20,12 +24,15 @@ check: generate
2024
cargo clippy --all-targets --features "${ALL_FEATURES}" -- -D clippy::all
2125

2226
unit-test: generate
23-
cargo nextest run --all --no-default-features
27+
cargo nextest run ${NEXTEST_ARGS} --all --no-default-features
28+
29+
integration-test: integration-test-txn integration-test-raw
30+
31+
integration-test-txn: generate
32+
$(RUN_INTEGRATION_TEST) txn_
2433

25-
integration-test: generate
26-
cargo test txn_ --all ${INTEGRATION_TEST_ARGS} -- --nocapture
27-
cargo test raw_ --all ${INTEGRATION_TEST_ARGS} -- --nocapture
28-
cargo test misc_ --all ${INTEGRATION_TEST_ARGS} -- --nocapture
34+
integration-test-raw: generate
35+
$(RUN_INTEGRATION_TEST) raw_
2936

3037
test: unit-test integration-test
3138

config/nextest.toml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[profile.ci]
2+
retries = 0
3+
fail-fast = false
4+
slow-timeout = { period = "60s", terminate-after = 10 } # Timeout 10m. TODO: speed up the slow tests.
5+
failure-output = "final"
6+
7+
[profile.ci.junit]
8+
path = "junit.xml"

config/tikv.toml

+1
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ max-open-files = 10000
1919
[storage]
2020
api-version = 2
2121
enable-ttl = true
22+
reserve-space = "0MiB"

tests/integration_tests.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
//! Test names should begin with one of the following:
66
//! 1. txn_
77
//! 2. raw_
8-
//! 3. misc_
98
//!
109
//! We make use of the convention to control the order of tests in CI, to allow
1110
//! transactional and raw tests to coexist, since transactional requests have

0 commit comments

Comments
 (0)