Skip to content

Commit f96dc62

Browse files
authored
Merge branch 'develop' into PCESA-3224
2 parents 487510b + d040f2d commit f96dc62

5 files changed

Lines changed: 107 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
### Removed
1616
### Fixed
1717
- [issues/82](https://github.com/podaac/bignbit/issues/82): Fixed date parsing bug where ISO-8601 format dates, the default for UMM-G, were not handled properly.
18+
- Update gibs_response_queue visibility timeout to match aws_lambda_function handle_gitc_response timeout
1819
### Security
1920

2021
## [0.2.4]

examples/cumulus-tf/bin/fake_gitc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def handler(event, context):
1414
logger.info(f"Received event {json.dumps(event)}")
1515

1616
for message in event["Records"]:
17-
response_topic_arn = message['messageAttributes']['response_topic_arn']
17+
response_topic_arn = message['messageAttributes']['response_topic_arn']['stringValue']
1818
message_body = loads(message["body"])
1919
logger.info(f"Processing message {json.dumps(message_body)}")
2020

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "bignbit"
3-
version = "0.3.0a10"
3+
version = "0.3.0a13"
44
description = "Browse image generation and transfer"
55
authors = ["PO.DAAC <podaac@jpl.nasa.gov>"]
66
license = "Apache 2.0"

scripts/performance_test.py

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
"""
2+
This script starts and monitors AWS Step Function executions, calculates execution statistics,
3+
and outputs the results. It uses the boto3 library to interact with AWS Step Functions.
4+
5+
Usage:
6+
python performance_test.py --profile <AWS_PROFILE> --state-machine-arn <STATE_MACHINE_ARN> --count <NUMBER_OF_EXECUTIONS>
7+
8+
Arguments:
9+
--profile: The AWS CLI profile name to use for authentication.
10+
--state-machine-arn: The ARN of the Step Function state machine to execute.
11+
--count: The number of Step Function executions to submit (default is 1).
12+
"""
13+
14+
import pathlib
15+
from os.path import dirname, realpath, basename
16+
import boto3
17+
import datetime
18+
import time
19+
import argparse
20+
import logging
21+
import statistics
22+
23+
# Configure logging
24+
logging.basicConfig(
25+
level=logging.INFO,
26+
format="%(asctime)s - %(levelname)s - %(message)s",
27+
datefmt="%Y-%m-%d %H:%M:%S"
28+
)
29+
30+
# Parse command-line arguments
31+
parser = argparse.ArgumentParser(description="Start and monitor Step Function executions.")
32+
parser.add_argument("--profile", required=True, help="boto3 profile name")
33+
parser.add_argument("--state-machine-arn", required=True, help="Step Function state machine ARN")
34+
parser.add_argument("--count", type=int, default=1, help="Number of Step Function executions to submit")
35+
args = parser.parse_args()
36+
37+
# Create a boto3 session using the specified profile
38+
session = boto3.Session(profile_name=args.profile)
39+
client = session.client('stepfunctions')
40+
now = datetime.datetime.now(tz=datetime.timezone.utc)
41+
42+
# Path to the sample message file
43+
message = pathlib.Path(dirname(realpath(__file__))).joinpath('../tests/sample_messages').joinpath(
44+
'cma.uat.workflow-input.OPERA_L3_DSWx-S1_T45QYD_20241001T121219Z_20241206T065726Z_S1A_30_v1.0.json'
45+
).read_text()
46+
47+
# Dictionary to store submission details
48+
submissions: dict[str, dict] = {}
49+
50+
# Start the specified number of Step Function executions
51+
for i in range(args.count):
52+
response = client.start_execution(
53+
stateMachineArn=args.state_machine_arn,
54+
name=f'{now.strftime("%Y%m%dT%H%M%S")}_{basename(__file__)}_{i}',
55+
input=message
56+
)
57+
logging.info(f"Started execution {i} with ARN: {response['executionArn']}")
58+
submissions[response['executionArn']] = {'i': i} | response
59+
60+
# Monitor the executions until all are complete
61+
all_complete = False
62+
while not all_complete:
63+
all_complete = True
64+
for executionArn, submission in submissions.items():
65+
# Check the status of each execution
66+
if 'status' not in submission or submission['status'] == 'RUNNING':
67+
response = client.describe_execution(
68+
executionArn=executionArn
69+
)
70+
submissions[executionArn].update(response)
71+
if response['status'] == 'RUNNING':
72+
all_complete = False
73+
break
74+
logging.info(f"Execution {submission['i']} is complete with status: {submission['status']}")
75+
if not all_complete:
76+
logging.info("Waiting for executions to complete...")
77+
time.sleep(10)
78+
79+
# Calculate statistics for execution durations
80+
data = [
81+
(sub['stopDate'] - sub['startDate']).total_seconds()
82+
for sub in submissions.values()
83+
if 'stopDate' in sub and 'startDate' in sub
84+
]
85+
86+
# Compute statistical metrics
87+
mean_value = statistics.mean(data)
88+
median_value = statistics.median(data)
89+
try:
90+
mode_value = statistics.mode(data) # Raises StatisticsError if no unique mode
91+
except statistics.StatisticsError:
92+
mode_value = "No unique mode"
93+
stdev_value = statistics.stdev(data)
94+
variance_value = statistics.variance(data)
95+
96+
# Log the calculated statistics
97+
logging.info(f"Count: {len(data)}")
98+
logging.info(f"Mean: {mean_value}")
99+
logging.info(f"Median: {median_value}")
100+
logging.info(f"Mode: {mode_value}")
101+
logging.info(f"Standard Deviation: {stdev_value}")
102+
logging.info(f"Variance: {variance_value}")

terraform/sqs_sns.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ resource "aws_sqs_queue" "gibs_response_queue" {
3434
deadLetterTargetArn = aws_sqs_queue.gibs_response_deadletter.arn
3535
maxReceiveCount = 4
3636
})
37+
visibility_timeout_seconds = 45
3738
}
3839

3940
resource "aws_sqs_queue" "gibs_response_deadletter" {
@@ -111,6 +112,7 @@ resource "aws_iam_role_policy" "allow_lambda_role_to_read_sqs_messages" {
111112
resource "aws_lambda_event_source_mapping" "gibs_response_event_trigger" {
112113
event_source_arn = aws_sqs_queue.gibs_response_queue.arn
113114
function_name = aws_lambda_function.handle_gitc_response.arn
115+
114116
}
115117

116118
data "aws_iam_policy_document" "gibs_request_queue_policy" {

0 commit comments

Comments
 (0)