Skip to content

Commit

Permalink
Merge pull request #37320 from makortel/statisticsSenderServiceCMSSWV…
Browse files Browse the repository at this point in the history
…ersion_10_6_x

[10_6_X] Add CMSSW version to StatisticsSenderService
  • Loading branch information
cmsbuild committed Mar 23, 2022
2 parents c86fcb3 + 870293c commit 6843b28
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
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

0 comments on commit 6843b28

Please sign in to comment.