()
| 3597 | #[cfg_attr(miri, ignore)] // too slow |
| 3598 | #[allow(clippy::disallowed_methods)] |
| 3599 | async fn webhook_concurrent_actions() { |
| 3600 | let server = test_util::TestHarness::default().start().await; |
| 3601 | let client = server.connect().await.unwrap(); |
| 3602 | |
| 3603 | #[derive(Debug, PartialEq, Eq, Deserialize, Serialize)] |
| 3604 | struct WebhookEvent { |
| 3605 | ts: u128, |
| 3606 | name: String, |
| 3607 | thread: usize, |
| 3608 | } |
| 3609 | |
| 3610 | // Create a webhook source. |
| 3611 | let src_name = "webhook_json"; |
| 3612 | client |
| 3613 | .execute( |
| 3614 | "CREATE CLUSTER webhook_cluster_concurrent REPLICAS (r1 (SIZE 'scale=1,workers=1'));", |
| 3615 | &[], |
| 3616 | ) |
| 3617 | .await |
| 3618 | .expect("failed to create cluster"); |
| 3619 | client |
| 3620 | .execute( |
| 3621 | &format!("CREATE SOURCE {src_name} IN CLUSTER webhook_cluster_concurrent FROM WEBHOOK BODY FORMAT JSON"), |
| 3622 | &[], |
| 3623 | ) |
| 3624 | .await |
| 3625 | .expect("failed to create source"); |
| 3626 | |
| 3627 | fn now() -> u128 { |
| 3628 | std::time::SystemTime::now() |
| 3629 | .duration_since(std::time::UNIX_EPOCH) |
| 3630 | .expect("time went backwards") |
| 3631 | .as_nanos() |
| 3632 | } |
| 3633 | |
| 3634 | // Flag that lets us shutdown our threads. |
| 3635 | let keep_sending = Arc::new(AtomicBool::new(true)); |
| 3636 | // Track how many requests were resolved before we dropped the collection. |
| 3637 | let num_requests_before_drop = Arc::new(AtomicUsize::new(0)); |
| 3638 | |
| 3639 | // Spin up tasks that will contiously push data to the webhook. |
| 3640 | let keep_sending_ = Arc::clone(&keep_sending); |
| 3641 | let num_requests_before_drop_ = Arc::clone(&num_requests_before_drop); |
| 3642 | let addr = server.http_local_addr(); |
| 3643 | |
| 3644 | let poster = mz_ore::task::spawn(|| "webhook_concurrent_actions-poster", async move { |
| 3645 | let mut i = 0; |
| 3646 | |
| 3647 | let http_client = reqwest::Client::new(); |
| 3648 | let mut tasks = Vec::with_capacity(500); |
| 3649 | |
| 3650 | // Keep sending events until we're told to stop. |
| 3651 | while keep_sending_.load(std::sync::atomic::Ordering::Relaxed) { |
| 3652 | let webhook_url = format!( |
| 3653 | "http://{}/api/webhook/materialize/public/webhook_json", |
| 3654 | addr, |
| 3655 | ); |
| 3656 |
nothing calls this directly
no test coverage detected