Skip to content

Commit d521c66

Browse files
Merge pull request #677 from versity/test_cmdline_more_user_ops
Test cmdline more user ops
2 parents 733b6e7 + c580947 commit d521c66

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+819
-467
lines changed

.github/workflows/system.yml

+11-11
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ jobs:
88
fail-fast: false
99
matrix:
1010
include:
11-
#- set: 1
12-
# LOCAL_FOLDER: /tmp/gw1
13-
# BUCKET_ONE_NAME: versity-gwtest-bucket-one-1
14-
# BUCKET_TWO_NAME: versity-gwtest-bucket-two-1
15-
# IAM_TYPE: folder
16-
# USERS_FOLDER: /tmp/iam1
17-
# AWS_ENDPOINT_URL: https://127.0.0.1:7070
18-
# RUN_SET: "s3cmd"
19-
# RECREATE_BUCKETS: "true"
20-
# PORT: 7070
21-
# BACKEND: "posix"
11+
- set: 1
12+
LOCAL_FOLDER: /tmp/gw1
13+
BUCKET_ONE_NAME: versity-gwtest-bucket-one-1
14+
BUCKET_TWO_NAME: versity-gwtest-bucket-two-1
15+
IAM_TYPE: folder
16+
USERS_FOLDER: /tmp/iam1
17+
AWS_ENDPOINT_URL: https://127.0.0.1:7070
18+
RUN_SET: "s3cmd"
19+
RECREATE_BUCKETS: "true"
20+
PORT: 7070
21+
BACKEND: "posix"
2222
- set: 2
2323
LOCAL_FOLDER: /tmp/gw2
2424
BUCKET_ONE_NAME: versity-gwtest-bucket-one-2

tests/commands/abort_multipart_upload.sh

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env bash
22

33
abort_multipart_upload() {
4+
record_command "abort-multipart-upload" "client:s3api"
45
if [ $# -ne 3 ]; then
56
log 2 "'abort multipart upload' command requires bucket, key, upload ID"
67
return 1
@@ -13,6 +14,7 @@ abort_multipart_upload() {
1314
}
1415

1516
abort_multipart_upload_with_user() {
17+
record_command "abort-multipart-upload" "client:s3api"
1618
if [ $# -ne 5 ]; then
1719
log 2 "'abort multipart upload' command requires bucket, key, upload ID, username, password"
1820
return 1

tests/commands/complete_multipart_upload.sh

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env bash
22

33
complete_multipart_upload() {
4+
record_command "complete-multipart-upload" "client:s3api"
45
if [[ $# -ne 4 ]]; then
56
log 2 "'complete multipart upload' command requires bucket, key, upload ID, parts list"
67
return 1

tests/commands/copy_object.sh

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env bash
22

33
copy_object() {
4+
record-command "copy-object" "client:$1"
45
if [ $# -ne 4 ]; then
56
echo "copy object command requires command type, source, bucket, key"
67
return 1
@@ -29,6 +30,7 @@ copy_object() {
2930
}
3031

3132
copy_object_empty() {
33+
record-command "copy-object" "client:s3api"
3234
error=$(aws --no-verify-ssl s3api copy-object 2>&1) || local result=$?
3335
if [[ $result -eq 0 ]]; then
3436
log 2 "copy object with empty parameters returned no error"

tests/commands/create_bucket.sh

+4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
#!/usr/bin/env bash
22

3+
source ./tests/report.sh
4+
35
# create an AWS bucket
46
# param: bucket name
57
# return 0 for success, 1 for failure
68
create_bucket() {
9+
record_command "create-bucket" "client:$1"
710
if [ $# -ne 2 ]; then
811
log 2 "create bucket missing command type, bucket name"
912
return 1
@@ -33,6 +36,7 @@ create_bucket() {
3336
}
3437

3538
create_bucket_object_lock_enabled() {
39+
record_command "create-bucket" "client:s3api"
3640
if [ $# -ne 1 ]; then
3741
log 2 "create bucket missing bucket name"
3842
return 1

tests/commands/create_multipart_upload.sh

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# params: bucket, key
55
# return 0 for success, 1 for failure
66
create_multipart_upload() {
7+
record_command "create-multipart-upload" "client:s3api"
78
if [ $# -ne 2 ]; then
89
log 2 "create multipart upload function must have bucket, key"
910
return 1
@@ -24,6 +25,7 @@ create_multipart_upload() {
2425
}
2526

2627
create_multipart_upload_with_user() {
28+
record_command "create-multipart-upload" "client:s3api"
2729
if [ $# -ne 4 ]; then
2830
log 2 "create multipart upload function must have bucket, key, username, password"
2931
return 1
@@ -44,6 +46,7 @@ create_multipart_upload_with_user() {
4446
}
4547

4648
create_multipart_upload_params() {
49+
record_command "create-multipart-upload" "client:s3api"
4750
if [ $# -ne 8 ]; then
4851
log 2 "create multipart upload function with params must have bucket, key, content type, metadata, object lock legal hold status, " \
4952
"object lock mode, object lock retain until date, and tagging"
@@ -71,6 +74,7 @@ create_multipart_upload_params() {
7174
}
7275

7376
create_multipart_upload_custom() {
77+
record_command "create-multipart-upload" "client:s3api"
7478
if [ $# -lt 2 ]; then
7579
log 2 "create multipart upload custom function must have at least bucket and key"
7680
return 1

tests/commands/delete_bucket.sh

+6
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@
44
# param: bucket name
55
# return 0 for success, 1 for failure
66
delete_bucket() {
7+
record_command "delete-bucket" "client:$1"
78
if [ $# -ne 2 ]; then
89
log 2 "delete bucket missing command type, bucket name"
910
return 1
1011
fi
1112

13+
if [[ ( $RECREATE_BUCKETS == "false" ) && (( "$2" == "$BUCKET_ONE_NAME" ) || ( "$2" == "$BUCKET_TWO_NAME" )) ]]; then
14+
log 2 "attempt to delete main buckets in static mode"
15+
return 1
16+
fi
17+
1218
local exit_code=0
1319
local error
1420
if [[ $1 == 's3' ]]; then

tests/commands/delete_bucket_policy.sh

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env bash
22

33
delete_bucket_policy() {
4+
record_command "delete-bucket-policy" "client:$1"
45
if [[ $# -ne 2 ]]; then
56
log 2 "delete bucket policy command requires command type, bucket"
67
return 1
@@ -23,6 +24,7 @@ delete_bucket_policy() {
2324
}
2425

2526
delete_bucket_policy_with_user() {
27+
record_command "delete-bucket-policy" "client:s3api"
2628
if [[ $# -ne 3 ]]; then
2729
log 2 "'delete bucket policy with user' command requires bucket, username, password"
2830
return 1
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
delete_bucket_tagging() {
4+
record_command "delete-bucket-tagging" "client:$1"
5+
if [ $# -ne 2 ]; then
6+
log 2 "delete bucket tagging command missing command type, bucket name"
7+
return 1
8+
fi
9+
local result
10+
if [[ $1 == 'aws' ]]; then
11+
tags=$(aws --no-verify-ssl s3api delete-bucket-tagging --bucket "$2" 2>&1) || result=$?
12+
elif [[ $1 == 'mc' ]]; then
13+
tags=$(mc --insecure tag remove "$MC_ALIAS"/"$2" 2>&1) || result=$?
14+
else
15+
log 2 "invalid command type $1"
16+
return 1
17+
fi
18+
if [[ $result -ne 0 ]]; then
19+
log 2 "error deleting bucket tagging: $tags"
20+
return 1
21+
fi
22+
return 0
23+
}

tests/commands/delete_object.sh

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env bash
22

33
delete_object() {
4+
record_command "delete-object" "client:$1"
45
if [ $# -ne 3 ]; then
56
log 2 "delete object command requires command type, bucket, key"
67
return 1
@@ -28,6 +29,7 @@ delete_object() {
2829
}
2930

3031
delete_object_with_user() {
32+
record_command "delete-object" "client:$1"
3133
if [ $# -ne 5 ]; then
3234
log 2 "delete object with user command requires command type, bucket, key, access ID, secret key"
3335
return 1

tests/commands/delete_object_tagging.sh

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env bash
22

33
delete_object_tagging() {
4+
record_command "delete-object-tagging" "client:$1"
45
if [[ $# -ne 3 ]]; then
56
echo "delete object tagging command missing command type, bucket, key"
67
return 1

tests/commands/delete_objects.sh

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
delete_objects() {
4+
record_command "delete-objects" "client:s3api"
5+
if [[ $# -ne 3 ]]; then
6+
log 2 "'delete-objects' command requires bucket name, two object keys"
7+
return 1
8+
fi
9+
if ! error=$(aws --no-verify-ssl s3api delete-objects --bucket "$1" --delete "{
10+
\"Objects\": [
11+
{\"Key\": \"$2\"},
12+
{\"Key\": \"$3\"}
13+
]
14+
}" 2>&1); then
15+
log 2 "error deleting objects: $error"
16+
return 1
17+
fi
18+
return 0
19+
}

tests/commands/get_bucket_acl.sh

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env bash
22

33
get_bucket_acl() {
4+
record_command "get-bucket-acl" "client:$1"
45
if [ $# -ne 2 ]; then
56
log 2 "bucket ACL command missing command type, bucket name"
67
return 1
@@ -22,6 +23,7 @@ get_bucket_acl() {
2223
}
2324

2425
get_bucket_acl_with_user() {
26+
record_command "get-bucket-acl" "client:s3api"
2527
if [ $# -ne 3 ]; then
2628
log 2 "'get bucket ACL with user' command requires bucket name, username, password"
2729
return 1

tests/commands/get_bucket_location.sh

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env bash
22

33
get_bucket_location() {
4+
record_command "get-bucket-location" "client:$1"
45
if [[ $# -ne 2 ]]; then
56
echo "get bucket location command requires command type, bucket name"
67
return 1
@@ -23,6 +24,7 @@ get_bucket_location() {
2324
}
2425

2526
get_bucket_location_aws() {
27+
record_command "get-bucket-location" "client:s3api"
2628
if [[ $# -ne 1 ]]; then
2729
echo "get bucket location (aws) requires bucket name"
2830
return 1
@@ -38,6 +40,7 @@ get_bucket_location_aws() {
3840
}
3941

4042
get_bucket_location_s3cmd() {
43+
record_command "get-bucket-location" "client:s3cmd"
4144
if [[ $# -ne 1 ]]; then
4245
echo "get bucket location (s3cmd) requires bucket name"
4346
return 1
@@ -53,6 +56,7 @@ get_bucket_location_s3cmd() {
5356
}
5457

5558
get_bucket_location_mc() {
59+
record_command "get-bucket-location" "client:mc"
5660
if [[ $# -ne 1 ]]; then
5761
echo "get bucket location (mc) requires bucket name"
5862
return 1

tests/commands/get_bucket_ownership_controls.sh

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env bash
22

33
get_bucket_ownership_controls() {
4+
record_command "get-bucket-ownership-controls" "client:s3api"
45
if [[ $# -ne 1 ]]; then
56
log 2 "'get bucket ownership controls' command requires bucket name"
67
return 1

tests/commands/get_bucket_policy.sh

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env bash
22

33
get_bucket_policy() {
4+
record_command "get-bucket-policy" "client:$1"
45
if [[ $# -ne 2 ]]; then
56
log 2 "get bucket policy command requires command type, bucket"
67
return 1
@@ -25,6 +26,7 @@ get_bucket_policy() {
2526
}
2627

2728
get_bucket_policy_aws() {
29+
record_command "get-bucket-policy" "client:s3api"
2830
if [[ $# -ne 1 ]]; then
2931
log 2 "aws 'get bucket policy' command requires bucket"
3032
return 1
@@ -47,6 +49,7 @@ get_bucket_policy_aws() {
4749
}
4850

4951
get_bucket_policy_with_user() {
52+
record_command "get-bucket-policy" "client:s3api"
5053
if [[ $# -ne 3 ]]; then
5154
log 2 "'get bucket policy with user' command requires bucket, username, password"
5255
return 1
@@ -67,6 +70,7 @@ get_bucket_policy_with_user() {
6770
}
6871

6972
get_bucket_policy_s3cmd() {
73+
record_command "get-bucket-policy" "client:s3cmd"
7074
if [[ $# -ne 1 ]]; then
7175
log 2 "s3cmd 'get bucket policy' command requires bucket"
7276
return 1
@@ -110,6 +114,7 @@ get_bucket_policy_s3cmd() {
110114
}
111115

112116
get_bucket_policy_mc() {
117+
record_command "get-bucket-policy" "client:mc"
113118
if [[ $# -ne 1 ]]; then
114119
echo "aws 'get bucket policy' command requires bucket"
115120
return 1

tests/commands/get_bucket_tagging.sh

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# params: bucket
55
# export 'tags' on success, return 1 for error
66
get_bucket_tagging() {
7+
record_command "get-bucket-tagging" "client:$1"
78
if [ $# -ne 2 ]; then
89
echo "get bucket tag command missing command type, bucket name"
910
return 1

tests/commands/get_bucket_versioning.sh

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env bash
22

33
get_bucket_versioning() {
4+
record_command "get-bucket-versioning" "client:s3api"
45
if [[ $# -ne 2 ]]; then
56
log 2 "put bucket versioning command requires command type, bucket name"
67
return 1

tests/commands/get_object.sh

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,36 @@
11
#!/usr/bin/env bash
22

33
get_object() {
4+
record_command "get-object" "client:$1"
45
if [ $# -ne 4 ]; then
56
log 2 "get object command requires command type, bucket, key, destination"
67
return 1
78
fi
89
local exit_code=0
910
local error
1011
if [[ $1 == 's3' ]]; then
11-
error=$(aws --no-verify-ssl s3 mv "s3://$2/$3" "$4" 2>&1) || exit_code=$?
12+
get_object_error=$(aws --no-verify-ssl s3 mv "s3://$2/$3" "$4" 2>&1) || exit_code=$?
1213
elif [[ $1 == 's3api' ]] || [[ $1 == 'aws' ]]; then
13-
error=$(aws --no-verify-ssl s3api get-object --bucket "$2" --key "$3" "$4" 2>&1) || exit_code=$?
14+
get_object_error=$(aws --no-verify-ssl s3api get-object --bucket "$2" --key "$3" "$4" 2>&1) || exit_code=$?
1415
elif [[ $1 == 's3cmd' ]]; then
15-
error=$(s3cmd "${S3CMD_OPTS[@]}" --no-check-certificate get "s3://$2/$3" "$4" 2>&1) || exit_code=$?
16+
get_object_error=$(s3cmd "${S3CMD_OPTS[@]}" --no-check-certificate get "s3://$2/$3" "$4" 2>&1) || exit_code=$?
1617
elif [[ $1 == 'mc' ]]; then
17-
error=$(mc --insecure get "$MC_ALIAS/$2/$3" "$4" 2>&1) || exit_code=$?
18+
get_object_error=$(mc --insecure get "$MC_ALIAS/$2/$3" "$4" 2>&1) || exit_code=$?
1819
else
1920
log 2 "'get object' command not implemented for '$1'"
2021
return 1
2122
fi
2223
log 5 "get object exit code: $exit_code"
2324
if [ $exit_code -ne 0 ]; then
24-
log 2 "error getting object: $error"
25+
log 2 "error getting object: $get_object_error"
26+
export get_object_error
2527
return 1
2628
fi
2729
return 0
2830
}
2931

3032
get_object_with_range() {
33+
record_command "get-object" "client:s3api"
3134
if [[ $# -ne 4 ]]; then
3235
log 2 "'get object with range' requires bucket, key, range, outfile"
3336
return 1
@@ -41,6 +44,7 @@ get_object_with_range() {
4144
}
4245

4346
get_object_with_user() {
47+
record_command "get-object" "client:$1"
4448
if [ $# -ne 6 ]; then
4549
log 2 "'get object with user' command requires command type, bucket, key, save location, aws ID, aws secret key"
4650
return 1

tests/commands/get_object_attributes.sh

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env bash
22

33
get_object_attributes() {
4+
record_command "get-object-attributes" "client:s3api"
45
if [[ $# -ne 2 ]]; then
56
log 2 "'get object attributes' command requires bucket, key"
67
return 1

0 commit comments

Comments
 (0)