From 118488d6c226460ffbf7bcfa01483ee1f27a9eb3 Mon Sep 17 00:00:00 2001 From: Heemank Verma Date: Thu, 5 Dec 2024 13:52:28 +0530 Subject: [PATCH] update: location arn fix --- .env.test | 6 +-- e2e-tests/tests.rs | 101 ++++++++++++++++++++---------------------- scripts/init_state.js | 2 +- 3 files changed, 53 insertions(+), 56 deletions(-) diff --git a/.env.test b/.env.test index d7a31179..62d74916 100644 --- a/.env.test +++ b/.env.test @@ -3,7 +3,7 @@ AWS_ACCESS_KEY_ID=AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY=AWS_SECRET_ACCESS_KEY -AWS_REGION=us-west-1 +AWS_REGION=us-east-1 # For Aws sdk AWS_ENDPOINT_URL=http://localhost.localstack.cloud:4566 @@ -18,7 +18,7 @@ MADARA_ORCHESTRATOR_EVENT_BRIDGE_TRIGGER_RULE_NAME=madara-orchestrator-worker-tr #### ALERTS #### -MADARA_ORCHESTRATOR_AWS_SNS_ARN=arn:aws:sns:us-west-1:000000000000:madara-orchestrator-arn +MADARA_ORCHESTRATOR_AWS_SNS_ARN=arn:aws:sns:us-east-1:000000000000:madara-orchestrator-arn #### DATA AVAILABILITY #### @@ -65,7 +65,7 @@ MADARA_ORCHESTRATOR_ATLANTIC_RPC_NODE_URL=http://127.0.0.1:8545 MADARA_ORCHESTRATOR_SQS_PREFIX=madara_orchestrator MADARA_ORCHESTRATOR_SQS_SUFFIX=queue MADARA_ORCHESTRATOR_EVENT_BRIDGE_TARGET_QUEUE_NAME=madara_orchestrator_worker_trigger_queue -MADARA_ORCHESTRATOR_SQS_BASE_QUEUE_URL=http://sqs.us-west-1.localhost.localstack.cloud:4566/000000000000 +MADARA_ORCHESTRATOR_SQS_BASE_QUEUE_URL=http://sqs.us-east-1.localhost.localstack.cloud:4566/000000000000 #### SETTLEMENT #### diff --git a/e2e-tests/tests.rs b/e2e-tests/tests.rs index 6d10d7da..d0b9e31a 100644 --- a/e2e-tests/tests.rs +++ b/e2e-tests/tests.rs @@ -4,8 +4,6 @@ use std::io::Read; use std::time::{Duration, Instant}; use aws_config::meta::region::RegionProviderChain; -use aws_sdk_eventbridge::types::{InputTransformer, RuleState, Target}; -use aws_sdk_sqs::types::QueueAttributeName; use chrono::{SubsecRound, Utc}; use e2e_tests::anvil::AnvilSetup; use e2e_tests::mock_server::MockResponseBodyType; @@ -15,7 +13,6 @@ use e2e_tests::utils::{get_mongo_db_client, read_state_update_from_file, vec_u8_ use e2e_tests::{MongoDbServer, Orchestrator}; use mongodb::bson::doc; use orchestrator::cli::database::DatabaseValidatedArgs; -use orchestrator::cron::{get_worker_trigger_message, WORKER_TRIGGERS}; use orchestrator::data_storage::DataStorage; use orchestrator::database::mongodb::MongoDBValidatedArgs; use orchestrator::jobs::constants::{JOB_METADATA_SNOS_BLOCK, JOB_METADATA_STATE_UPDATE_BLOCKS_TO_SETTLE_KEY}; @@ -240,55 +237,55 @@ async fn test_orchestrator_workflow(#[case] l2_block_number: String) { /// Function that adds rules to tests for localstack /// This can be removed after https://github.com/localstack/localstack/issues/9861 is closed -async fn create_eventbridge_rule(trigger_rule_name: &String, target_queue_name: &String) -> color_eyre::Result<()> { - let aws_config = &aws_config::from_env().load().await; - - let queue_client = aws_sdk_sqs::Client::new(aws_config); - - let event_bridge_client = aws_sdk_eventbridge::Client::new(aws_config); - - let queue_url = queue_client.get_queue_url().queue_name(target_queue_name).send().await?; - - let queue_attributes = queue_client - .get_queue_attributes() - .queue_url(queue_url.queue_url.unwrap()) - .attribute_names(QueueAttributeName::QueueArn) - .send() - .await?; - let queue_arn = queue_attributes.attributes().unwrap().get(&QueueAttributeName::QueueArn).unwrap(); - - // Create the EventBridge target with the input transformer - - for trigger in WORKER_TRIGGERS.iter() { - let message = get_worker_trigger_message(trigger.clone())?; - let input_transformer = - InputTransformer::builder().input_paths_map("time", "$.time").input_template(message).build()?; - - let trigger_name = format!("{}-{}", trigger_rule_name, trigger); - event_bridge_client - .put_rule() - .name(trigger_name.clone()) - .schedule_expression("rate(1 minute)") - .state(RuleState::Enabled) - .send() - .await?; - - event_bridge_client - .put_targets() - .rule(trigger_name.clone()) - .targets( - Target::builder() - .id(uuid::Uuid::new_v4().to_string()) - .arn(queue_arn) - .input_transformer(input_transformer.clone()) - .build()?, - ) - .send() - .await?; - } - - Ok(()) -} +// async fn create_eventbridge_rule(trigger_rule_name: &String, target_queue_name: &String) -> color_eyre::Result<()> { +// let aws_config = &aws_config::from_env().load().await; + +// let queue_client = aws_sdk_sqs::Client::new(aws_config); + +// let event_bridge_client = aws_sdk_eventbridge::Client::new(aws_config); + +// let queue_url = queue_client.get_queue_url().queue_name(target_queue_name).send().await?; + +// let queue_attributes = queue_client +// .get_queue_attributes() +// .queue_url(queue_url.queue_url.unwrap()) +// .attribute_names(QueueAttributeName::QueueArn) +// .send() +// .await?; +// let queue_arn = queue_attributes.attributes().unwrap().get(&QueueAttributeName::QueueArn).unwrap(); + +// // Create the EventBridge target with the input transformer + +// for trigger in WORKER_TRIGGERS.iter() { +// let message = get_worker_trigger_message(trigger.clone())?; +// let input_transformer = +// InputTransformer::builder().input_paths_map("time", "$.time").input_template(message).build()?; + +// let trigger_name = format!("{}-{}", trigger_rule_name, trigger); +// event_bridge_client +// .put_rule() +// .name(trigger_name.clone()) +// .schedule_expression("rate(1 minute)") +// .state(RuleState::Enabled) +// .send() +// .await?; + +// event_bridge_client +// .put_targets() +// .rule(trigger_name.clone()) +// .targets( +// Target::builder() +// .id(uuid::Uuid::new_v4().to_string()) +// .arn(queue_arn) +// .input_transformer(input_transformer.clone()) +// .build()?, +// ) +// .send() +// .await?; +// } + +// Ok(()) +// } /// Function to check db for expected state continuously async fn wait_for_db_state( diff --git a/scripts/init_state.js b/scripts/init_state.js index a5cb3a09..0c041972 100644 --- a/scripts/init_state.js +++ b/scripts/init_state.js @@ -852,4 +852,4 @@ async function main() { await setupMongoDb(block_number - 1); } -main(); \ No newline at end of file +main();