-
Notifications
You must be signed in to change notification settings - Fork 50
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
Add json output for mint mc test cases #121
Conversation
run/core/mc/test.sh
Outdated
log_pass() { | ||
jq -n --arg name "${1}" --arg function "${2}" --arg args "${3}" \ | ||
--arg duration "${4}" --arg status "pass" \ | ||
'{"name": $name, "function": $function, "args": $args, "duration": $duration, "status": $status }' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Unable to understand
jq
usage for this json structure. You could useecho
orprintf
command - As this function is for
PASS
case, you would need to have hard-codedstatus
in the json
run/core/mc/test.sh
Outdated
log_fail() { | ||
jq -n --arg name "${1}" --arg function "${2}" --arg args "${3}" \ | ||
--arg duration "${4}" --arg status "fail" --arg message "${5}" --arg error "${6}" \ | ||
'{"name": $name, "function": $function, "args": $args, "duration": $duration, "status": $status, "message": $message, "error": $error }' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
run/core/mc/test.sh
Outdated
'{"name": $name, "function": $function, "args": $args, "duration": $duration, "status": $status, "message": $message, "error": $error }' | ||
} | ||
|
||
log_fail_with_alert() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could name it as log_alert()
run/core/mc/test.sh
Outdated
# Create a bucket and check if it exists on server | ||
makeBucket(){ | ||
make_bucket(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I would recommend to follow
function <name> {
style which is more readable. - You could need to fix formatting by given proper spacing for
{
run/core/mc/test.sh
Outdated
# Create a bucket and check if it exists on server | ||
makeBucket(){ | ||
make_bucket(){ | ||
name="mc" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You would need to keep this globally for all functions
run/core/mc/test.sh
Outdated
if ! ./mc mb "target/${bucketName}" > /dev/null | ||
then | ||
>&2 echo "Make Bucket Test 1 Failure" | ||
function="./mc mb target/${bucketName}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
camelCase
style is not a convention. You would need to use bucket_name
run/core/mc/test.sh
Outdated
# log end time in ms | ||
end=$(($(date +%s%N)/1000000)) | ||
# find the duration | ||
duration=$(( end - start )) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- You would need to calculate duration before this
if
block. - You would need to round to
ms
at duration computing than gettingstart
andend
start
andend
need to be named asstart_time
andend_time
run/core/mc/test.sh
Outdated
# find the duration | ||
duration=$(( end - start )) | ||
# update log file | ||
log_fail_with_alert "${name}" "${function}" "${args}" "${duration}" "Blocker" "mc mb failed" "$error" | ||
return 1 | ||
fi | ||
|
||
# remove bucket and cleanup | ||
remove_bucket "${bucketName}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why you skip checking remove_bucket?
1f812bf
to
f4c9740
Compare
@balamurugana updated the PR. |
run/core/mc/test.sh
Outdated
|
||
remove_bucket() { | ||
function remove_bucket() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can fix this function too.
run/core/mc/test.sh
Outdated
printf '{"name": "mc", "duration": "%d", "function": "%s", "status": "FAIL", "error": "%d"}\n' "$1" "$2" "$3" | ||
} | ||
|
||
function log_failure_and_alert() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can name this function as log_alert()
or log_alert_failure()
run/core/mc/test.sh
Outdated
} | ||
|
||
function log_failure() { | ||
printf '{"name": "mc", "duration": "%d", "function": "%s", "status": "FAIL", "error": "%d"}\n' "$1" "$2" "$3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"error"
is "%s"
run/core/mc/test.sh
Outdated
} | ||
|
||
function log_failure_and_alert() { | ||
printf '{"name": "mc", "duration": "%d", "function": "%s", "status": "FAIL", "alert": "%d", error": "%d"}\n' "$1" "$2" "$3" "$4" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is not used anywhere. You could remove it.
run/core/mc/test.sh
Outdated
if [ $rv -eq 0 ]; then | ||
log_success "$(get_duration "$start_time")" "${function}" | ||
else | ||
log_failure "$(get_duration "$start_time")" "${function}" "${out}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could leave unquoted get_duration
and start_time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shellcheck (the linter we use) recommends adding quotes here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
run/core/mc/test.sh
Outdated
|
||
# Make bucket | ||
./mc mb "target/${bucketName}" > /dev/null | ||
bucket_name="mc-mint-test-bucket-$RANDOM" | ||
function="${MC_CMD} mb ${SERVER_ALIAS}/${bucket_name}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could do have setup
and teardown
style than creating/removing bucket every time.
run/core/mc/test.sh
Outdated
return 1 | ||
# if download succeeds, verify downloaded file | ||
if [ $rv -eq 0 ]; then | ||
if [ "$hash1" == "$hash2" ] && [ "$(basename "$(echo "$out" | jq -r .target)")" == "datafile-1-MB" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to check target
with the name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to check the downloaded file name same as the uploaded file name.
run/core/mc/test.sh
Outdated
|
||
# Make bucket - invalid bucket name | ||
bucket_name="Mc-mint-test-bucket-$RANDOM" | ||
function="${MC_CMD} mb ${SERVER_ALIAS}/${bucket_name}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unknown to understand this test and the behavior. This function always fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a negative test to make sure a bucket with invalid name is not created on the server.
run/core/mc/test.sh
Outdated
local bucketName | ||
bucketName="Abcd" | ||
# Upload an object, with invalid object name | ||
function put_object_error() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function would need a better than conveying about invalid object name.
run/core/mc/test.sh
Outdated
printf "\n %s End of tests %s \n\n" "${blue}" "${normal}" 1 | ||
# Negative tests | ||
make_bucket_error | ||
put_object_error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend to have test function name prefixing test_
run/core/mc/test.sh
Outdated
bucketName=$(create_random_string) | ||
# Tests for the cat object success by comparing the STDOUT of "cat run.sh", | ||
# to "mc cat run.sh" by uploading run.sh, and comparing the two outputs. | ||
function cat_objects() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this test for server? It doesn't make any different than cp
in server point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was not introduced in this commit. I assume the test is to check if cat streams the content properly.
I think it doesn't hurt to make sure the mc
specific commands are working as expected with Minio server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mint
is meant for server testing, adding mc's cat command test is not a good idea.
For server, there is no difference whether returned http response body is saved, streamed or printed on the screen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
run/core/mc/test.sh
Outdated
bucketName=$(create_random_string) | ||
# Tests for list object success, by mirroring an fs store to minio, | ||
# and then comparing the ls results. | ||
function mirror_list_objects() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its not good idea to upload data dir for list objects. You could create objects using smallest file with different names. Mirror is not the right choice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was not introduced in this commit. I assume the test was to check if mirror works and uploads all the files and then it is verified via ls.
I will update the comments in the test case accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mint
is for server testing, adding mc's mirror test is not applicable. It is mc specific feature syncing directory.
As this test is for list objects, using mirror is not a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mint is for server testing, adding mc's mirror test is not applicable. It is mc specific feature syncing directory.
The point of Mint is to test functionally if various libraries/SDKs/tools are working as expected with Minio server and of course if the server is working as expected.
If you say mirror
is not applicable as mint does server testing, and mirror
is just one feature of mc
that does cp
in the background. It implies we don't even need multiple SDKs, we can just test one SDK and be done -- since all the SDKs will call the same server APIs.
We use all SDKs to check if there is something broken in a specific scenario which may otherwise get overlooked. As mint
runs all the SDKs / tools with their specific way to interact with server, we have the confidence that overall system (various clients + server) are all working fine.
So, I think mirror
is needed and should not be removed. I can for sure add a new test case that does what you proposed - upload multiple files via cp
and then perform a ls
.
d6a9283
to
a6504af
Compare
Updated with |
a6504af
to
0d01566
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am taking this immediately for minio PR verification test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fixes: #114
Here is the new output for
mint mc
tests: