Skip to content

Commit

Permalink
remove new param
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasheartman committed Dec 16, 2024
1 parent 9f86bef commit e95b032
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 69 deletions.
10 changes: 0 additions & 10 deletions server/src/client_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -999,12 +995,10 @@ mod tests {
Arc::new(DashMap::default());
let upstream_token_cache: Arc<DashMap<String, EdgeToken>> = Arc::new(DashMap::default());
let upstream_engine_cache: Arc<DashMap<String, EngineState>> = 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");
Expand Down Expand Up @@ -1065,12 +1059,10 @@ mod tests {
Arc::new(DashMap::default());
let upstream_token_cache: Arc<DashMap<String, EdgeToken>> = Arc::new(DashMap::default());
let upstream_engine_cache: Arc<DashMap<String, EngineState>> = 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");
Expand Down Expand Up @@ -1190,12 +1182,10 @@ mod tests {
Arc::new(DashMap::default());
let upstream_token_cache: Arc<DashMap<String, EdgeToken>> = Arc::new(DashMap::default());
let upstream_engine_cache: Arc<DashMap<String, EngineState>> = 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");
Expand Down
2 changes: 0 additions & 2 deletions server/src/http/broadcaster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
58 changes: 1 addition & 57 deletions server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<DashMap<String, ClientFeatures>> = Arc::new(DashMap::default());
let token_cache: Arc<DashMap<String, EdgeToken>> = Arc::new(DashMap::default());
let engine_cache: Arc<DashMap<String, EngineState>> = 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<DashMap<String, EdgeToken>>,
upstream_features_cache: Arc<DashMap<String, ClientFeatures>>,
upstream_engine_cache: Arc<DashMap<String, EngineState>>,
upstream_broadcaster: Arc<Broadcaster>,
) -> TestServer {
let token_validator = Arc::new(TokenValidator {
unleash_client: Arc::new(Default::default()),
Expand All @@ -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))
Expand Down

0 comments on commit e95b032

Please sign in to comment.