Skip to content

Commit 2761270

Browse files
authored
build: Make sure tikv-client works on stable rust (#412)
Signed-off-by: Xuanwo <github@xuanwo.io>
1 parent 2c831ba commit 2761270

File tree

18 files changed

+179
-160
lines changed

18 files changed

+179
-160
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v2
15-
- uses: actions-rs/toolchain@v1
16-
with:
17-
profile: minimal
18-
toolchain: nightly
19-
override: true
20-
- run: rustup component add rustfmt clippy
2115
- name: Install Protoc
2216
uses: arduino/setup-protoc@v1
2317
with:
@@ -35,11 +29,6 @@ jobs:
3529
runs-on: ubuntu-latest
3630
steps:
3731
- uses: actions/checkout@v2
38-
- uses: actions-rs/toolchain@v1
39-
with:
40-
profile: minimal
41-
toolchain: nightly
42-
override: true
4332
- name: Install Protoc
4433
uses: arduino/setup-protoc@v1
4534
with:
@@ -57,11 +46,6 @@ jobs:
5746
runs-on: ubuntu-latest
5847
steps:
5948
- uses: actions/checkout@v2
60-
- uses: actions-rs/toolchain@v1
61-
with:
62-
profile: minimal
63-
toolchain: nightly
64-
override: true
6549
- name: Install Protoc
6650
uses: arduino/setup-protoc@v1
6751
with:

Makefile

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,9 @@ integration-test:
2626

2727
test: unit-test integration-test
2828

29-
doc:
29+
doc:
3030
cargo doc --workspace --exclude tikv-client-proto --document-private-items --no-deps
3131

32-
# Deprecated
33-
# docker-pd:
34-
# docker run -d -v $(shell pwd)/config:/config --net=host --name pd --rm pingcap/pd:latest --name "pd" --data-dir "pd" --client-urls "http://127.0.0.1:2379" --advertise-client-urls "http://127.0.0.1:2379" --config /config/pd.toml
35-
36-
# docker-kv:
37-
# docker run -d -v $(shell pwd)/config:/config --net=host --name kv --rm --ulimit nofile=90000:90000 pingcap/tikv:latest --pd-endpoints "127.0.0.1:2379" --addr "127.0.0.1:2378" --data-dir "kv" --config /config/tikv.toml
38-
39-
# docker: docker-pd docker-kv
40-
4132
tiup:
4233
tiup playground nightly --mode tikv-slim --kv 3 --without-monitor --kv.config $(shell pwd)/config/tikv.toml --pd.config $(shell pwd)/config/pd.toml &
4334

examples/raw.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ async fn main() -> Result<()> {
100100
.expect("Could not scan");
101101

102102
let keys: Vec<_> = pairs.into_iter().map(|p| p.key().clone()).collect();
103-
assert_eq!(&keys, &[
104-
Key::from("k1".to_owned()),
105-
Key::from("k2".to_owned()),
106-
]);
103+
assert_eq!(
104+
&keys,
105+
&[Key::from("k1".to_owned()), Key::from("k2".to_owned()),]
106+
);
107107
println!("Scanning from {start:?} to {end:?} gives: {keys:?}");
108108

109109
let k1 = "k1";
@@ -122,15 +122,18 @@ async fn main() -> Result<()> {
122122
.into_iter()
123123
.map(|p| String::from_utf8(p.1).unwrap())
124124
.collect();
125-
assert_eq!(&vals, &[
126-
"v1".to_owned(),
127-
"v2".to_owned(),
128-
"v2".to_owned(),
129-
"v3".to_owned(),
130-
"v1".to_owned(),
131-
"v2".to_owned(),
132-
"v3".to_owned()
133-
]);
125+
assert_eq!(
126+
&vals,
127+
&[
128+
"v1".to_owned(),
129+
"v2".to_owned(),
130+
"v2".to_owned(),
131+
"v3".to_owned(),
132+
"v1".to_owned(),
133+
"v2".to_owned(),
134+
"v3".to_owned()
135+
]
136+
);
134137
println!("Scanning batch scan from {batch_scan_keys:?} gives: {vals:?}");
135138

136139
// Cleanly exit.

examples/transaction.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ async fn main() {
110110
let key1_exists = key_exists(&txn, key1.clone()).await;
111111
let key2: Key = b"key_not_exist".to_vec().into();
112112
let key2_exists = key_exists(&txn, key2.clone()).await;
113-
println!("check exists {:?}", vec![
114-
(key1, key1_exists),
115-
(key2, key2_exists)
116-
]);
113+
println!(
114+
"check exists {:?}",
115+
vec![(key1, key1_exists), (key2, key2_exists)]
116+
);
117117

118118
// scan
119119
let key1: Key = b"key1".to_vec().into();

rust-toolchain.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[toolchain]
2+
channel = "stable"
3+
components = ["rustfmt", "clippy"]

rustfmt.toml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
edition = "2021"
2-
version = "Two"
32
reorder_imports = true
4-
imports_granularity = "Item"
5-
group_imports = "StdExternalCrate"
6-
where_single_line = true
7-
trailing_comma = "Vertical"
8-
overflow_delimited_expr = true
9-
format_code_in_doc_comments = true
10-
normalize_comments = true
3+
4+
# Those options are disabled for not supported in stable rust.
5+
# We should enable them back once stabilized.
6+
#
7+
# version = "Two"
8+
# imports_granularity = "Item"
9+
# group_imports = "StdExternalCrate"
10+
# where_single_line = true
11+
# trailing_comma = "Vertical"
12+
# overflow_delimited_expr = true
13+
# format_code_in_doc_comments = true
14+
# normalize_comments = true

src/kv/codec.rs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -154,18 +154,26 @@ pub mod test {
154154
#[test]
155155
fn test_enc_dec_bytes() {
156156
let pairs = vec![
157-
(vec![], vec![0, 0, 0, 0, 0, 0, 0, 0, 247], vec![
158-
255, 255, 255, 255, 255, 255, 255, 255, 8,
159-
]),
160-
(vec![0], vec![0, 0, 0, 0, 0, 0, 0, 0, 248], vec![
161-
255, 255, 255, 255, 255, 255, 255, 255, 7,
162-
]),
163-
(vec![1, 2, 3], vec![1, 2, 3, 0, 0, 0, 0, 0, 250], vec![
164-
254, 253, 252, 255, 255, 255, 255, 255, 5,
165-
]),
166-
(vec![1, 2, 3, 0], vec![1, 2, 3, 0, 0, 0, 0, 0, 251], vec![
167-
254, 253, 252, 255, 255, 255, 255, 255, 4,
168-
]),
157+
(
158+
vec![],
159+
vec![0, 0, 0, 0, 0, 0, 0, 0, 247],
160+
vec![255, 255, 255, 255, 255, 255, 255, 255, 8],
161+
),
162+
(
163+
vec![0],
164+
vec![0, 0, 0, 0, 0, 0, 0, 0, 248],
165+
vec![255, 255, 255, 255, 255, 255, 255, 255, 7],
166+
),
167+
(
168+
vec![1, 2, 3],
169+
vec![1, 2, 3, 0, 0, 0, 0, 0, 250],
170+
vec![254, 253, 252, 255, 255, 255, 255, 255, 5],
171+
),
172+
(
173+
vec![1, 2, 3, 0],
174+
vec![1, 2, 3, 0, 0, 0, 0, 0, 251],
175+
vec![254, 253, 252, 255, 255, 255, 255, 255, 4],
176+
),
169177
(
170178
vec![1, 2, 3, 4, 5, 6, 7],
171179
vec![1, 2, 3, 4, 5, 6, 7, 0, 254],

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@
9393
// To support both prost & rust-protobuf.
9494
#![cfg_attr(feature = "prost-codec", allow(clippy::useless_conversion))]
9595
#![allow(clippy::field_reassign_with_default)]
96-
#![allow(clippy::arc_with_non_send_sync)]
9796

9897
pub mod backoff;
9998
#[doc(hidden)]

src/mock.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ pub struct MockKvClient {
5757

5858
impl MockKvClient {
5959
pub fn with_dispatch_hook<F>(dispatch: F) -> MockKvClient
60-
where F: Fn(&dyn Any) -> Result<Box<dyn Any>> + Send + Sync + 'static {
60+
where
61+
F: Fn(&dyn Any) -> Result<Box<dyn Any>> + Send + Sync + 'static,
62+
{
6163
MockKvClient {
6264
addr: String::new(),
6365
dispatch: Some(Arc::new(dispatch)),

src/pd/client.rs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -372,16 +372,19 @@ pub mod test {
372372
let mut stream = executor::block_on_stream(stream);
373373

374374
let result: Vec<Key> = stream.next().unwrap().unwrap().1;
375-
assert_eq!(result, vec![
376-
vec![1].into(),
377-
vec![2].into(),
378-
vec![3].into(),
379-
vec![5, 2].into()
380-
]);
381-
assert_eq!(stream.next().unwrap().unwrap().1, vec![
382-
vec![12].into(),
383-
vec![11, 4].into()
384-
]);
375+
assert_eq!(
376+
result,
377+
vec![
378+
vec![1].into(),
379+
vec![2].into(),
380+
vec![3].into(),
381+
vec![5, 2].into()
382+
]
383+
);
384+
assert_eq!(
385+
stream.next().unwrap().unwrap().1,
386+
vec![vec![12].into(), vec![11, 4].into()]
387+
);
385388
assert!(stream.next().is_none());
386389
}
387390

@@ -425,10 +428,13 @@ pub mod test {
425428
let ranges4 = stream.next().unwrap().unwrap();
426429

427430
assert_eq!(ranges1.0.id(), 1);
428-
assert_eq!(ranges1.1, vec![
429-
make_key_range(k1.clone(), k2.clone()),
430-
make_key_range(k1.clone(), k_split.clone()),
431-
]);
431+
assert_eq!(
432+
ranges1.1,
433+
vec![
434+
make_key_range(k1.clone(), k2.clone()),
435+
make_key_range(k1.clone(), k_split.clone()),
436+
]
437+
);
432438
assert_eq!(ranges2.0.id(), 2);
433439
assert_eq!(ranges2.1, vec![make_key_range(k_split.clone(), k3.clone())]);
434440
assert_eq!(ranges3.0.id(), 1);

0 commit comments

Comments
 (0)