Skip to content

Commit

Permalink
Merge pull request #34379 from mmusich/CondDBUploadUnitTest
Browse files Browse the repository at this point in the history
introduce `uploadConditions.py` unit test
  • Loading branch information
cmsbuild authored Jul 16, 2021
2 parents fdf2a2f + 499f39e commit d9fe644
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CondCore/Utilities/test/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@
</bin>

<test name="testGetPayloadData" command="test_getPayloadData.sh"/>

<test name="testUploadConditions" command="test_uploadConditions.sh">
<flags PRE_TEST="testBasicPayload"/>
</test>
57 changes: 57 additions & 0 deletions CondCore/Utilities/test/test_uploadConditions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash
check_for_success() {
"${@}" && echo -e "\n ---> Passed test of '${@}'\n\n" || exit 1
}

check_for_failure() {
"${@}" && exit 1 || echo -e "\n ---> Passed test of '${@}'\n\n"
}

function die { echo $1: status $2; exit $2; }

########################################
# Test help function
########################################
check_for_success uploadConditions.py --help

########################################
# Test wizard
########################################
if test -f "BasicPayload_v0_ref.txt"; then
rm -f BasicPayload_v0_ref.txt
fi
cat <<EOF >> BasicPayload_v0_ref.txt
{
"destinationDatabase": "oracle://cms_orcoff_prep/CMS_CONDITIONS",
"destinationTags": {
"BasicPayload_v0": {}
},
"inputTag": "BasicPayload_v0",
"since": 1,
"userText": "uploadConditions unit test"
}
EOF

echo "Content of the directory is:" `ls -lh . | grep db`
echo -ne '\n\n'

if test -f "BasicPayload_v0.txt"; then
rm -f BasicPayload_v0.txt
fi

# this is expected to fail given lack of credentials
check_for_failure uploadConditions.py BasicPayload_v0.db <<EOF
y
0
oracle://cms_orcoff_prep/CMS_CONDITIONS
1
uploadConditions unit test
BasicPayload_v0
`echo -ne '\n'`
y
test
test
EOF

# test that the metadata created with the wizard corresponds to the reference one
diff -w BasicPayload_v0.txt BasicPayload_v0_ref.txt || die 'failed comparing metadata with reference' $?

0 comments on commit d9fe644

Please sign in to comment.