Skip to content

Commit 23c8cef

Browse files
committed
Replicate the mocked version -based reduced ProcessHistory tests for streamer file format
1 parent 73cb482 commit 23c8cef

5 files changed

+198
-2
lines changed

IOPool/Streamer/test/BuildFile.xml

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
<test name="NewStreamerZSTD" command="RunZSTD.sh"/>
2828

2929
<test name="TestIOPoolStreamerRefProductIDMetadataConsistency" command="run_TestRefProductIDMetadataConsistencyStreamer.sh"/>
30-
30+
31+
<test name="TestIOPoolStreamerReducedProcessHistory" command="run_TestReducedProcessHistory.sh"/>
32+
3133
<library file="StreamThingProducer.cc" name="StreamThingProducer">
3234
<flags EDM_PLUGIN="1"/>
3335
<use name="DataFormats/TestObjects"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
3+
function die { echo Failure $1: status $2 ; exit $2 ; }
4+
function runSuccess {
5+
echo "cmsRun $@"
6+
cmsRun $@ || die "cmsRun $*" $?
7+
echo
8+
}
9+
function runFailure {
10+
echo "cmsRun $@ (expected to fail)"
11+
cmsRun $@ && die "cmsRun $*" 1
12+
echo
13+
}
14+
15+
VERSION_ARR=(${CMSSW_VERSION//_/ })
16+
VERSION1="${VERSION_ARR[0]}_${VERSION_ARR[1]}_${VERSION_ARR[2]}_0"
17+
VERSION2="${VERSION_ARR[0]}_${VERSION_ARR[1]}_${VERSION_ARR[2]}_1"
18+
VERSION3="${VERSION_ARR[0]}_${VERSION_ARR[1]}_$((${VERSION_ARR[2]}+1))_0"
19+
20+
# Check that changing the patch version does not lead to new lumi or run
21+
runSuccess ${SCRAM_TEST_PATH}/testReducedProcessHistoryCreate_cfg.py --version ${VERSION1} --firstEvent 1 --output version1.dat
22+
runSuccess ${SCRAM_TEST_PATH}/testReducedProcessHistoryCreate_cfg.py --version ${VERSION2} --firstEvent 101 --output version2.dat
23+
24+
CatStreamerFiles merged.dat version1.dat version2.dat
25+
26+
runSuccess ${SCRAM_TEST_PATH}/testReducedProcessHistory_cfg.py --input merged.dat --output merged.root
27+
28+
edmProvDump merged.root | grep -q "PROD.*'${VERSION1}'" || die "Did not find ${VERSION1} from merged.root provenance" $?
29+
edmProvDump merged.root | grep -q "PROD.*'${VERSION2}'" || die "Did not find ${VERSION2} from merged.root provenance" $?
30+
31+
32+
# Check that changing the minor version leads to new lumi
33+
runSuccess ${SCRAM_TEST_PATH}/testReducedProcessHistoryCreate_cfg.py --version ${VERSION3} --firstEvent 201 --output version3_lumi.dat
34+
35+
CatStreamerFiles merged3_lumi.dat version1.dat version3_lumi.dat
36+
37+
runFailure ${SCRAM_TEST_PATH}/testReducedProcessHistory_cfg.py --input merged3_lumi.dat --output merged3_lumi.root
38+
39+
runSuccess ${SCRAM_TEST_PATH}/testReducedProcessHistory_cfg.py --input merged3_lumi.dat --output merged3_lumi.root --expectNewLumi
40+
41+
edmProvDump merged3_lumi.root | grep -q "PROD.*'${VERSION3}'" || die "Did not find ${VERSION3} from merged3_lumi.root provenance" $?
42+
43+
44+
# Check that changing the minor version leads to new run
45+
runSuccess ${SCRAM_TEST_PATH}/testReducedProcessHistoryCreate_cfg.py --version ${VERSION3} --firstEvent 201 --lumi 2 --output version3_run.dat
46+
47+
CatStreamerFiles merged3_run.dat version1.dat version3_run.dat
48+
49+
runFailure ${SCRAM_TEST_PATH}/testReducedProcessHistory_cfg.py --input merged3_run.dat --output merged3_run.root
50+
51+
runSuccess ${SCRAM_TEST_PATH}/testReducedProcessHistory_cfg.py --input merged3_run.dat --output merged3_run.root --expectNewRun
52+
53+
edmProvDump merged3_run.root | grep -q "PROD.*'${VERSION3}'" || die "Did not find ${VERSION3} from merged3_run.root provenance" $?
54+
55+
exit 0

IOPool/Streamer/test/run_TestRefProductIDMetadataConsistencyStreamer.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function runSuccess {
77
echo
88
}
99
function runFailure {
10-
echo "cmsRun $@ (exepcted to fail)"
10+
echo "cmsRun $@ (expected to fail)"
1111
cmsRun $@ && die "cmsRun $*" 1
1212
echo
1313
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import FWCore.ParameterSet.Config as cms
2+
import argparse
3+
4+
parser = argparse.ArgumentParser(description='Create files for reduced ProcessHistory test')
5+
parser.add_argument("--version", type=str, help="CMSSW version to be used in the ProcessHistory")
6+
parser.add_argument("--firstEvent", default=1, type=int, help="Number of first event")
7+
parser.add_argument("--lumi", default=1, type=int, help="LuminosityBlock number")
8+
parser.add_argument("--output", type=str, help="Output file name")
9+
10+
args = parser.parse_args()
11+
12+
process = cms.Process("PROD")
13+
process._specialOverrideReleaseVersionOnlyForTesting(args.version)
14+
15+
process.maxEvents.input = 10
16+
17+
from FWCore.Modules.modules import EmptySource
18+
process.source = EmptySource(
19+
firstEvent = args.firstEvent,
20+
firstLuminosityBlock = args.lumi,
21+
)
22+
23+
from IOPool.Streamer.modules import EventStreamFileWriter
24+
process.out = EventStreamFileWriter(
25+
fileName = args.output
26+
)
27+
28+
from FWCore.Framework.modules import IntProducer
29+
process.intProducer = IntProducer(ivalue = 42)
30+
31+
from FWCore.Integration.modules import ThingProducer
32+
process.thing = ThingProducer()
33+
34+
process.t = cms.Task(
35+
process.intProducer,
36+
process.thing,
37+
)
38+
process.p = cms.Path(process.t)
39+
process.ep = cms.EndPath(process.out)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import FWCore.ParameterSet.Config as cms
2+
import argparse
3+
4+
parser = argparse.ArgumentParser(description='Test reduced ProcessHistory')
5+
parser.add_argument("--input", type=str, help="Input file")
6+
#parser.add_argument("--bypassVersionCheck", action="store_true", help="Bypass version check")
7+
parser.add_argument("--expectNewLumi", action="store_true", help="Set this if a new lumi is expected between the original files")
8+
parser.add_argument("--expectNewRun", action="store_true", help="Set this if a new run is expected between the original files")
9+
parser.add_argument("--output", type=str, help="Output file name")
10+
11+
args = parser.parse_args()
12+
13+
process = cms.Process("READ")
14+
15+
from IOPool.Streamer.modules import NewEventStreamFileReader
16+
process.source = NewEventStreamFileReader(
17+
fileNames = [f"file:{args.input}"],
18+
# bypassVersionCheck = args.bypassVersionCheck,
19+
)
20+
21+
from IOPool.Output.modules import PoolOutputModule
22+
process.out = PoolOutputModule(
23+
fileName = args.output
24+
)
25+
26+
from FWCore.Framework.modules import RunLumiEventAnalyzer
27+
process.test = RunLumiEventAnalyzer(
28+
expectedRunLumiEvents = [
29+
1, 0, 0, # beginRun
30+
1, 1, 0, # beginLumi
31+
1, 1, 1,
32+
1, 1, 2,
33+
1, 1, 3,
34+
1, 1, 4,
35+
1, 1, 5,
36+
1, 1, 6,
37+
1, 1, 7,
38+
1, 1, 8,
39+
1, 1, 9,
40+
1, 1, 10,
41+
1, 1, 101,
42+
1, 1, 102,
43+
1, 1, 103,
44+
1, 1, 104,
45+
1, 1, 105,
46+
1, 1, 106,
47+
1, 1, 107,
48+
1, 1, 108,
49+
1, 1, 109,
50+
1, 1, 110,
51+
1, 1, 0, # endLumi
52+
1, 0, 0, # endRun
53+
]
54+
)
55+
endFirstFileIndex = 3*(10+2)
56+
if args.expectNewLumi:
57+
process.test.expectedRunLumiEvents = process.test.expectedRunLumiEvents[:endFirstFileIndex] + [
58+
1, 1, 0, # endLumi
59+
1, 0, 0, # endRun
60+
1, 0, 0, # beginRun
61+
1, 1, 0, # beginLumi
62+
1, 1, 201,
63+
1, 1, 202,
64+
1, 1, 203,
65+
1, 1, 204,
66+
1, 1, 205,
67+
1, 1, 206,
68+
1, 1, 207,
69+
1, 1, 208,
70+
1, 1, 209,
71+
1, 1, 210,
72+
1, 1, 0, # endLumi
73+
1, 0, 0, # endRun
74+
]
75+
elif args.expectNewRun:
76+
process.test.expectedRunLumiEvents = process.test.expectedRunLumiEvents[:endFirstFileIndex] + [
77+
1, 1, 0, # endLumi
78+
1, 0, 0, # endRun
79+
1, 0, 0, # beginRun
80+
1, 2, 0, # beginLumi
81+
1, 2, 201,
82+
1, 2, 202,
83+
1, 2, 203,
84+
1, 2, 204,
85+
1, 2, 205,
86+
1, 2, 206,
87+
1, 2, 207,
88+
1, 2, 208,
89+
1, 2, 209,
90+
1, 2, 210,
91+
1, 2, 0, # endLumi
92+
1, 0, 0, # endRun
93+
]
94+
95+
process.p = cms.Path(
96+
process.test
97+
)
98+
process.ep = cms.EndPath(
99+
process.out
100+
)

0 commit comments

Comments
 (0)