Skip to content

Commit aa224b3

Browse files
Wip on tests
1 parent e55206e commit aa224b3

File tree

8 files changed

+53
-18
lines changed

8 files changed

+53
-18
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,13 @@ jobs:
5252

5353
integration-test:
5454
name: integration test
55+
strategy:
56+
fail-fast: false
57+
matrix:
58+
case: ["integration-test-txn", "integration-test-raw"]
5559
env:
5660
CARGO_INCREMENTAL: 0
61+
TIKV_VERSION: v8.5.1
5762
runs-on: ubuntu-latest
5863
steps:
5964
- uses: actions/checkout@v4
@@ -69,14 +74,22 @@ jobs:
6974
- name: start tiup playground
7075
run: |
7176
# 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 &
77+
~/.tiup/bin/tiup install tikv:${{ env.TIKV_VERSION }} pd:${{ env.TIKV_VERSION }}
78+
~/.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 &
7479
while :; do
7580
echo "waiting cluster to be ready"
7681
[[ "$(curl -I http://127.0.0.1:2379/pd/api/v1/regions 2>/dev/null | head -n 1 | cut -d$' ' -f2)" -ne "405" ]] || break
7782
sleep 1
7883
done
7984
- name: Install latest nextest release
8085
uses: taiki-e/install-action@nextest
81-
- name: integration test
82-
run: MULTI_REGION=1 make integration-test
86+
- name: Integration test
87+
run: MULTI_REGION=1 make ${{ matrix.case }}
88+
- name: Upload logs
89+
if: failure()
90+
uses: actions/upload-artifact@v4
91+
with:
92+
name: cluster-logs
93+
path: |
94+
~/.tiup/data/cluster/tikv*/*.log
95+
~/.tiup/data/cluster/pd*/*.log

Makefile

Lines changed: 14 additions & 7 deletions
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 -P ci
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

Lines changed: 8 additions & 0 deletions
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 = 3 } # Timeout 3m.
5+
failure-output = "final"
6+
7+
[profile.ci.junit]
8+
path = "junit.xml"

config/tikv.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
[coprocessor]
22
region-max-keys = 10
3-
region-split-keys = 7
3+
region-split-keys = 150
44
batch-split-limit = 100
55

66
[raftstore]
77
region-split-check-diff = "1B"
88
pd-heartbeat-tick-interval = "2s"
99
pd-store-heartbeat-tick-interval = "5s"
1010
split-region-check-tick-interval = "1s"
11-
raft-entry-max-size = "1MB"
11+
raft-entry-max-size = "256KiB"
1212

1313
[rocksdb]
1414
max-open-files = 10000

src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@
100100

101101
pub mod backoff;
102102
#[doc(hidden)]
103+
pub mod proto; // export `proto` to enable user customized codec
104+
#[doc(hidden)]
103105
pub mod raw;
104106
pub mod request;
105107
#[doc(hidden)]
@@ -110,7 +112,6 @@ mod compat;
110112
mod config;
111113
mod kv;
112114
mod pd;
113-
mod proto;
114115
mod region;
115116
mod region_cache;
116117
mod stats;

src/proto.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#![allow(clippy::large_enum_variant)]
44
#![allow(clippy::enum_variant_names)]
5+
#![allow(clippy::doc_lazy_continuation)]
56

67
pub use protos::*;
78

tests/failpoint_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ async fn must_rollbacked(client: &TransactionClient, keys: HashSet<Vec<u8>>) {
374374

375375
async fn count_locks(client: &TransactionClient) -> Result<usize> {
376376
let ts = client.current_timestamp().await.unwrap();
377-
let locks = client.scan_locks(&ts, .., 1024).await?;
377+
let locks = client.scan_locks(&ts, vec![].., 1024).await?;
378378
// De-duplicated as `scan_locks` will return duplicated locks due to retry on region changes.
379379
let locks_set: HashSet<Vec<u8>> = HashSet::from_iter(locks.into_iter().map(|l| l.key));
380380
Ok(locks_set.len())

tests/integration_tests.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@
1212
//! requirements on the region boundaries.
1313
1414
mod common;
15+
use std::collections::HashMap;
16+
use std::iter;
17+
1518
use common::*;
1619
use futures::prelude::*;
1720
use rand::seq::IteratorRandom;
1821
use rand::thread_rng;
1922
use rand::Rng;
2023
use serial_test::serial;
21-
use std::collections::HashMap;
22-
use std::iter;
2324
use tikv_client::backoff::DEFAULT_REGION_BACKOFF;
2425
use tikv_client::transaction::HeartbeatOption;
2526
use tikv_client::transaction::Mutation;
@@ -207,7 +208,11 @@ async fn txn_split_batch() -> Result<()> {
207208
let val_len = 15000;
208209

209210
let values: Vec<_> = (0..keys_count)
210-
.map(|_| (0..val_len).map(|_| rng.gen::<u8>()).collect::<Vec<_>>())
211+
.map(|_| {
212+
let mut buf = vec![0; val_len];
213+
rng.fill(&mut buf[..]);
214+
buf
215+
})
211216
.collect();
212217

213218
for (i, value) in values.iter().enumerate() {

0 commit comments

Comments
 (0)