Skip to content

Commit

Permalink
update: PR review changes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
heemankv committed Sep 5, 2024
1 parent 5a57002 commit 56f1e56
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 219 deletions.
27 changes: 0 additions & 27 deletions crates/orchestrator/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,33 +147,6 @@ impl Config {
}
}

/// The app config. It can be accessed from anywhere inside the service.
/// It's initialized only once.
/// We are using `ArcSwap` as it allow us to replace the new `Config` with
/// a new one which is required when running test cases. This approach was
/// inspired from here - https://github.com/matklad/once_cell/issues/127
// pub static CONFIG: OnceCell<ArcSwap<Config>> = OnceCell::const_new();

/// Returns the app config. Initializes if not already done.
// pub async fn config() -> Guard<Arc<Config>> {
// let cfg = CONFIG.get_or_init(|| async { ArcSwap::from_pointee(init_config().await) }).await;
// cfg.load()
// }

/// OnceCell only allows us to initialize the config once and that's how it should be on production.
/// However, when running tests, we often want to reinitialize because we want to clear the DB and
/// set it up again for reuse in new tests. By calling `config_force_init` we replace the already
/// stored config inside `ArcSwap` with the new configuration and pool settings.
// #[cfg(test)]
// pub async fn config_force_init(config: Config) {
// match CONFIG.get() {
// Some(arc) => arc.store(Arc::new(config)),
// None => {
// CONFIG.get_or_init(|| async { ArcSwap::from_pointee(config) }).await;
// }
// }
// }

/// Builds the DA client based on the environment variable DA_LAYER
pub async fn build_da_client() -> Box<dyn DaClient + Send + Sync> {
match get_env_var_or_panic("DA_LAYER").as_str() {
Expand Down
4 changes: 2 additions & 2 deletions crates/orchestrator/src/tests/alerts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ use tokio::time::sleep;
use utils::env_utils::get_env_var_or_panic;

use crate::tests::common::{get_sns_client, get_sqs_client};
use crate::tests::config::{ClientValue, TestConfigBuilder};
use crate::tests::config::{ConfigType, TestConfigBuilder};

pub const SNS_ALERT_TEST_QUEUE: &str = "orchestrator_sns_alert_testing_queue";

#[rstest]
#[tokio::test]
async fn sns_alert_subscribe_to_topic_receive_alert_works() {
let services = TestConfigBuilder::new().configure_alerts(ClientValue::Actual).build().await;
let services = TestConfigBuilder::new().configure_alerts(ConfigType::Actual).build().await;

let sqs_client = get_sqs_client().await;
let queue = sqs_client.create_queue().queue_name(SNS_ALERT_TEST_QUEUE).send().await.unwrap();
Expand Down
Loading

0 comments on commit 56f1e56

Please sign in to comment.