Skip to content

tests: Improve integration tests #481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
name: unit test
env:
CARGO_INCREMENTAL: 0
NEXTEST_PROFILE: ci
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -52,8 +53,14 @@ jobs:

integration-test:
name: integration test
strategy:
fail-fast: false
matrix:
case: ["integration-test-txn", "integration-test-raw"]
env:
CARGO_INCREMENTAL: 0
NEXTEST_PROFILE: ci
TIKV_VERSION: v8.5.1
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -69,14 +76,22 @@ jobs:
- name: start tiup playground
run: |
# use latest stable version
~/.tiup/bin/tiup install tikv pd
~/.tiup/bin/tiup playground --mode tikv-slim --kv 3 --without-monitor --kv.config config/tikv.toml --pd.config config/pd.toml &
~/.tiup/bin/tiup install tikv:${{ env.TIKV_VERSION }} pd:${{ env.TIKV_VERSION }}
~/.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 &
while :; do
echo "waiting cluster to be ready"
[[ "$(curl -I http://127.0.0.1:2379/pd/api/v1/regions 2>/dev/null | head -n 1 | cut -d$' ' -f2)" -ne "405" ]] || break
sleep 1
done
- name: Install latest nextest release
uses: taiki-e/install-action@nextest
- name: integration test
run: MULTI_REGION=1 make integration-test
- name: Integration test
run: MULTI_REGION=1 make ${{ matrix.case }}
- name: Upload logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: cluster-logs
path: |
~/.tiup/data/cluster/tikv*/*.log
~/.tiup/data/cluster/pd*/*.log
21 changes: 14 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
export RUSTFLAGS=-Dwarnings

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

export PD_ADDRS ?= 127.0.0.1:2379
export MULTI_REGION ?= 1

ALL_FEATURES := integration-tests

INTEGRATION_TEST_ARGS := --features "integration-tests"
NEXTEST_ARGS := --config-file $(shell pwd)/config/nextest.toml

INTEGRATION_TEST_ARGS := --features "integration-tests" --test-threads 1

RUN_INTEGRATION_TEST := cargo nextest run ${NEXTEST_ARGS} --all ${INTEGRATION_TEST_ARGS}

default: check

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

unit-test: generate
cargo nextest run --all --no-default-features
cargo nextest run ${NEXTEST_ARGS} --all --no-default-features

integration-test: integration-test-txn integration-test-raw

integration-test-txn: generate
$(RUN_INTEGRATION_TEST) txn_

integration-test: generate
cargo test txn_ --all ${INTEGRATION_TEST_ARGS} -- --nocapture
cargo test raw_ --all ${INTEGRATION_TEST_ARGS} -- --nocapture
cargo test misc_ --all ${INTEGRATION_TEST_ARGS} -- --nocapture
integration-test-raw: generate
$(RUN_INTEGRATION_TEST) raw_

test: unit-test integration-test

Expand Down
8 changes: 8 additions & 0 deletions config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[profile.ci]
retries = 0
fail-fast = false
slow-timeout = { period = "60s", terminate-after = 10 } # Timeout 10m. TODO: speed up the slow tests.
failure-output = "final"

[profile.ci.junit]
path = "junit.xml"
1 change: 1 addition & 0 deletions config/tikv.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ max-open-files = 10000
[storage]
api-version = 2
enable-ttl = true
reserve-space = "0MiB"
1 change: 0 additions & 1 deletion tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//! Test names should begin with one of the following:
//! 1. txn_
//! 2. raw_
//! 3. misc_
//!
//! We make use of the convention to control the order of tests in CI, to allow
//! transactional and raw tests to coexist, since transactional requests have
Expand Down