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

[10_6_X] Add CMSSW version to StatisticsSenderService #37320

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Utilities/StorageFactory/BuildFile.xml
Expand Up @@ -2,6 +2,7 @@
<use name="FWCore/MessageLogger"/>
<use name="FWCore/Utilities"/>
<use name="FWCore/ServiceRegistry"/>
<use name="FWCore/Version"/>
<use name="boost"/>
<use name="openssl"/>
<use name="tbb"/>
Expand Down
4 changes: 4 additions & 0 deletions Utilities/StorageFactory/src/StatisticsSenderService.cc
Expand Up @@ -6,6 +6,7 @@
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/src/Guid.h"
#include "FWCore/Version/interface/GetReleaseVersion.h"

#include <string>
#include <cmath>
Expand Down Expand Up @@ -383,6 +384,9 @@ void StatisticsSenderService::fillUDP(const std::string &siteName,
if (!siteName.empty()) {
os << "\"site_name\":\"" << siteName << "\", ";
}
// edm::getReleaseVersion() returns a string that includes quotation
// marks, therefore they are not added here
os << "\"cmssw_version\":" << edm::getReleaseVersion() << ", ";
if (usedFallback) {
os << "\"fallback\": true, ";
} else {
Expand Down
25 changes: 24 additions & 1 deletion Utilities/StorageFactory/test/test_file_statistics_sender.sh
Expand Up @@ -3,6 +3,24 @@
# Pass in name and status
function die { echo $1: status $2 ; exit $2; }

function testJSON {
# The JSON document is on one line, using an arbitrary key here to
# extract all of the documents into a separte file
grep cmssw_version $1 > test.json
python3 <<EOF
import json
with open('test.json') as f:
for line in f:
json.loads(line)
EOF
RET=$?
if [ "x$RET" != "x0" ]; then
echo "Invalid JSON in $1:"
cat test.json
exit $RET
fi
}

LOCAL_TEST_DIR=${CMSSW_BASE}/src/Utilities/StorageFactory/test
LOCAL_TMP_DIR=${CMSSW_BASE}/tmp/${SCRAM_ARCH}

Expand All @@ -16,18 +34,22 @@ rm make_2nd_file.log

cmsRun ${LOCAL_TEST_DIR}/test_single_file_statistics_sender_cfg.py &> test_single_file_statistics_sender.log || die "cmsRun test_single_file_statistics_sender_cfg.py" $?
grep -q '"file_lfn":"file:stat_sender_first.root"' test_single_file_statistics_sender.log || die "no StatisticsSenderService output for single file" 1
grep -q "\"cmssw_version\":\"$CMSSW_VERSION\"" test_single_file_statistics_sender.log || die "no StatisticsSenderService output for CMSSW version" 1
testJSON test_single_file_statistics_sender.log
rm test_single_file_statistics_sender.log

cmsRun ${LOCAL_TEST_DIR}/test_multiple_files_file_statistics_sender_cfg.py &> test_multiple_files_file_statistics_sender.log || die "cmsRun test_multiple_files_file_statistics_sender_cfg.py" $?
grep -q '"file_lfn":"file:stat_sender_b.root"' test_multiple_files_file_statistics_sender.log || die "no StatisticsSenderService output for file b in multiple files" 1
grep -q '"file_lfn":"file:stat_sender_c.root"' test_multiple_files_file_statistics_sender.log || die "no StatisticsSenderService output for file c in multiple files" 1
grep -q '"file_lfn":"file:stat_sender_d.root"' test_multiple_files_file_statistics_sender.log || die "no StatisticsSenderService output for file d in multiple files" 1
grep -q '"file_lfn":"file:stat_sender_e.root"' test_multiple_files_file_statistics_sender.log || die "no StatisticsSenderService output for file e in multiple files" 1
testJSON test_multiple_files_file_statistics_sender.log
rm test_multiple_files_file_statistics_sender.log

cmsRun ${LOCAL_TEST_DIR}/test_multi_file_statistics_sender_cfg.py &> test_multi_file_statistics_sender.log || die "cmsRun test_multi_file_statistics_sender_cfg.py" $?
grep -q '"file_lfn":"file:stat_sender_first.root"' test_multi_file_statistics_sender.log || die "no StatisticsSenderService output for file first in multi file" 1
grep -q '"file_lfn":"file:stat_sender_second.root"' test_multi_file_statistics_sender.log || die "no StatisticsSenderService output for file second in multi file" 1
testJSON test_multi_file_statistics_sender.log
rm test_multi_file_statistics_sender.log

cmsRun ${LOCAL_TEST_DIR}/test_secondary_file_statistics_sender_cfg.py &> test_secondary_file_statistics_sender.log || die "cmsRun test_secondary_file_statistics_sender_cfg.py" $?
Expand All @@ -36,6 +58,7 @@ grep -q '"file_lfn":"file:stat_sender_b.root"' test_secondary_file_statistics_se
grep -q '"file_lfn":"file:stat_sender_c.root"' test_secondary_file_statistics_sender.log || die "no StatisticsSenderService output for file 'c' in secondary files" 1
grep -q '"file_lfn":"file:stat_sender_d.root"' test_secondary_file_statistics_sender.log || die "no StatisticsSenderService output for file 'd' in secondary files" 1
grep -q '"file_lfn":"file:stat_sender_e.root"' test_secondary_file_statistics_sender.log || die "no StatisticsSenderService output for file 'e' in secondary files" 1
testJSON test_secondary_file_statistics_sender.log
rm test_secondary_file_statistics_sender.log

popd
popd