Skip to content

Commit

Permalink
Fix ada exit code when staging non-existing file, add test for this
Browse files Browse the repository at this point in the history
  • Loading branch information
hailihu committed Dec 12, 2024
1 parent 8ba9004 commit ce4d2b0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ada/ada
Original file line number Diff line number Diff line change
Expand Up @@ -1560,7 +1560,7 @@ api_call () {
stage ) activity='PIN' ;;
unstage ) activity='UNPIN' ;;
esac
bulk_request "$activity" "$pathlist" "$recursive" | column -t -s $'\t'
bulk_request "$activity" "$pathlist" "$recursive"
;;
events | report-staged )
if [ "${BASH_VERSINFO[0]}" -lt 4 ] ; then
Expand Down
14 changes: 12 additions & 2 deletions tests/integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ test_ada_stage_file() {
assertEquals "ada returned error code ${result}" 0 ${result} || return
request_url=`grep "request-url" "${stdoutF}" | awk '{print $2}' | tr -d '\r'`
assertNotNull "No request-url found" $request_url || return
sleep 2 # needed if request is still RUNNING
state=`curl -X GET "${request_url}" -H "accept: application/json" -H "Authorization: Bearer $token" | jq -r '.targets[0].state'`
assertEquals "State of target:" "COMPLETED" $state
}
Expand All @@ -118,6 +119,7 @@ test_ada_unstage_file() {
assertEquals "ada returned error code ${result}" 0 ${result} || return
request_url=`grep "request-url" "${stdoutF}" | awk '{print $2}' | tr -d '\r'`
assertNotNull "No request-url found" $request_url || return
sleep 2 # needed if request is still RUNNING
state=`curl -X GET "${request_url}" -H "accept: application/json" -H "Authorization: Bearer $token" | jq -r '.targets[0].state'`
assertEquals "State of target:" "COMPLETED" $state
}
Expand All @@ -129,7 +131,7 @@ test_ada_stage_filelist() {
assertEquals "ada returned error code ${result}" 0 ${result} || return
request_url=`grep "request-url" "${stdoutF}" | awk '{print $2}' | tr -d '\r'`
assertNotNull "No request-url found" $request_url || return
# sleep 2 # needed if request is still RUNNING
sleep 2 # needed if request is still RUNNING
state=`curl -X GET "${request_url}" -H "accept: application/json" -H "Authorization: Bearer $token" | jq -r '.targets[0].state'`
assertEquals "State of target:" "COMPLETED" $state
}
Expand All @@ -141,12 +143,20 @@ test_ada_unstage_filelist() {
assertEquals "ada returned error code ${result}" 0 ${result} || return
request_url=`grep "request-url" "${stdoutF}" | awk '{print $2}' | tr -d '\r'`
assertNotNull "No request-url found" $request_url || return
# sleep 2
sleep 2 # needed if request is still RUNNING
state=`curl -X GET "${request_url}" -H "accept: application/json" -H "Authorization: Bearer $token" | jq -r '.targets[0].state'`
assertEquals "State of target:" "COMPLETED" $state
}


# Test if ada exits with error when staging non-existing file
test_ada_stage_file_error() {
ada/ada --tokenfile ${token_file} --stage "/${tape_path}/${dirname}/testerror" --api ${api} >${stdoutF} 2>${stderrF}
result=$?
assertEquals "ada returned error code ${result}" 1 ${result}
}


oneTimeSetUp() {
outputDir="${SHUNIT_TMPDIR}/output"
# outputDir="output"
Expand Down

0 comments on commit ce4d2b0

Please sign in to comment.