Skip to content

Commit d649883

Browse files
committed
Merge branch 'master' into dont-clone-config
2 parents 45b48cc + 72f4a17 commit d649883

File tree

10 files changed

+98
-77
lines changed

10 files changed

+98
-77
lines changed

.travis.yml

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,47 @@
1-
branches:
2-
only:
3-
# This is where pull requests from "bors r+" are built.
4-
- staging
5-
# This is where pull requests from "bors try" are built.
6-
- trying
7-
# Enable building pull requests.
8-
- master
1+
sudo: false
92

103
language: rust
11-
sudo: false
4+
os:
5+
- linux
6+
# - windows # TODO: https://github.com/pingcap/kvproto/issues/355
7+
- osx
8+
rust:
9+
- stable
10+
- nightly
1211
env:
1312
global:
1413
- RUST_BACKTRACE=1
1514
- RUSTFLAGS="-D warnings"
16-
cache: cargo
17-
18-
rust:
19-
os:
20-
- linux
21-
- windows
22-
- osx
2315

24-
matrix:
25-
include:
26-
# This build uses stable and checks rustfmt and clippy.
27-
# We don't check them on nightly since their lints and formatting may differ.
28-
- rust: stable
29-
install:
30-
- rustup component add rustfmt-preview
31-
- rustup component add clippy-preview
32-
before_script:
33-
- cargo fmt --all -- --check
34-
- cargo clippy --all -- -D clippy
35-
# Since many users will use nightlies, also test that.
36-
- rust: nightly
16+
addons:
17+
apt:
18+
update: true
19+
sources:
20+
- sourceline: 'ppa:maarten-fonville/protobuf'
21+
packages:
22+
- protobuf-compiler
23+
homebrew:
24+
packages:
25+
- protobuf
26+
- cmake
27+
- go
3728

29+
install:
30+
- if [[ $TRAVIS_RUST_VERSION == "stable" && $TRAVIS_OS_NAME == "linux" ]]; then rustup component add rustfmt; fi
31+
- if [[ $TRAVIS_RUST_VERSION == "stable" && $TRAVIS_OS_NAME == "linux" ]]; then rustup component add clippy; fi
32+
- if [[ $TRAVIS_OS_NAME == "windows" ]]; then choco install golang cmake strawberryperl protoc; fi
33+
- if [[ $TRAVIS_OS_NAME == "windows" ]]; then export PATH="$PATH:/c/Go/bin/:/c/Program Files/CMake/bin"; fi
3834

3935
script:
40-
- docker run -d --net=host --name pd --rm pingcap/pd --name "pd" --data-dir "pd" --client-urls "http://127.0.0.1:2379" --advertise-client-urls "http://127.0.0.1:2379"
41-
- docker run -d --net=host --name kv --rm pingcap/tikv --pd-endpoints "127.0.0.1:2379" --addr "127.0.0.1:2378" --data-dir "kv"
36+
- if [[ $TRAVIS_RUST_VERSION == "stable" && $TRAVIS_OS_NAME == "linux" ]]; then cargo fmt -- --check; fi
37+
- if [[ $TRAVIS_RUST_VERSION == "stable" && $TRAVIS_OS_NAME == "linux" ]]; then cargo clippy -- -D clippy::all; fi
4238
- cargo test --all -- --nocapture
43-
# Validate benches still work.
44-
- cargo bench --all -- --test
39+
# For now we only run full integration tests on Linux. Here's why:
40+
# * Docker on OS X is not supported by Travis.
41+
# * Docker on Windows seems to not have the correct binary at `"/c/Program Files/Docker/Docker/DockerCli.exe" to switch it to Linux containers.
42+
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then docker run -d --net=host --name pd --rm pingcap/pd --name "pd" --data-dir "pd" --client-urls "http://127.0.0.1:2379" --advertise-client-urls "http://127.0.0.1:2379"; fi
43+
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then docker run -d --net=host --name kv --rm --ulimit nofile=90000:90000 pingcap/tikv --pd-endpoints "127.0.0.1:2379" --addr "127.0.0.1:2378" --data-dir "kv"; fi
44+
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then docker ps; fi
45+
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then docker logs pd; fi
46+
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then docker logs kv; fi
47+
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then PD_ADDR="127.0.0.1:2379" cargo test --all --features integration-tests -- --nocapture; fi

Cargo.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ repository = "https://github.com/tikv/client-rust"
88
description = "The rust language implementation of TiKV client."
99
edition = "2018"
1010

11+
[features]
12+
default = []
13+
# Enable integration tests with a running TiKV and PD instance.
14+
# Use $PD_ADDRS, comma separated, to set the addresses the tests use.
15+
integration-tests = []
16+
1117
[lib]
1218
name = "tikv_client"
1319

@@ -26,7 +32,7 @@ failure = "0.1"
2632

2733
[dependencies.kvproto]
2834
git = "https://github.com/pingcap/kvproto.git"
29-
rev = "f9b9e7d362c7cc2c90202fc7c300b2e466cbfbf2"
35+
branch = "raft-0.5.0"
3036

3137
[dependencies.prometheus]
3238
version = "0.4.2"

appveyor.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

examples/raw.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,7 @@ fn main() -> Result<()> {
6262

6363
// You can also set the `ColumnFamily` used by the request.
6464
// This is *advanced usage* and should have some special considerations.
65-
client
66-
.delete(KEY)
67-
.wait()
68-
.expect("Could not delete value");
65+
client.delete(KEY).wait().expect("Could not delete value");
6966
println!("Key: {:?} deleted", Key::from(KEY));
7067

7168
// Here we check if the key has been deleted from the key-value store.
@@ -82,10 +79,7 @@ fn main() -> Result<()> {
8279
KvPair::from(("k2", "v2")),
8380
KvPair::from(("k3", "v3")),
8481
];
85-
client
86-
.batch_put(pairs)
87-
.wait()
88-
.expect("Could not put pairs");
82+
client.batch_put(pairs).wait().expect("Could not put pairs");
8983

9084
// Same thing when you want to retrieve multiple values.
9185
let keys = vec![Key::from("k1"), Key::from("k2")];

src/rpc/client.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14+
// TODO: Remove this when txn is done.
15+
#![allow(dead_code)]
16+
1417
use std::{
1518
collections::HashMap,
1619
fmt,

src/rpc/pd/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14+
// TODO: Remove this when txn is done.
15+
#![allow(dead_code)]
16+
1417
use std::ops::{Deref, DerefMut};
1518

1619
use kvproto::{kvrpcpb, metapb};

src/rpc/tikv/client.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14+
// TODO: Remove this when txn is done.
15+
#![allow(dead_code)]
16+
1417
use std::{fmt, sync::Arc, time::Duration};
1518

1619
use futures::Future;
@@ -46,7 +49,7 @@ impl From<errorpb::Error> for Error {
4649
} else if e.has_region_not_found() {
4750
Error::region_not_found(e.get_region_not_found().get_region_id(), Some(message))
4851
} else if e.has_key_not_in_region() {
49-
let mut e = e.take_key_not_in_region();
52+
let e = e.take_key_not_in_region();
5053
Error::key_not_in_region(e)
5154
} else if e.has_epoch_not_match() {
5255
Error::stale_epoch(Some(format!(

tests/integration_tests/mod.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2019 The TiKV Project Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
mod raw;
15+
16+
use std::env::var;
17+
const ENV_PD_ADDR: &str = "PD_ADDR";
18+
19+
pub fn pd_addr() -> Vec<String> {
20+
var(ENV_PD_ADDR)
21+
.expect(&format!("Expected {}:", ENV_PD_ADDR))
22+
.split(",")
23+
.map(From::from)
24+
.collect()
25+
}

tests/raw.rs renamed to tests/integration_tests/raw.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018 The TiKV Project Authors
1+
// Copyright 2019 The TiKV Project Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -14,6 +14,7 @@
1414
use futures::future::Future;
1515

1616
const NUM_TEST_KEYS: u32 = 100;
17+
use crate::integration_tests::pd_addr;
1718
use tikv_client::{raw::Client, Config, Key, KvPair, Value};
1819

1920
fn generate_key(id: i32) -> Key {
@@ -34,7 +35,7 @@ fn wipe_all(client: &Client) {
3435
}
3536

3637
fn connect() -> Client {
37-
let client = Client::new(Config::new(vec!["127.0.0.1:2379"]))
38+
let client = Client::new(&Config::new(pd_addr()))
3839
.wait()
3940
.expect("Could not connect to tikv");
4041
wipe_all(&client);

tests/test.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2019 The TiKV Project Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
#[cfg(feature = "integration-tests")]
15+
mod integration_tests;

0 commit comments

Comments
 (0)