diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000000..de8dd537c9 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,76 @@ +name: CI +on: + pull_request: + push: + branches: + - master + +env: + RUST_BACKTRACE: 1 + +jobs: + test: + name: Test ${{ matrix.rust }} on ${{ matrix.os }} + + strategy: + matrix: + rust: + - stable + - beta + - nightly + # - 1.39.0 + + os: + - ubuntu-latest + - windows-latest + - macOS-latest + + include: + - rust: stable + features: "" + - rust: beta + features: "" + - rust: nightly + features: "--features nightly" + benches: true + # Limit the Happy Eyeballs tests to Linux + - rust: stable + os: ubuntu-latest + features: "--features __internal_happy_eyeballs_tests" + # - rust: 1.39.0 + # features: "--no-default-features --features runtime" + # build-only: true + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout + uses: actions/checkout@v1 + + - name: Install Rust (${{ matrix.rust }}) + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: ${{ matrix.rust }} + override: true + + - name: Build only + if: matrix.build-only + uses: actions-rs/cargo@v1 + with: + command: build + args: ${{ matrix.features }} + + - name: Test + if: matrix.build-only != true + uses: actions-rs/cargo@v1 + with: + command: test + args: ${{ matrix.features }} + + - name: Test all benches + if: matrix.benches && matrix.build-only != true + uses: actions-rs/cargo@v1 + with: + command: test + args: --benches ${{ matrix.features }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b9c80a4fa2..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,33 +0,0 @@ -language: rust -sudo: true # Required for functional IPv6 (forces VM instead of Docker). -dist: trusty -matrix: - fast_finish: true - include: - - rust: nightly - env: FEATURES="--no-default-features --features runtime,stream,nightly" - - rust: beta - env: FEATURES="--no-default-features --features runtime,stream,__internal_happy_eyeballs_tests" - #- rust: stable - # env: FEATURES="--no-default-features --features runtime,stream,__internal_happy_eyeballs_tests" - - rust: beta #stable - env: FEATURES="--no-default-features" - # Minimum Supported Rust Version - #- rust: 1.39.0 - # env: FEATURES="--no-default-features --features runtime" BUILD_ONLY="1" - -before_script: - # Add an IPv6 config - see the corresponding Travis issue - # https://github.com/travis-ci/travis-ci/issues/83 - - if [ "${TRAVIS_OS_NAME}" == "linux" ]; then - sudo sh -c 'echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6'; - fi - -script: - - 'if [ "$BUILD_ONLY" != "1" ]; then cargo test $FEATURES -- --test-threads=1; fi' - - 'if [ $TRAVIS_RUST_VERSION = nightly ]; then cargo test --benches $FEATURES; fi' - -env: - global: - - RUST_BACKTRACE=1 - - secure: KipdEhZsGIrb2W0HsDbC95x8FJ1RKEWPq8uSK8wSZwGw6MtvoZDX0edfrtf4o3/skA0h84yn35ZWF/rpo1ZEesgFY1g+l+me+jtyGvMwEsXTGjNP4oNR2MrDizjO8eYDm4hRUCLEmJVvsq4j7oNVdLGHfdrcnwqk8/NxJsRzqXM= diff --git a/Cargo.toml b/Cargo.toml index 38e8c67af0..5732c5a1ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,7 +55,6 @@ url = "1.0" [features] default = [ - "__internal_flaky_tests", "runtime", "stream", ] @@ -75,7 +74,6 @@ stream = [] # internal features used in CI nightly = [] -__internal_flaky_tests = [] __internal_happy_eyeballs_tests = [] [package.metadata.docs.rs] diff --git a/src/client/pool.rs b/src/client/pool.rs index df7224797b..68296f62e1 100644 --- a/src/client/pool.rs +++ b/src/client/pool.rs @@ -2,11 +2,13 @@ use std::collections::{HashMap, HashSet, VecDeque}; use std::fmt; use std::ops::{Deref, DerefMut}; use std::sync::{Arc, Mutex, Weak}; + +#[cfg(not(feature = "runtime"))] use std::time::{Duration, Instant}; use futures_channel::oneshot; #[cfg(feature = "runtime")] -use tokio::time::Interval; +use tokio::time::{Duration, Instant, Interval}; use crate::common::{Exec, Future, Pin, Poll, Unpin, task}; use super::Ver; @@ -899,6 +901,9 @@ mod tests { #[cfg(feature = "runtime")] #[tokio::test] async fn test_pool_timer_removes_expired() { + let _ = pretty_env_logger::try_init(); + tokio::time::pause(); + let pool = Pool::new(super::Config { enabled: true, keep_alive_timeout: Some(Duration::from_millis(10)), @@ -916,7 +921,9 @@ mod tests { assert_eq!(pool.locked().idle.get(&key).map(|entries| entries.len()), Some(3)); // Let the timer tick passed the expiration... - tokio::time::delay_for(Duration::from_millis(50)).await; + tokio::time::advance(Duration::from_millis(30)).await; + // Yield so the Interval can reap... + tokio::task::yield_now().await; assert!(pool.locked().idle.get(&key).is_none()); } diff --git a/tests/integration.rs b/tests/integration.rs index 68cc4c403a..bc292749b5 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -333,9 +333,6 @@ t! { ; } -// In rare cases, the h2 client connection does not shutdown, resulting -// in this test simply hanging... :( -#[cfg(feature = "__internal_flaky_tests")] t! { http2_parallel_10, parallel: 0..10