Skip to content

Commit

Permalink
update: location arn fix
Browse files Browse the repository at this point in the history
  • Loading branch information
heemankv committed Dec 5, 2024
1 parent 21d0a3b commit 118488d
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 56 deletions.
6 changes: 3 additions & 3 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ####
Expand Down Expand Up @@ -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 ####

Expand Down
101 changes: 49 additions & 52 deletions e2e-tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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};
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion scripts/init_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -852,4 +852,4 @@ async function main() {
await setupMongoDb(block_number - 1);
}

main();
main();

0 comments on commit 118488d

Please sign in to comment.