Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: fix spurious CI failure #5752

Merged
merged 1 commit into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ jobs:
toolchain: ${{ env.rust_nightly }}
- uses: Swatinem/rust-cache@v2
- name: asan
run: cargo test --workspace --all-features --target x86_64-unknown-linux-gnu --tests -- --test-threads 1
run: cargo test --workspace --all-features --target x86_64-unknown-linux-gnu --tests -- --test-threads 1 --nocapture
env:
RUSTFLAGS: -Z sanitizer=address
# Ignore `trybuild` errors as they are irrelevant and flaky on nightly
Expand Down
25 changes: 9 additions & 16 deletions tokio/tests/rt_threaded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,6 @@ fn test_tuning() {
}

// Now, hammer the injection queue until the interval drops.
let mut i = 0;
let mut n = 0;
loop {
let curr = interval.load(Relaxed);
Expand All @@ -645,18 +644,16 @@ fn test_tuning() {
break;
}

let counter = counter.clone();
let interval = interval.clone();
if Arc::strong_count(&interval) < 5_000 {
let counter = counter.clone();
let interval = interval.clone();

if i <= 5_000 {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the test expects 3 "valid" measurements, with unreliable enough thread scheduling (CI), it is possible t not to observe these measurements in 5k spawned tasks.

i += 1;
rt.spawn(async move {
let prev = counter.swap(0, Relaxed);
interval.store(prev, Relaxed);
});

std::thread::yield_now();
} else {
std::thread::sleep(Duration::from_micros(500));
}
}

Expand All @@ -682,7 +679,6 @@ fn test_tuning() {
}

// Now, hammer the injection queue until the interval reaches the expected range.
let mut i = 0;
let mut n = 0;
loop {
let curr = interval.load(Relaxed);
Expand All @@ -697,20 +693,17 @@ fn test_tuning() {
break;
}

let counter = counter.clone();
let interval = interval.clone();
if Arc::strong_count(&interval) <= 5_000 {
let counter = counter.clone();
let interval = interval.clone();

if i <= 5_000 {
i += 1;
rt.spawn(async move {
let prev = counter.swap(0, Relaxed);
interval.store(prev, Relaxed);
});

std::thread::yield_now();
} else {
std::thread::sleep(Duration::from_micros(500));
}

std::thread::yield_now();
}

flag.store(false, Relaxed);
Expand Down