Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-07-28 22:48:27

0001 
0002 # Use this as follows:
0003 #
0004 # cmsRun FWCore/Integration/test/testFrameworkExceptionHandling_cfg.py testNumber=1
0005 #
0006 # with the value assigned to testNumber having a value from 1 to 16.
0007 # That value specifies which transition to throw an exception in.
0008 # If the value is not specified, then no exception is thrown.
0009 
0010 import FWCore.ParameterSet.Config as cms
0011 
0012 nStreams = 4
0013 nRuns = 17
0014 nLumisPerRun = 1
0015 nEventsPerLumi = 6
0016 
0017 nEventsPerRun = nLumisPerRun*nEventsPerLumi
0018 nLumis = nRuns*nLumisPerRun
0019 nEvents = nRuns*nEventsPerRun
0020 
0021 process = cms.Process("TEST")
0022 
0023 process.load("FWCore.MessageService.MessageLogger_cfi")
0024 process.MessageLogger.cerr.FwkReport.reportEvery = 100
0025 
0026 from FWCore.ParameterSet.VarParsing import VarParsing
0027 
0028 process.TestServiceOne = cms.Service("TestServiceOne",
0029     verbose = cms.untracked.bool(False),
0030     printTimestamps = cms.untracked.bool(True)
0031 )
0032 
0033 process.TestServiceTwo = cms.Service("TestServiceTwo",
0034     verbose = cms.untracked.bool(False),
0035     printTimestamps = cms.untracked.bool(True)
0036 )
0037 
0038 options = VarParsing()
0039 
0040 options.register("testNumber", 0,
0041                  VarParsing.multiplicity.singleton,
0042                  VarParsing.varType.int,
0043                  "Test number")
0044 
0045 options.parseArguments()
0046 
0047 process.source = cms.Source("EmptySource",
0048     firstRun = cms.untracked.uint32(1),
0049     firstLuminosityBlock = cms.untracked.uint32(1),
0050     firstEvent = cms.untracked.uint32(1),
0051     numberEventsInLuminosityBlock = cms.untracked.uint32(nEventsPerLumi),
0052     numberEventsInRun = cms.untracked.uint32(nEventsPerRun)
0053 )
0054 
0055 process.maxEvents = cms.untracked.PSet(
0056     input = cms.untracked.int32(nEvents)
0057 )
0058 
0059 process.options = cms.untracked.PSet(
0060     numberOfThreads = cms.untracked.uint32(4),
0061     numberOfStreams = cms.untracked.uint32(nStreams),
0062     numberOfConcurrentRuns = cms.untracked.uint32(4),
0063     numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(4)
0064 )
0065 
0066 process.busy1 = cms.EDProducer("BusyWaitIntProducer",ivalue = cms.int32(1), iterations = cms.uint32(10*1000*1000))
0067 
0068 process.throwException = cms.EDProducer("ExceptionThrowingProducer",
0069     verbose = cms.untracked.bool(False)
0070 )
0071 process.doNotThrowException = cms.EDProducer("ExceptionThrowingProducer")
0072 
0073 print('testNumber', options.testNumber)
0074 
0075 # Below, the EventID's are selected such that it is likely that in the process
0076 # configured by this file that more than 1 run, more than 1 lumi and more than 1 event
0077 # (stream) will be in flight when the exception is thrown.
0078 
0079 if options.testNumber == 1:
0080     process.throwException.eventIDThrowOnEvent = cms.untracked.EventID(3, 1, 5)
0081 elif options.testNumber == 2:
0082     process.throwException.eventIDThrowOnGlobalBeginRun = cms.untracked.EventID(4, 0, 0)
0083     process.throwException.expectedGlobalBeginRun = cms.untracked.uint32(4)
0084     process.throwException.expectedOffsetNoGlobalEndRun = cms.untracked.uint32(1)
0085     process.throwException.expectedOffsetNoWriteRun = cms.untracked.uint32(1)
0086     process.doNotThrowException.expectedOffsetNoGlobalEndRun = cms.untracked.uint32(1)
0087     process.doNotThrowException.expectedOffsetNoWriteRun = cms.untracked.uint32(1)
0088 elif options.testNumber == 3:
0089     process.throwException.eventIDThrowOnGlobalBeginLumi = cms.untracked.EventID(4, 1, 0)
0090     process.throwException.expectedGlobalBeginLumi = cms.untracked.uint32(4)
0091     process.throwException.expectedOffsetNoGlobalEndLumi = cms.untracked.uint32(1)
0092     process.throwException.expectedOffsetNoWriteLumi = cms.untracked.uint32(1)
0093     process.doNotThrowException.expectedOffsetNoGlobalEndLumi = cms.untracked.uint32(1)
0094     process.doNotThrowException.expectedOffsetNoWriteLumi = cms.untracked.uint32(1)
0095 elif options.testNumber == 4:
0096     process.throwException.eventIDThrowOnGlobalEndRun = cms.untracked.EventID(3, 0, 0)
0097     process.throwException.expectedGlobalBeginRun = cms.untracked.uint32(3)
0098     process.throwException.expectedOffsetNoWriteRun = cms.untracked.uint32(1)
0099     process.doNotThrowException.expectedOffsetNoWriteRun = cms.untracked.uint32(1)
0100 elif options.testNumber == 5:
0101     process.throwException.eventIDThrowOnGlobalEndLumi = cms.untracked.EventID(3, 1, 0)
0102     process.throwException.expectedGlobalBeginLumi = cms.untracked.uint32(3)
0103     process.throwException.expectedOffsetNoWriteLumi = cms.untracked.uint32(1)
0104     process.doNotThrowException.expectedOffsetNoWriteLumi = cms.untracked.uint32(1)
0105 elif options.testNumber == 6:
0106     process.throwException.eventIDThrowOnStreamBeginRun = cms.untracked.EventID(4, 0, 0)
0107     process.throwException.expectedStreamBeginRun = cms.untracked.uint32(4)
0108     process.throwException.expectedOffsetNoStreamEndRun = cms.untracked.uint32(1)
0109     process.doNotThrowException.expectedStreamBeginRun = cms.untracked.uint32(4)
0110     process.doNotThrowException.expectedOffsetNoStreamEndRun = cms.untracked.uint32(1)
0111 elif options.testNumber == 7:
0112     process.throwException.eventIDThrowOnStreamBeginLumi = cms.untracked.EventID(4, 1, 0)
0113     process.throwException.expectedStreamBeginLumi = cms.untracked.uint32(4)
0114     process.throwException.expectedOffsetNoStreamEndLumi = cms.untracked.uint32(1)
0115     process.doNotThrowException.expectedStreamBeginLumi = cms.untracked.uint32(4)
0116     process.doNotThrowException.expectedOffsetNoStreamEndLumi = cms.untracked.uint32(1)
0117 elif options.testNumber == 8:
0118     process.throwException.eventIDThrowOnStreamEndRun = cms.untracked.EventID(3, 0, 0)
0119 elif options.testNumber == 9:
0120     process.throwException.eventIDThrowOnStreamEndLumi = cms.untracked.EventID(3, 1, 0)
0121 elif options.testNumber == 10:
0122     process.throwException.throwInBeginJob = cms.untracked.bool(True)
0123     process.throwException.expectedNEndJob = cms.untracked.uint32(0)
0124     process.throwException.expectedOffsetNoEndJob = cms.untracked.uint32(1)
0125     process.doNotThrowException.expectedNBeginStream = cms.untracked.uint32(0)
0126     process.doNotThrowException.expectedNBeginProcessBlock = cms.untracked.uint32(0)
0127     process.doNotThrowException.expectedNEndProcessBlock = cms.untracked.uint32(0)
0128     process.doNotThrowException.expectedNEndStream = cms.untracked.uint32(0)
0129     process.doNotThrowException.expectNoRunsProcessed = cms.untracked.bool(True)
0130     process.doNotThrowException.expectedOffsetNoEndJob = cms.untracked.uint32(1)
0131 elif options.testNumber == 11:
0132     process.throwException.throwInBeginStream = cms.untracked.bool(True)
0133     process.throwException.expectedNBeginStream = cms.untracked.uint32(4)
0134     process.throwException.expectedNBeginProcessBlock = cms.untracked.uint32(0)
0135     process.throwException.expectedNEndProcessBlock = cms.untracked.uint32(0)
0136     process.throwException.expectedNEndStream = cms.untracked.uint32(3)
0137     process.throwException.expectNoRunsProcessed = cms.untracked.bool(True)
0138     process.throwException.expectedOffsetNoEndStream = cms.untracked.uint32(1)
0139     process.doNotThrowException.expectedNBeginStream = cms.untracked.uint32(4)
0140     process.doNotThrowException.expectedNBeginProcessBlock = cms.untracked.uint32(0)
0141     process.doNotThrowException.expectedNEndProcessBlock = cms.untracked.uint32(0)
0142     process.doNotThrowException.expectedNEndStream = cms.untracked.uint32(4)
0143     process.doNotThrowException.expectNoRunsProcessed = cms.untracked.bool(True)
0144     process.doNotThrowException.expectedOffsetNoEndStream = cms.untracked.uint32(1)
0145 elif options.testNumber == 12:
0146     process.throwException.throwInBeginProcessBlock = cms.untracked.bool(True)
0147     process.throwException.expectedNEndProcessBlock = cms.untracked.uint32(0)
0148     process.throwException.expectNoRunsProcessed = cms.untracked.bool(True)
0149     process.throwException.expectedOffsetNoEndProcessBlock = cms.untracked.uint32(1)
0150     process.doNotThrowException.expectNoRunsProcessed = cms.untracked.bool(True)
0151     process.doNotThrowException.expectedOffsetNoEndProcessBlock = cms.untracked.uint32(1)
0152 elif options.testNumber == 13:
0153     process.throwException.throwInEndProcessBlock = cms.untracked.bool(True)
0154 elif options.testNumber == 14:
0155     process.throwException.throwInEndStream = cms.untracked.bool(True)
0156 elif options.testNumber == 15:
0157     process.throwException.throwInEndJob = cms.untracked.bool(True)
0158 # This one does not throw. It is not used in the unit test but was useful
0159 # when manually debugging the test itself and manually debugging other things.
0160 elif options.testNumber == 16:
0161     process.throwException.throwInEndJob = cms.untracked.bool(False)
0162 else:
0163     print("The parameter named testNumber is out of range. An exception will not be thrown. Supported values range from 1 to 16.")
0164     print("The proper syntax for setting the parameter is:")
0165     print("")
0166     print ("    cmsRun FWCore/Integration/test/testFrameworkExceptionHandling_cfg.py testNumber=1")
0167     print("")
0168 process.path1 = cms.Path(
0169     process.busy1 *
0170     process.throwException
0171 )
0172 process.path2 = cms.Path(process.doNotThrowException)