Skip to content

Commit

Permalink
Refine CI
Browse files Browse the repository at this point in the history
Signed-off-by: Ana Hobden <operator@hoverbear.org>
  • Loading branch information
Hoverbear committed Jan 14, 2019
1 parent c33bc13 commit 4350ff6
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 36 deletions.
87 changes: 53 additions & 34 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,63 @@
branches:
only:
# This is where pull requests from "bors r+" are built.
- staging
# This is where pull requests from "bors try" are built.
- trying
# Enable building pull requests.
- master
sudo: false

language: rust
sudo: false
os:
rust:
cache: cargo

env:
global:
- RUST_BACKTRACE=1
- RUSTFLAGS="-D warnings"
cache: cargo

rust:
os:
- linux
- windows
- osx

matrix:
include:
# This build uses stable and checks rustfmt and clippy.
# We don't check them on nightly since their lints and formatting may differ.
- rust: stable
install:
- rustup component add rustfmt-preview
- rustup component add clippy-preview
before_script:
- cargo fmt --all -- --check
- cargo clippy --all -- -D clippy
# Since many users will use nightlies, also test that.
- rust: nightly

- os: linux
rust: stable
stages:
- lint
- unit
- integration
- os: linux
rust: nightly
stages:
- unit
- integration
- os: windows
rust: stable
stages:
- unit
- integration
- os: windows
rust: nightly
stages:
- unit
- integration
# OS X doesn't get docker. :(
- os: osx
rust: stable
stages:
- unit
- os: osx
rust: nightly
stages:
- unit

script:
- 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"
- 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"
- cargo test --all -- --nocapture
# Validate benches still work.
- cargo bench --all -- --test
jobs:
include:
- stage: lint
install:
- rustup component add rustfmt-preview
- rustup component add clippy-preview
before_script:
- cargo fmt --all -- --check
- cargo clippy --all -- -D clippy
- stage: unit
script:
- cargo test --all
- stage: integration
before_script:
- 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"
- 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"
script:
- cargo test --features integration-tests
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ repository = "https://github.com/tikv/client-rust"
description = "The rust language implementation of TiKV client."
edition = "2018"

[features]
default = []
# Enable integration tests with a running TiKV and PD instance.
# Use $PD_ADDRS, comma separated, to set the addresses the tests use.
integration-tests = []

[lib]
name = "tikv_client"

Expand Down
25 changes: 25 additions & 0 deletions tests/integration_tests/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2019 The TiKV Project Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.

mod raw;

use std::env::var;
const ENV_PD_ADDR: &str = "PD_ADDR";

pub fn pd_addrs() -> Vec<String> {
var(ENV_PD_ADDR)
.expect(&format!("Expected {}:", ENV_PD_ADDR))
.split(",")
.map(From::from)
.collect()
}
5 changes: 3 additions & 2 deletions tests/raw.rs → tests/integration_tests/raw.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 The TiKV Project Authors
// Copyright 2019 The TiKV Project Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -15,6 +15,7 @@ use futures::future::Future;

const NUM_TEST_KEYS: u32 = 100;
use tikv_client::{raw::Client, Config, Key, KvPair, Value};
use crate::integration_tests::pd_addrs;

fn generate_key(id: i32) -> Key {
format!("testkey_{}", id).into_bytes().into()
Expand All @@ -34,7 +35,7 @@ fn wipe_all(client: &Client) {
}

fn connect() -> Client {
let client = Client::new(&Config::new(vec!["127.0.0.1:2379"]))
let client = Client::new(&Config::new(pd_addrs()))
.wait()
.expect("Could not connect to tikv");
wipe_all(&client);
Expand Down
15 changes: 15 additions & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2019 The TiKV Project Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.

#[cfg(feature = "integration-tests")]
mod integration_tests;

0 comments on commit 4350ff6

Please sign in to comment.