diff --git a/.env.test b/.env.test index 160845f6..c80d4784 100644 --- a/.env.test +++ b/.env.test @@ -3,8 +3,7 @@ AWS_ACCESS_KEY_ID=AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY=AWS_SECRET_ACCESS_KEY -AWS_REGION=us-east-1 -MADARA_ORCHESTRATOR_AWS_BUCKET_LOCATION_CONSTRAINT=us-west-1 +AWS_REGION=us-west-1 # For Aws sdk AWS_ENDPOINT_URL=http://localhost.localstack.cloud:4566 # For Omniqueue @@ -20,7 +19,7 @@ MADARA_ORCHESTRATOR_EVENT_BRIDGE_TRIGGER_POLICY_NAME=madara-orchestrator-worker- #### ALERTS #### -MADARA_ORCHESTRATOR_AWS_SNS_ARN=arn:aws:sns:us-east-1:000000000000:madara-orchestrator-arn +MADARA_ORCHESTRATOR_AWS_SNS_ARN=arn:aws:sns:us-west-1:000000000000:madara-orchestrator-arn #### DATA AVAILABILITY #### @@ -67,7 +66,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-east-1.localhost.localstack.cloud:4566/000000000000 +MADARA_ORCHESTRATOR_SQS_BASE_QUEUE_URL=http://sqs.us-west-1.localhost.localstack.cloud:4566/000000000000 #### SETTLEMENT #### diff --git a/crates/orchestrator/src/cli/mod.rs b/crates/orchestrator/src/cli/mod.rs index 06e367a7..b17d9369 100644 --- a/crates/orchestrator/src/cli/mod.rs +++ b/crates/orchestrator/src/cli/mod.rs @@ -393,10 +393,6 @@ pub mod validate_params { if aws_s3_args.aws_s3 && aws_config_args.aws { Ok(StorageValidatedArgs::AWSS3(AWSS3ValidatedArgs { bucket_name: aws_s3_args.bucket_name.clone().expect("Bucket name is required"), - bucket_location_constraint: aws_s3_args - .bucket_location_constraint - .clone() - .expect("Bucket Location Constraint is required"), })) } else { Err("Only AWS S3 is supported as of now".to_string()) diff --git a/crates/orchestrator/src/data_storage/aws_s3/mod.rs b/crates/orchestrator/src/data_storage/aws_s3/mod.rs index 2984d246..a94b2a1c 100644 --- a/crates/orchestrator/src/data_storage/aws_s3/mod.rs +++ b/crates/orchestrator/src/data_storage/aws_s3/mod.rs @@ -15,14 +15,13 @@ pub const S3_SETTINGS_NAME: &str = "s3"; #[derive(Debug, Clone)] pub struct AWSS3ValidatedArgs { pub bucket_name: String, - pub bucket_location_constraint: String, } /// AWSS3 represents AWS S3 client object containing the client and the config itself. pub struct AWSS3 { client: Client, bucket: String, - bucket_location_constraint: String, + bucket_location_constraint: BucketLocationConstraint, } /// Implementation for AWS S3 client. Contains the function for : @@ -36,10 +35,13 @@ impl AWSS3 { // this is necessary for it to work with localstack in test cases s3_config_builder.set_force_path_style(Some(true)); let client = Client::from_conf(s3_config_builder.build()); + + let region_str = aws_config.region().expect("Could not get region as string").to_string(); + let location_constraint: BucketLocationConstraint = BucketLocationConstraint::from_str(region_str.as_str()).expect("Could not get location constraint from region string"); Self { client, bucket: s3_config.bucket_name.clone(), - bucket_location_constraint: s3_config.bucket_location_constraint.clone(), + bucket_location_constraint: location_constraint, } } } @@ -90,8 +92,7 @@ impl DataStorage for AWSS3 { async fn create_bucket(&self, bucket_name: &str) -> Result<()> { let create_bucket_config = Some( CreateBucketConfiguration::builder() - // TODO: assign region based on env - .location_constraint(BucketLocationConstraint::from_str(self.bucket_location_constraint.as_str()).expect("Could not decode location constraint")) + .location_constraint(self.bucket_location_constraint.clone()) .build(), ); diff --git a/crates/orchestrator/src/queue/job_queue.rs b/crates/orchestrator/src/queue/job_queue.rs index 636ce742..1527f493 100644 --- a/crates/orchestrator/src/queue/job_queue.rs +++ b/crates/orchestrator/src/queue/job_queue.rs @@ -44,16 +44,12 @@ pub struct JobQueueMessage { } #[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Display)] +#[strum(serialize_all = "PascalCase")] pub enum WorkerTriggerType { - #[strum(serialize = "Snos")] Snos, - #[strum(serialize = "Proving")] Proving, - #[strum(serialize = "ProofRegistration")] ProofRegistration, - #[strum(serialize = "DataSubmission")] DataSubmission, - #[strum(serialize = "UpdateState")] UpdateState, } diff --git a/crates/orchestrator/src/tests/config.rs b/crates/orchestrator/src/tests/config.rs index 7f883fd0..e46fdc23 100644 --- a/crates/orchestrator/src/tests/config.rs +++ b/crates/orchestrator/src/tests/config.rs @@ -495,7 +495,6 @@ fn get_env_params() -> EnvParams { let storage_params = StorageValidatedArgs::AWSS3(AWSS3ValidatedArgs { bucket_name: get_env_var_or_panic("MADARA_ORCHESTRATOR_AWS_S3_BUCKET_NAME"), - bucket_location_constraint: get_env_var_or_panic("MADARA_ORCHESTRATOR_AWS_BUCKET_LOCATION_CONSTRAINT"), }); let queue_params = QueueValidatedArgs::AWSSQS(AWSSQSValidatedArgs { diff --git a/e2e-tests/tests.rs b/e2e-tests/tests.rs index cc02e029..9430109d 100644 --- a/e2e-tests/tests.rs +++ b/e2e-tests/tests.rs @@ -174,7 +174,7 @@ async fn test_orchestrator_workflow(#[case] l2_block_number: String) { let target_queue_name = &get_env_var_or_panic("MADARA_ORCHESTRATOR_EVENT_BRIDGE_TARGET_QUEUE_NAME"); // Setup eventbridge rules - create_eventbridge_rule(trigger_rule_name, target_queue_name).await.expect( + create_event_bridge_rule(trigger_rule_name, target_queue_name).await.expect( "Unable to create event bridge rule", ); @@ -239,7 +239,7 @@ 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<()> { +async fn create_event_bridge_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);