From d9e014c07438bbdbff9c3dca03ac185ae04b5343 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein <tamird@gmail.com> Date: Mon, 3 Feb 2025 12:06:19 -0500 Subject: [PATCH] build(deps): update rand requirement in the cargo-crates group Updates the requirements on [rand](https://github.com/rust-random/rand) to permit the latest version. Updates `rand` to 0.9.0 - [Release notes](https://github.com/rust-random/rand/releases) - [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-random/rand/compare/0.8.5...0.9.0) --- updated-dependencies: - dependency-name: rand dependency-type: direct:production dependency-group: cargo-crates ... Signed-off-by: dependabot[bot] <support@github.com> --- Cargo.toml | 2 +- test/integration-test/Cargo.toml | 2 +- test/integration-test/src/tests/ring_buf.rs | 16 ++++++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6809beaa..59da0849 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -87,7 +87,7 @@ proc-macro2 = { version = "1", default-features = false } proc-macro2-diagnostics = { version = "0.10.1", default-features = false } public-api = { version = "0.43.0", default-features = false } quote = { version = "1", default-features = false } -rand = { version = "0.8", default-features = false } +rand = { version = "0.9", default-features = false } rbpf = { version = "0.3.0", default-features = false } rustdoc-json = { version = "0.9.0", default-features = false } rustup-toolchain = { version = "0.1.5", default-features = false } diff --git a/test/integration-test/Cargo.toml b/test/integration-test/Cargo.toml index 4cdeaa28..430268c6 100644 --- a/test/integration-test/Cargo.toml +++ b/test/integration-test/Cargo.toml @@ -22,7 +22,7 @@ libc = { workspace = true } log = { workspace = true } netns-rs = { workspace = true } object = { workspace = true, features = ["elf", "read_core", "std"] } -rand = { workspace = true, features = ["std", "std_rng"] } +rand = { workspace = true, features = ["thread_rng"] } rbpf = { workspace = true } test-case = { workspace = true } test-log = { workspace = true, features = ["log"] } diff --git a/test/integration-test/src/tests/ring_buf.rs b/test/integration-test/src/tests/ring_buf.rs index 515ed421..52affeba 100644 --- a/test/integration-test/src/tests/ring_buf.rs +++ b/test/integration-test/src/tests/ring_buf.rs @@ -77,8 +77,8 @@ struct WithData(RingBufTest, Vec<u64>); impl WithData { fn new(n: usize) -> Self { Self(RingBufTest::new(), { - let mut rng = rand::thread_rng(); - std::iter::repeat_with(|| rng.gen()).take(n).collect() + let mut rng = rand::rng(); + std::iter::repeat_with(|| rng.random()).take(n).collect() }) } } @@ -270,13 +270,17 @@ async fn ring_buf_async_no_drop() { ) = WithData::new(RING_BUF_MAX_ENTRIES * 3); let writer = { - let data = data.to_owned(); + let mut rng = rand::rng(); + let data: Vec<_> = data + .iter() + .copied() + .map(|value| (value, Duration::from_nanos(rng.random_range(0..10)))) + .collect(); tokio::spawn(async move { - for value in data { + for (value, duration) in data { // Sleep a tad so we feel confident that the consumer will keep up // and no messages will be dropped. - let dur = Duration::from_nanos(rand::thread_rng().gen_range(0..10)); - sleep(dur).await; + sleep(duration).await; ring_buf_trigger_ebpf_program(value); } })