Skip to content
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

[DQM] Added a new test for ROOT file uploads to DQMGUI #46551

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions DQMServices/Demo/test/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@
</library>

<test name="TestDQMServicesDemo" command="runtests.sh"/>
<test name="TestDQMGUIUpload" command="test_dqmgui_upload.sh">
<flags PRE_TEST="TestDQMServicesDemo"/>
</test>
69 changes: 69 additions & 0 deletions DQMServices/Demo/test/test_dqmgui_upload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/env bash
# Simple test to use one of the files generated by TestDQMServicesDemo test
# to upload it to the dev DQMGUI, making sure that the ROOT file format generated
# is compatible. See cmssw issue #43590.
# Requires curl and jq to be installed. Also requires either a Grid key and certificate,
# or a proxy to be available.
set -x
set -e

DEV_DQMGUI_URL="https://cmsweb.cern.ch/dqm/dev"
# Create a unique fake "Era", so that different executions of this test
# produce differently named files. This is required, because this test might pass
# if it's checking a file that was successfully uploaded during a previous
# instance of the same test.
UNIQUE_ERA_ID=$(date -u +%Y%m%d%M%S%N)
OLD_FILENAME=DQM_V0001_R000000001__Harvesting__DQMTests__DQMIO.root
NEW_FILENAME=${OLD_FILENAME/DQMTests/DQMTests${UNIQUE_ERA_ID}}

# Make sure the required file exists. We expect to find it in the current directory.
if [ ! -f $OLD_FILENAME ]; then
echo "Unable to find required file ${OLD_FILENAME}!"
exit 1
fi

# Prepare curl args
curl_args=""
if [ -n "$X509_CERT_DIR" ]; then
curl_args="${curl_args} --capath ${X509_CERT_DIR}/"
else
curl_args="${curl_args} -k"
fi
if [ -n "$X509_USER_PROXY" ]; then
curl_args="${curl_args} --key ${X509_USER_PROXY} --cert ${X509_USER_PROXY}"
elif [ -n "$X509_USER_KEY" ] && [ -n "$X509_USER_CERT" ]; then
curl_args="${curl_args} --key ${X509_USER_KEY} --cert ${X509_USER_CERT}"
elif [ -f $HOME/.globus/usercert.pem ] && [ -f $HOME/.globus/userkey.pem ]; then
Copy link
Contributor

@smuzaffar smuzaffar Oct 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nothingface0 , looks like test is not using X509_USER_PROXY . Although X509_USER_PROXY is set but due to [ -n "$X509_CERT_DIR" ] check script is not using it. I would suggest to use X509_CERT_DIR to only add --capath ${X509_CERT_DIR} and separate condition for X509_USER_PROXY

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also may be add -s to curl command to avoid curl verbose output

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any better like this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good now

curl_args="${curl_args} --key $HOME/.globus/userkey.pem --cert $HOME/.globus/usercert.pem"
else
echo "Unable to find proxy or key/cert env vars, cannot continue"
exit 1
fi

# Make a copy with a filename that conforms to the naming convention required by DQMGUI.
rm -f "$NEW_FILENAME"
cp $OLD_FILENAME "$NEW_FILENAME"

# Upload the file to the DQMGUI
visDQMUpload.py "$DEV_DQMGUI_URL" "$NEW_FILENAME"
Copy link
Contributor

@mmusich mmusich Oct 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my education: will these files be indexed and stored permanently? Do we risk to eventually run out of db space if this is going to run twice a day times N IBs flavours for the foreseable future? Also do we risk to take down a production GUI with some kind of DDoS if some user inadvertenly runs this test multiple times? Sorry for the naive questions!

Copy link
Contributor Author

@nothingface0 nothingface0 Oct 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will these files be indexed and stored permanently?

Yes.

eventually run out of db space if this is going to run twice a day times N IBs flavours for the foreseable future?

Yes, but this happens anyway for the dev flavor, since all CMSSW automated tests upload there all their files, which is why we clean it up every now and then. AFAIK no one will check for the tests of very old CMSSW PRs.

do we risk to take down a production GUI with some kind of DDoS

This test (same as all tests by cmsbuild) is uploading to the dev DQMGUI only (which is not "production" per se). Is your question about possibly bypassing the test to upload, e.g., to offline DQMGUI?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which is not "production" per se

If it's used for the PR tests, it's "production" in some sense. But ok if you already clean it up regularly I think it's fine, thanks for the explanation.


# Wait for a bit for the file to be imported into the DQMGUI's index.
# The currently used file is very small and expected to be ingested quickly,
# but better safe than sorry.
SECONDS_TO_WAIT=600
# Reset shell's internal SECONDS var.
SECONDS=0

while true; do
# Wait for the dataset to appear in the /json/samples endpoint. It might take a while.
if curl -sL $curl_args "${DEV_DQMGUI_URL}/data/json/samples?match=DQMTests${UNIQUE_ERA_ID}" | jq .samples[0].items[0].dataset | grep -q "$UNIQUE_ERA_ID"; then
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smuzaffar -s added here

exit 0
fi

sleep 10
# Timeout after SECONDS_TO_WAIT have passed.
nothingface0 marked this conversation as resolved.
Show resolved Hide resolved
if [ $SECONDS -ge $SECONDS_TO_WAIT ]; then
exit 1
fi
done
exit 1