From e95b03234ff6b454641054a88c2ba294219ea3e4 Mon Sep 17 00:00:00 2001 From: Thomas Heartman Date: Mon, 16 Dec 2024 11:19:14 +0100 Subject: [PATCH] remove new param --- server/src/client_api.rs | 10 ------ server/src/http/broadcaster.rs | 2 -- server/src/lib.rs | 58 +--------------------------------- 3 files changed, 1 insertion(+), 69 deletions(-) diff --git a/server/src/client_api.rs b/server/src/client_api.rs index 6eb793ea..11683643 100644 --- a/server/src/client_api.rs +++ b/server/src/client_api.rs @@ -690,12 +690,10 @@ mod tests { let upstream_features_cache = Arc::new(DashMap::default()); let upstream_engine_cache = Arc::new(DashMap::default()); upstream_token_cache.insert(token.token.clone(), token.clone()); - let broadcaster = Broadcaster::new(upstream_features_cache.clone()); let srv = upstream_server( upstream_token_cache, upstream_features_cache, upstream_engine_cache, - broadcaster.clone(), ) .await; let req = reqwest::Client::new(); @@ -731,12 +729,10 @@ mod tests { let upstream_features_cache = Arc::new(DashMap::default()); let upstream_engine_cache = Arc::new(DashMap::default()); upstream_token_cache.insert(frontend_token.token.clone(), frontend_token.clone()); - let broadcaster = Broadcaster::new(upstream_features_cache.clone()); let srv = upstream_server( upstream_token_cache, upstream_features_cache, upstream_engine_cache, - broadcaster.clone(), ) .await; let client = UnleashClient::new(srv.url("/").as_str(), None).unwrap(); @@ -999,12 +995,10 @@ mod tests { Arc::new(DashMap::default()); let upstream_token_cache: Arc> = Arc::new(DashMap::default()); let upstream_engine_cache: Arc> = Arc::new(DashMap::default()); - let broadcaster = Broadcaster::new(upstream_features_cache.clone()); let server = upstream_server( upstream_token_cache.clone(), upstream_features_cache.clone(), upstream_engine_cache.clone(), - broadcaster.clone(), ) .await; let upstream_features = features_from_disk("../examples/hostedexample.json"); @@ -1065,12 +1059,10 @@ mod tests { Arc::new(DashMap::default()); let upstream_token_cache: Arc> = Arc::new(DashMap::default()); let upstream_engine_cache: Arc> = Arc::new(DashMap::default()); - let broadcaster = Broadcaster::new(upstream_features_cache.clone()); let server = upstream_server( upstream_token_cache.clone(), upstream_features_cache.clone(), upstream_engine_cache.clone(), - broadcaster.clone(), ) .await; let upstream_features = features_from_disk("../examples/hostedexample.json"); @@ -1190,12 +1182,10 @@ mod tests { Arc::new(DashMap::default()); let upstream_token_cache: Arc> = Arc::new(DashMap::default()); let upstream_engine_cache: Arc> = Arc::new(DashMap::default()); - let broadcaster = Broadcaster::new(upstream_features_cache.clone()); let server = upstream_server( upstream_token_cache.clone(), upstream_features_cache.clone(), upstream_engine_cache.clone(), - broadcaster.clone(), ) .await; let upstream_features = features_from_disk("../examples/hostedexample.json"); diff --git a/server/src/http/broadcaster.rs b/server/src/http/broadcaster.rs index 2bf9146f..0b4a4250 100644 --- a/server/src/http/broadcaster.rs +++ b/server/src/http/broadcaster.rs @@ -206,5 +206,3 @@ impl Broadcaster { let _ = future::join_all(send_events).await; } } - -// e2e test? -> test module in the test folder (makes it a separate compilation unit; will increase test compliation time) diff --git a/server/src/lib.rs b/server/src/lib.rs index 31dc001d..e3e7547e 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -28,7 +28,7 @@ pub mod tokens; pub mod types; pub mod urls; #[cfg(test)] -pub mod tests { +mod tests { use std::fs; use std::io::BufReader; use std::path::PathBuf; @@ -59,65 +59,10 @@ pub mod tests { serde_json::from_reader(reader).unwrap() } - pub async fn edge_server(upstream_url: &str) -> TestServer { - let unleash_client = Arc::new(UnleashClient::new(upstream_url, None).unwrap()); - - let features_cache: Arc> = Arc::new(DashMap::default()); - let token_cache: Arc> = Arc::new(DashMap::default()); - let engine_cache: Arc> = Arc::new(DashMap::default()); - let broadcaster = Broadcaster::new(features_cache.clone()); - let feature_refresher = Arc::new(FeatureRefresher { - unleash_client: unleash_client.clone(), - features_cache: features_cache.clone(), - engine_cache: engine_cache.clone(), - refresh_interval: Duration::seconds(6000), - broadcaster: broadcaster.clone(), - ..Default::default() - }); - let token_validator = Arc::new(TokenValidator { - unleash_client: unleash_client.clone(), - token_cache: token_cache.clone(), - persistence: None, - }); - test_server(move || { - let config = serde_qs::actix::QsQueryConfig::default() - .qs_config(serde_qs::Config::new(5, false)); - let metrics_cache = MetricsCache::default(); - let connect_via = ConnectVia { - app_name: "edge".into(), - instance_id: "testinstance".into(), - }; - HttpService::new(map_config( - App::new() - .app_data(config) - .app_data(web::Data::from(token_validator.clone())) - .app_data(web::Data::from(features_cache.clone())) - .app_data(web::Data::from(broadcaster.clone())) - .app_data(web::Data::from(engine_cache.clone())) - .app_data(web::Data::from(token_cache.clone())) - .app_data(web::Data::new(metrics_cache)) - .app_data(web::Data::new(connect_via)) - .app_data(web::Data::from(feature_refresher.clone())) - .service( - web::scope("/api") - .configure(crate::client_api::configure_client_api) - .configure(|cfg| { - crate::frontend_api::configure_frontend_api(cfg, false) - }), - ) - .service(web::scope("/edge").configure(crate::edge_api::configure_edge_api)), - |_| AppConfig::default(), - )) - .tcp() - }) - .await - } - pub async fn upstream_server( upstream_token_cache: Arc>, upstream_features_cache: Arc>, upstream_engine_cache: Arc>, - upstream_broadcaster: Arc, ) -> TestServer { let token_validator = Arc::new(TokenValidator { unleash_client: Arc::new(Default::default()), @@ -138,7 +83,6 @@ pub mod tests { .app_data(config) .app_data(web::Data::from(token_validator.clone())) .app_data(web::Data::from(upstream_features_cache.clone())) - .app_data(web::Data::from(upstream_broadcaster.clone())) .app_data(web::Data::from(upstream_engine_cache.clone())) .app_data(web::Data::from(upstream_token_cache.clone())) .app_data(web::Data::new(metrics_cache))