Skip to content

Commit

Permalink
Added unit test for StatisticsSenderService
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr15Jones committed Oct 1, 2021
1 parent 86edd4a commit 7786d20
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 0 deletions.
1 change: 1 addition & 0 deletions Utilities/StorageFactory/test/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<bin file="mkstemp.cpp" name="test_StorageFactory_Mkstemp">
</bin>

<test name="TestStatisticsSenderService" command="test_file_statistics_sender.sh"/>
<!--
We do not currently run the threadsafe test, as the StorageFactoryMaker is not thread-safe
(the underlying PluginManager can be called from multiple threads, but itself is not
Expand Down
10 changes: 10 additions & 0 deletions Utilities/StorageFactory/test/make_2nd_file_cfg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import FWCore.ParameterSet.Config as cms

process = cms.Process("SECOND")

process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring("file:stat_sender_first.root"))

process.o = cms.OutputModule("PoolOutputModule", fileName = cms.untracked.string("stat_sender_second.root"), outputCommands = cms.untracked.vstring("drop *"))

process.ep = cms.EndPath(process.o)

20 changes: 20 additions & 0 deletions Utilities/StorageFactory/test/make_test_files_cfg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import FWCore.ParameterSet.Config as cms

process = cms.Process("FIRST")

process.source = cms.Source("EmptySource")

process.first = cms.OutputModule("PoolOutputModule", fileName = cms.untracked.string("stat_sender_first.root"))
process.b = cms.OutputModule("PoolOutputModule", fileName = cms.untracked.string("stat_sender_b.root"))
process.c = cms.OutputModule("PoolOutputModule", fileName = cms.untracked.string("stat_sender_c.root"))
process.d = cms.OutputModule("PoolOutputModule", fileName = cms.untracked.string("stat_sender_d.root"))
process.e = cms.OutputModule("PoolOutputModule", fileName = cms.untracked.string("stat_sender_e.root"))

process.Thing = cms.EDProducer("ThingProducer")
process.OtherThing = cms.EDProducer("OtherThingProducer")
process.EventNumber = cms.EDProducer("EventNumberIntProducer")


process.o = cms.EndPath(process.first+process.b+process.c+process.d+process.e, cms.Task(process.Thing, process.OtherThing, process.EventNumber))

process.maxEvents.input = 10
41 changes: 41 additions & 0 deletions Utilities/StorageFactory/test/test_file_statistics_sender.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

# Pass in name and status
function die { echo $1: status $2 ; exit $2; }

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

pushd ${LOCAL_TMP_DIR}

#setup files used in tests
cmsRun ${LOCAL_TEST_DIR}/make_test_files_cfg.py &> make_test_files.log || die "cmsRun make_test_files_cfg.py" $?
rm make_test_files.log
cmsRun ${LOCAL_TEST_DIR}/make_2nd_file_cfg.py &> make_2nd_file.log || die "cmsRun make_2nd_file_cfg.py" $?
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
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
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
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" $?
grep -q '"file_lfn":"file:stat_sender_first.root"' test_secondary_file_statistics_sender.log || die "no StatisticsSenderService output for file 'first' in secondary files" 1
grep -q '"file_lfn":"file:stat_sender_b.root"' test_secondary_file_statistics_sender.log || die "no StatisticsSenderService output for file 'b' in secondary files" 1
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
rm test_secondary_file_statistics_sender.log

popd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import FWCore.ParameterSet.Config as cms

process = cms.Process("TEST")

process.source = cms.Source("PoolSource",
fileNames = cms.untracked.vstring("file:stat_sender_second.root"),
secondaryFileNames = cms.untracked.vstring("file:stat_sender_first.root")
)

process.add_(cms.Service("StatisticsSenderService", debug = cms.untracked.bool(True)))
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import FWCore.ParameterSet.Config as cms

process = cms.Process("TEST")

process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring("file:stat_sender_b.root", "file:stat_sender_c.root", "file:stat_sender_d.root", "file:stat_sender_e.root"),
duplicateCheckMode = cms.untracked.string('noDuplicateCheck'),
inputCommands = cms.untracked.vstring('drop *_*_beginRun_*', 'drop *_*_endRun_*', 'drop *_*_beginLumi_*', 'drop *_*_endLumi_*')
)

process.add_(cms.Service("StatisticsSenderService", debug = cms.untracked.bool(True)))
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import FWCore.ParameterSet.Config as cms

process = cms.Process("TEST")

process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring("file:stat_sender_first.root"))

process.b = cms.EDProducer("SecondaryProducer",
seq = cms.untracked.bool(True),
input = cms.SecSource("EmbeddedRootSource",
sequential = cms.untracked.bool(True),
fileNames = cms.untracked.vstring('file:stat_sender_b.root')
)
)

process.c = cms.EDProducer("SecondaryProducer",
seq = cms.untracked.bool(True),
input = cms.SecSource("EmbeddedRootSource",
sequential = cms.untracked.bool(True),
fileNames = cms.untracked.vstring('file:stat_sender_c.root')
)
)

process.d = cms.EDProducer("SecondaryProducer",
seq = cms.untracked.bool(True),
input = cms.SecSource("EmbeddedRootSource",
sequential = cms.untracked.bool(True),
fileNames = cms.untracked.vstring('file:stat_sender_d.root')
)
)

process.e = cms.EDProducer("SecondaryProducer",
seq = cms.untracked.bool(True),
input = cms.SecSource("EmbeddedRootSource",
sequential = cms.untracked.bool(True),
fileNames = cms.untracked.vstring('file:stat_sender_e.root')
)
)

process.pB = cms.Path(process.b)
process.pC = cms.Path(process.c)
process.pD = cms.Path(process.d)
process.pE = cms.Path(process.e)

process.add_(cms.Service("StatisticsSenderService", debug = cms.untracked.bool(True)))
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import FWCore.ParameterSet.Config as cms

process = cms.Process("TEST")

process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring("file:stat_sender_first.root"))

process.add_(cms.Service("StatisticsSenderService", debug = cms.untracked.bool(True)))

process.load("FWCore.MessageService.MessageLogger_cfi")

process.MessageLogger.cerr.INFO.limit = 1000

0 comments on commit 7786d20

Please sign in to comment.