Skip to content

Commit d36db7a

Browse files
committed
fix: Sccache dist tests broken after bump to tokio 1.21 and later
Signed-off-by: Xuanwo <github@xuanwo.io>
1 parent 53de1a0 commit d36db7a

File tree

8 files changed

+129
-150
lines changed

8 files changed

+129
-150
lines changed

.github/workflows/ci.yml

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
include:
4545
- os: ubuntu-20.04
4646
rustc: 1.60.0 # Oldest supported version, keep in sync with README.md
47-
- os: ubuntu-18.04
47+
- os: ubuntu-22.04
4848
rustc: 1.60.0
4949
extra_desc: dist-server
5050
extra_args: --no-default-features --features=dist-tests test_dist_ -- --test-threads 1
@@ -182,10 +182,10 @@ jobs:
182182
extra_args: --features=unstable
183183
- os: macOS-11
184184
rustc: nightly
185-
# Disable on Windows for now as it fails with:
186-
# found invalid metadata files for crate `vte_generate_state_changes`
187-
# - os: windows-2019
188-
# rustc: nightly
185+
# Disable on Windows for now as it fails with:
186+
# found invalid metadata files for crate `vte_generate_state_changes`
187+
# - os: windows-2019
188+
# rustc: nightly
189189
env:
190190
RUST_BACKTRACE: 1
191191
steps:
@@ -207,9 +207,9 @@ jobs:
207207
- name: Execute tests
208208
run: cargo test --no-fail-fast --locked --all-targets --verbose ${{ matrix.extra_args }}
209209
env:
210-
CARGO_INCREMENTAL: '0'
211-
RUSTC_WRAPPER: ''
212-
RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off'
210+
CARGO_INCREMENTAL: "0"
211+
RUSTC_WRAPPER: ""
212+
RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off"
213213

214214
- name: Generate coverage data (via `grcov`)
215215
id: coverage
@@ -245,53 +245,53 @@ jobs:
245245
matrix:
246246
job:
247247
- { os: macos-12 }
248-
release: [ "13.1" ]
248+
release: ["13.1"]
249249
steps:
250-
- uses: actions/checkout@v3
251-
- name: Prepare, build and test
252-
uses: vmactions/freebsd-vm@v0
253-
with:
254-
mem: 8192
255-
usesh: true
256-
copyback: false
257-
prepare: pkg install -y ca_root_nss curl gmake gtar pot sudo
258-
run: |
259-
#####################################################################################
260-
### Prepare, build, and test
261-
#####################################################################################
262-
### based on ref: <https://github.com/rust-lang/rustup/pull/2783>
263-
### and on ref: <https://github.com/uutils/coreutils/commit/86c610a84b8b6c>
264-
### * NOTE: All steps need to be run in this block, otherwise, we are operating back
265-
### on the mac host.
266-
set -exo pipefail
267-
#
268-
### Basic user setup ################################################################
269-
TEST_USER=tester
270-
TEST_USER_HOME="/opt/$TEST_USER"
271-
REPO_NAME=${GITHUB_WORKSPACE##*/}
272-
WORKSPACE_PARENT="/Users/runner/work/${REPO_NAME}"
273-
WORKSPACE="${WORKSPACE_PARENT}/${REPO_NAME}"
274-
export WORKSPACE
275-
#
276-
mkdir -p "$TEST_USER_HOME"
277-
pw adduser -n "$TEST_USER" -d "$TEST_USER_HOME" -c "Tester" -h -
278-
chown -R "$TEST_USER":"$TEST_USER" "$TEST_USER_HOME"
279-
chown -R "$TEST_USER":"$TEST_USER" "/$WORKSPACE_PARENT"/
280-
cat > /usr/local/etc/sudoers.d/wheel<<EOF
281-
$TEST_USER ALL=(ALL) NOPASSWD: ALL
282-
EOF
283-
#
284-
### Install rust stable from rustup ################################################
285-
su "$TEST_USER" -c "/bin/sh -exo pipefail" <<"EOH"
286-
whoami
287-
echo "$HOME"
288-
fetch -o /tmp/rustup.sh https://sh.rustup.rs
289-
sh /tmp/rustup.sh -y --profile=minimal
290-
### Run tests #######################################################################
291-
. "$HOME/.cargo/env"
292-
"$WORKSPACE/scripts/freebsd-ci-test.sh"
293-
EOH
294-
# end
250+
- uses: actions/checkout@v3
251+
- name: Prepare, build and test
252+
uses: vmactions/freebsd-vm@v0
253+
with:
254+
mem: 8192
255+
usesh: true
256+
copyback: false
257+
prepare: pkg install -y ca_root_nss curl gmake gtar pot sudo
258+
run: |
259+
#####################################################################################
260+
### Prepare, build, and test
261+
#####################################################################################
262+
### based on ref: <https://github.com/rust-lang/rustup/pull/2783>
263+
### and on ref: <https://github.com/uutils/coreutils/commit/86c610a84b8b6c>
264+
### * NOTE: All steps need to be run in this block, otherwise, we are operating back
265+
### on the mac host.
266+
set -exo pipefail
267+
#
268+
### Basic user setup ################################################################
269+
TEST_USER=tester
270+
TEST_USER_HOME="/opt/$TEST_USER"
271+
REPO_NAME=${GITHUB_WORKSPACE##*/}
272+
WORKSPACE_PARENT="/Users/runner/work/${REPO_NAME}"
273+
WORKSPACE="${WORKSPACE_PARENT}/${REPO_NAME}"
274+
export WORKSPACE
275+
#
276+
mkdir -p "$TEST_USER_HOME"
277+
pw adduser -n "$TEST_USER" -d "$TEST_USER_HOME" -c "Tester" -h -
278+
chown -R "$TEST_USER":"$TEST_USER" "$TEST_USER_HOME"
279+
chown -R "$TEST_USER":"$TEST_USER" "/$WORKSPACE_PARENT"/
280+
cat > /usr/local/etc/sudoers.d/wheel<<EOF
281+
$TEST_USER ALL=(ALL) NOPASSWD: ALL
282+
EOF
283+
#
284+
### Install rust stable from rustup ################################################
285+
su "$TEST_USER" -c "/bin/sh -exo pipefail" <<"EOH"
286+
whoami
287+
echo "$HOME"
288+
fetch -o /tmp/rustup.sh https://sh.rustup.rs
289+
sh /tmp/rustup.sh -y --profile=minimal
290+
### Run tests #######################################################################
291+
. "$HOME/.cargo/env"
292+
"$WORKSPACE/scripts/freebsd-ci-test.sh"
293+
EOH
294+
# end
295295
296296
release:
297297
name: release

Cargo.lock

Lines changed: 5 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ env_logger = "0.10"
4242
filetime = "0.2"
4343
flate2 = { version = "1.0", optional = true, default-features = false, features = ["rust_backend"] }
4444
futures = "0.3"
45-
futures-locks = "0.7"
4645
gzp = { version = "0.11.1", default-features = false, features = ["deflate_rust"] }
4746
http = "0.2"
4847
hyper = { version = "0.14.10", optional = true, features = ["server"] }

src/dist/http.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,10 @@ mod server {
556556

557557
rouille::Response {
558558
status_code: 200,
559-
headers: vec![("Content-Type".into(), "application/octet-stream".into())],
559+
headers: vec![
560+
("Content-Type".into(), "application/octet-stream".into()),
561+
("Content-Length".into(), data.len().to_string().into()),
562+
],
560563
data: rouille::ResponseBody::from_data(data),
561564
upgrade: None,
562565
}
@@ -744,6 +747,9 @@ mod server {
744747
}
745748
// Finish the client
746749
let new_client = client_builder
750+
// Disable connection pool to avoid broken connection
751+
// between runtime
752+
.pool_max_idle_per_host(0)
747753
.build()
748754
.context("failed to create a HTTP client")?;
749755
// Use the updated certificates
@@ -783,12 +789,16 @@ mod server {
783789
prepare_response(request, &res)
784790
},
785791
(GET) (/api/v1/scheduler/server_certificate/{server_id: ServerId}) => {
786-
let certs = server_certificates.lock().unwrap();
787-
let (cert_digest, cert_pem) = try_or_500_log!(req_id, certs.get(&server_id)
792+
let certs = {
793+
let guard = server_certificates.lock().unwrap();
794+
guard.get(&server_id).map(|v|v.to_owned())
795+
};
796+
797+
let (cert_digest, cert_pem) = try_or_500_log!(req_id, certs
788798
.context("server cert not available"));
789799
let res = ServerCertificateHttpResponse {
790-
cert_digest: cert_digest.clone(),
791-
cert_pem: cert_pem.clone(),
800+
cert_digest,
801+
cert_pem,
792802
};
793803
prepare_response(request, &res)
794804
},
@@ -1100,6 +1110,9 @@ mod client {
11001110
let client = reqwest::ClientBuilder::new()
11011111
.timeout(timeout)
11021112
.connect_timeout(connect_timeout)
1113+
// Disable connection pool to avoid broken connection
1114+
// between runtime
1115+
.pool_max_idle_per_host(0)
11031116
.build()
11041117
.context("failed to create an async HTTP client")?;
11051118
let client_toolchains =

0 commit comments

Comments
 (0)