From cd5c5ec4d35764d57dd0d93e38228827328c1d17 Mon Sep 17 00:00:00 2001 From: Dimitris Date: Wed, 30 Oct 2024 11:55:49 +0100 Subject: [PATCH] Added a new test for ROOT file uploads to DQMGUI It uses a ROOT file generated by the TestDQMServicesDemo test and uploads it to the dev DQMGUI. This should cover the case where CMSSW moves to a new ROOT release, which might be incompatible with the one being used at the DQMGUI. Resolves: #43590 --- DQMServices/Demo/test/BuildFile.xml | 3 + DQMServices/Demo/test/test_dqmgui_upload.sh | 69 +++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100755 DQMServices/Demo/test/test_dqmgui_upload.sh diff --git a/DQMServices/Demo/test/BuildFile.xml b/DQMServices/Demo/test/BuildFile.xml index 53aaaaa7c7b9c..4f57697d9104d 100644 --- a/DQMServices/Demo/test/BuildFile.xml +++ b/DQMServices/Demo/test/BuildFile.xml @@ -6,3 +6,6 @@ + + + diff --git a/DQMServices/Demo/test/test_dqmgui_upload.sh b/DQMServices/Demo/test/test_dqmgui_upload.sh new file mode 100755 index 0000000000000..da48f6a56bd3b --- /dev/null +++ b/DQMServices/Demo/test/test_dqmgui_upload.sh @@ -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 + 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" + +# 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 + exit 0 + fi + + sleep 10 + # Timeout after SECONDS_TO_WAIT have passed. + if [ $SECONDS -ge $SECONDS_TO_WAIT ]; then + exit 1 + fi +done +exit 1