Skip to content

Commit dfe1f5e

Browse files
authored
Merge pull request #46551 from nothingface0/test_dqmgui_upload
[DQM] Added a new test for ROOT file uploads to DQMGUI
2 parents ddbd544 + cd5c5ec commit dfe1f5e

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

DQMServices/Demo/test/BuildFile.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@
66
</library>
77

88
<test name="TestDQMServicesDemo" command="runtests.sh"/>
9+
<test name="TestDQMGUIUpload" command="test_dqmgui_upload.sh">
10+
<flags PRE_TEST="TestDQMServicesDemo"/>
11+
</test>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/env bash
2+
# Simple test to use one of the files generated by TestDQMServicesDemo test
3+
# to upload it to the dev DQMGUI, making sure that the ROOT file format generated
4+
# is compatible. See cmssw issue #43590.
5+
# Requires curl and jq to be installed. Also requires either a Grid key and certificate,
6+
# or a proxy to be available.
7+
set -x
8+
set -e
9+
10+
DEV_DQMGUI_URL="https://cmsweb.cern.ch/dqm/dev"
11+
# Create a unique fake "Era", so that different executions of this test
12+
# produce differently named files. This is required, because this test might pass
13+
# if it's checking a file that was successfully uploaded during a previous
14+
# instance of the same test.
15+
UNIQUE_ERA_ID=$(date -u +%Y%m%d%M%S%N)
16+
OLD_FILENAME=DQM_V0001_R000000001__Harvesting__DQMTests__DQMIO.root
17+
NEW_FILENAME=${OLD_FILENAME/DQMTests/DQMTests${UNIQUE_ERA_ID}}
18+
19+
# Make sure the required file exists. We expect to find it in the current directory.
20+
if [ ! -f $OLD_FILENAME ]; then
21+
echo "Unable to find required file ${OLD_FILENAME}!"
22+
exit 1
23+
fi
24+
25+
# Prepare curl args
26+
curl_args=""
27+
if [ -n "$X509_CERT_DIR" ]; then
28+
curl_args="${curl_args} --capath ${X509_CERT_DIR}/"
29+
else
30+
curl_args="${curl_args} -k"
31+
fi
32+
if [ -n "$X509_USER_PROXY" ]; then
33+
curl_args="${curl_args} --key ${X509_USER_PROXY} --cert ${X509_USER_PROXY}"
34+
elif [ -n "$X509_USER_KEY" ] && [ -n "$X509_USER_CERT" ]; then
35+
curl_args="${curl_args} --key ${X509_USER_KEY} --cert ${X509_USER_CERT}"
36+
elif [ -f $HOME/.globus/usercert.pem ] && [ -f $HOME/.globus/userkey.pem ]; then
37+
curl_args="${curl_args} --key $HOME/.globus/userkey.pem --cert $HOME/.globus/usercert.pem"
38+
else
39+
echo "Unable to find proxy or key/cert env vars, cannot continue"
40+
exit 1
41+
fi
42+
43+
# Make a copy with a filename that conforms to the naming convention required by DQMGUI.
44+
rm -f "$NEW_FILENAME"
45+
cp $OLD_FILENAME "$NEW_FILENAME"
46+
47+
# Upload the file to the DQMGUI
48+
visDQMUpload.py "$DEV_DQMGUI_URL" "$NEW_FILENAME"
49+
50+
# Wait for a bit for the file to be imported into the DQMGUI's index.
51+
# The currently used file is very small and expected to be ingested quickly,
52+
# but better safe than sorry.
53+
SECONDS_TO_WAIT=600
54+
# Reset shell's internal SECONDS var.
55+
SECONDS=0
56+
57+
while true; do
58+
# Wait for the dataset to appear in the /json/samples endpoint. It might take a while.
59+
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
60+
exit 0
61+
fi
62+
63+
sleep 10
64+
# Timeout after SECONDS_TO_WAIT have passed.
65+
if [ $SECONDS -ge $SECONDS_TO_WAIT ]; then
66+
exit 1
67+
fi
68+
done
69+
exit 1

0 commit comments

Comments
 (0)