Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
TingDaoK committed Oct 9, 2024
1 parent 6a3b659 commit 6224930
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 27 deletions.
1 change: 1 addition & 0 deletions include/aws/s3/s3_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ enum aws_s3_meta_request_type {
* - only {bucket}/{key} format is supported for source and passing arn as
* source will not work
* - source bucket is assumed to be in the same region as dest
* - source bucket and dest needs both be directory bucket or regular bucket.
*/
AWS_S3_META_REQUEST_TYPE_COPY_OBJECT,

Expand Down
9 changes: 6 additions & 3 deletions tests/s3_data_plane_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -6289,7 +6289,8 @@ static int s_test_s3_copy_object_helper(
destination_key,
expected_error_code,
expected_response_status,
expected_size);
expected_size,
false);
}

AWS_TEST_CASE(test_s3_copy_small_object, s_test_s3_copy_small_object)
Expand Down Expand Up @@ -6392,7 +6393,8 @@ static int s_test_s3_copy_source_prefixed_by_slash(struct aws_allocator *allocat
destination_key,
AWS_ERROR_SUCCESS,
AWS_HTTP_STATUS_CODE_200_OK,
MB_TO_BYTES(1));
MB_TO_BYTES(1),
false);
}

/**
Expand Down Expand Up @@ -6438,7 +6440,8 @@ static int s_test_s3_copy_source_prefixed_by_slash_multipart(struct aws_allocato
destination_key,
AWS_ERROR_SUCCESS,
AWS_HTTP_STATUS_CODE_200_OK,
MB_TO_BYTES(256));
MB_TO_BYTES(256),
false);
}

static int s_s3_get_object_mrap_helper(struct aws_allocator *allocator, bool multipart) {
Expand Down
14 changes: 8 additions & 6 deletions tests/s3_s3express_client_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -658,16 +658,17 @@ TEST_CASE(s3express_client_copy_object) {
struct aws_byte_cursor source_key = AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("pre-existing-10MB");
struct aws_byte_cursor destination_key = AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("copies/destination_10MB");
struct aws_byte_cursor source_bucket =
AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("aws-c-s3-test-bucket--use1-az4--x-s3");
AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("aws-c-s3-test-bucket--usw2-az1--x-s3");
return aws_test_s3_copy_object_helper(
allocator,
source_bucket,
source_key,
g_test_s3express_bucket_use1_az4_endpoint,
g_test_s3express_bucket_usw2_az1_endpoint,
destination_key,
AWS_ERROR_SUCCESS,
AWS_HTTP_STATUS_CODE_200_OK,
MB_TO_BYTES(10));
MB_TO_BYTES(10),
true);
}

/**
Expand All @@ -679,14 +680,15 @@ TEST_CASE(s3express_client_copy_object_multipart) {
struct aws_byte_cursor source_key = AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("pre-existing-2GB");
struct aws_byte_cursor destination_key = AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("copies/destination_2GB");
struct aws_byte_cursor source_bucket =
AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("aws-c-s3-test-bucket--use1-az4--x-s3");
AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("aws-c-s3-test-bucket--usw2-az1--x-s3");
return aws_test_s3_copy_object_helper(
allocator,
source_bucket,
source_key,
g_test_s3express_bucket_use1_az4_endpoint,
g_test_s3express_bucket_usw2_az1_endpoint,
destination_key,
AWS_ERROR_SUCCESS,
AWS_HTTP_STATUS_CODE_200_OK,
GB_TO_BYTES(2));
GB_TO_BYTES(2),
true);
}
27 changes: 17 additions & 10 deletions tests/s3_tester.c
Original file line number Diff line number Diff line change
Expand Up @@ -2364,15 +2364,16 @@ int aws_test_s3_copy_object_from_x_amz_copy_source(
struct aws_byte_cursor destination_key,
int expected_error_code,
int expected_response_status,
uint64_t expected_size) {
uint64_t expected_size,
bool s3express) {
struct aws_s3_tester tester;
AWS_ZERO_STRUCT(tester);
ASSERT_SUCCESS(aws_s3_tester_init(allocator, &tester));

struct aws_s3_client_config client_config;
AWS_ZERO_STRUCT(client_config);
client_config.enable_s3express = true;
struct aws_byte_cursor region_cursor = aws_byte_cursor_from_c_str("us-east-1");
client_config.enable_s3express = s3express;
struct aws_byte_cursor region_cursor = g_test_s3_region;
client_config.region = region_cursor;
ASSERT_SUCCESS(aws_s3_tester_bind_client(&tester, &client_config, AWS_S3_TESTER_BIND_CLIENT_SIGNING));

Expand All @@ -2387,10 +2388,6 @@ int aws_test_s3_copy_object_from_x_amz_copy_source(

test_data.c_var = (struct aws_condition_variable)AWS_CONDITION_VARIABLE_INIT;
aws_mutex_init(&test_data.mutex);
struct aws_signing_config_aws s3express_signing_config = {
.algorithm = AWS_SIGNING_ALGORITHM_V4_S3EXPRESS,
.service = g_s3express_service_name,
};

struct aws_s3_meta_request_options meta_request_options = {
.user_data = &test_data,
Expand All @@ -2400,10 +2397,18 @@ int aws_test_s3_copy_object_from_x_amz_copy_source(
.progress_callback = s_copy_object_meta_request_progress_callback,
.message = message,
.shutdown_callback = NULL,
.signing_config = &s3express_signing_config,
.signing_config = client_config.signing_config,
.type = AWS_S3_META_REQUEST_TYPE_COPY_OBJECT,
};

if (s3express) {
struct aws_signing_config_aws s3express_signing_config = {
.algorithm = AWS_SIGNING_ALGORITHM_V4_S3EXPRESS,
.service = g_s3express_service_name,
};
meta_request_options.signing_config = &s3express_signing_config;
}

struct aws_s3_meta_request *meta_request = aws_s3_client_make_meta_request(client, &meta_request_options);
ASSERT_NOT_NULL(meta_request);

Expand Down Expand Up @@ -2443,7 +2448,8 @@ int aws_test_s3_copy_object_helper(
struct aws_byte_cursor destination_key,
int expected_error_code,
int expected_response_status,
uint64_t expected_size) {
uint64_t expected_size,
bool s3_express) {

char copy_source_value[1024];
snprintf(
Expand All @@ -2464,5 +2470,6 @@ int aws_test_s3_copy_object_helper(
destination_key,
expected_error_code,
expected_response_status,
expected_size);
expected_size,
s3_express);
}
6 changes: 4 additions & 2 deletions tests/s3_tester.h
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,8 @@ int aws_test_s3_copy_object_helper(
struct aws_byte_cursor destination_key,
int expected_error_code,
int expected_response_status,
uint64_t expected_size);
uint64_t expected_size,
bool s3_express);

/**
* Take the source with x_amz_copy_source, and the destination_endpoint to help testing copy object.
Expand All @@ -538,6 +539,7 @@ int aws_test_s3_copy_object_from_x_amz_copy_source(
struct aws_byte_cursor destination_key,
int expected_error_code,
int expected_response_status,
uint64_t expected_size);
uint64_t expected_size,
bool s3_express);

#endif /* AWS_S3_TESTER_H */
12 changes: 6 additions & 6 deletions tests/test_helper/test_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,13 @@ def cleanup(bucket_name, availability_zone=None, client=s3_client):


if args.action == 'init':
create_bucket_with_lifecycle("use1-az4", s3_client_east1)
# create_bucket_with_lifecycle("use1-az4", s3_client_east1)
create_bucket_with_lifecycle("usw2-az1")
create_bucket_with_lifecycle()
create_bucket_with_public_object()
if os.environ.get('CRT_S3_TEST_BUCKET_NAME') != BUCKET_NAME_BASE:
print(
f"*** Set the environment variable $CRT_S3_TEST_BUCKET_NAME to {BUCKET_NAME_BASE} before running the tests ***")
# create_bucket_with_lifecycle()
# create_bucket_with_public_object()
# if os.environ.get('CRT_S3_TEST_BUCKET_NAME') != BUCKET_NAME_BASE:
# print(
# f"*** Set the environment variable $CRT_S3_TEST_BUCKET_NAME to {BUCKET_NAME_BASE} before running the tests ***")

elif args.action == 'clean':
if "CRT_S3_TEST_BUCKET_NAME" not in os.environ and args.bucket_name is None:
Expand Down

0 comments on commit 6224930

Please sign in to comment.