diff --git a/Cargo.lock b/Cargo.lock index f0199318a..6750f3ee4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5291,7 +5291,7 @@ version = "0.1.0" dependencies = [ "async-trait", "paste", - "rand 0.8.5", + "rand 0.9.0", "rstest", "rusqlite", "thiserror 2.0.17", diff --git a/Cargo.toml b/Cargo.toml index a42ca3b9f..4fc9bf349 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,7 +48,7 @@ linkify = "0.10.0" parse_link_header = "0.4" paste = "1.0" proc-macro-crate = "3.4.0" -rand = "0.8" +rand = "0.9" proc-macro2 = "1.0" quote = "1.0" regex = "1.12" diff --git a/wp_mobile/src/service/mock_post_service.rs b/wp_mobile/src/service/mock_post_service.rs index e2113bd27..d9506a751 100644 --- a/wp_mobile/src/service/mock_post_service.rs +++ b/wp_mobile/src/service/mock_post_service.rs @@ -73,8 +73,8 @@ fn stress_test_batch_update( format!("

Content updated at batch #{}

", current_count); // Randomize the post status - let mut rng = rand::thread_rng(); - let status_index = rng.gen_range(0..STRESS_TEST_STATUS_VALUES.len()); + let mut rng = rand::rng(); + let status_index = rng.random_range(0..STRESS_TEST_STATUS_VALUES.len()); post.status = STRESS_TEST_STATUS_VALUES[status_index].clone(); repo.upsert(conn, db_site, &post)?; @@ -389,7 +389,7 @@ impl MockPostService { thread::spawn(move || { let repo = PostRepository::::new(); - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); let mut next_insert_id: i64 = 20000; // Start IDs for inserted posts // Calculate total weight for operation selection @@ -412,11 +412,11 @@ impl MockPostService { } // Determine batch size for this iteration - let batch_size = rng.gen_range(config.min_batch_size..=config.max_batch_size); + let batch_size = rng.random_range(config.min_batch_size..=config.max_batch_size); let batch_size = batch_size.min(entity_ids.len() as u32); // Choose operation based on weights - let roll = rng.gen_range(0..total_weight); + let roll = rng.random_range(0..total_weight); let operation = if roll < config.update_weight { StressTestOperation::Update } else if roll < config.update_weight + config.delete_weight { @@ -429,7 +429,7 @@ impl MockPostService { // Select random posts for this batch let batch_indices: Vec = (0..batch_size) - .map(|_| rng.gen_range(0..entity_ids.len())) + .map(|_| rng.random_range(0..entity_ids.len())) .collect(); match operation { @@ -462,7 +462,7 @@ impl MockPostService { } // Variable delay between batches - let delay_ms = rng.gen_range(config.min_delay_ms..=config.max_delay_ms); + let delay_ms = rng.random_range(config.min_delay_ms..=config.max_delay_ms); thread::sleep(Duration::from_millis(delay_ms)); } });