Skip to content

Update Sample Apps aws-sdk-call param name to indicate Test ID #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,18 @@ def healthcheck(request):
def aws_sdk_call(request):
bucket_name = "e2e-test-bucket-name"

# Add an (pod) ID to bucketname to associate buckets to specific test runs
ip = request.GET.get('ip', None)
if ip is not None:
bucket_name += "-" + ip
# Add a unique test ID to bucketname to associate buckets to specific test runs
testing_id = request.GET.get('testingId', None)
if testing_id is not None:
bucket_name += "-" + testing_id
s3_client = boto3.client("s3")
try:
s3_client.get_bucket_location(
Bucket=bucket_name,
)
except Exception as e:
# bucket_name does not exist, so this is expected.
logger.error("Error occurred when trying to get bucket location of: " + bucket_name)
logger.error("Could not retrieve http request:" + str(e))

return get_xray_trace_id()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,19 @@ public String healthcheck() {
// test aws calls instrumentation
@GetMapping("/aws-sdk-call")
@ResponseBody
public String awssdkCall(@RequestParam(name = "ip", required = false) String ip) {
public String awssdkCall(@RequestParam(name = "testingId", required = false) String testingId) {
String bucketName = "e2e-test-bucket-name";
// Add an (pod) ID to bucketname to associate buckets to specific test runs
if (ip != null) {
bucketName += "-" + ip;
// Add a unique test ID to bucketname to associate buckets to specific test runs
if (testingId != null) {
bucketName += "-" + testingId;
}
GetBucketLocationRequest bucketLocationRequest =
GetBucketLocationRequest.builder().bucket(bucketName).build();
try {
s3.getBucketLocation(bucketLocationRequest);
} catch (Exception e) {
// e2e-test-bucket-name does not exist, so this is expected.
// bucketName does not exist, so this is expected.
logger.error("Error occurred when trying to get bucket location of: " + bucketName);
logger.error("Could not retrieve http request:" + e.getLocalizedMessage());
}
return getXrayTraceId();
Expand Down