Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-06-04 04:34:59

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 9.
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 from FWCore.ParameterSet.VarParsing import VarParsing
0024 
0025 process.TestServiceOne = cms.Service("TestServiceOne",
0026     verbose = cms.untracked.bool(False),
0027     printTimestamps = cms.untracked.bool(True)
0028 )
0029 
0030 process.TestServiceTwo = cms.Service("TestServiceTwo",
0031     verbose = cms.untracked.bool(False),
0032     printTimestamps = cms.untracked.bool(True)
0033 )
0034 
0035 options = VarParsing()
0036 
0037 options.register("testNumber", 0,
0038                  VarParsing.multiplicity.singleton,
0039                  VarParsing.varType.int,
0040                  "Test number")
0041 
0042 options.parseArguments()
0043 
0044 process.source = cms.Source("EmptySource",
0045     firstRun = cms.untracked.uint32(1),
0046     firstLuminosityBlock = cms.untracked.uint32(1),
0047     firstEvent = cms.untracked.uint32(1),
0048     numberEventsInLuminosityBlock = cms.untracked.uint32(nEventsPerLumi),
0049     numberEventsInRun = cms.untracked.uint32(nEventsPerRun)
0050 )
0051 
0052 process.maxEvents = cms.untracked.PSet(
0053     input = cms.untracked.int32(nEvents)
0054 )
0055 
0056 process.options = cms.untracked.PSet(
0057     numberOfThreads = cms.untracked.uint32(4),
0058     numberOfStreams = cms.untracked.uint32(nStreams),
0059     numberOfConcurrentRuns = cms.untracked.uint32(4),
0060     numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(4)
0061 )
0062 
0063 process.busy1 = cms.EDProducer("BusyWaitIntProducer",ivalue = cms.int32(1), iterations = cms.uint32(10*1000*1000))
0064 
0065 process.throwException = cms.EDProducer("ExceptionThrowingProducer")
0066 process.doNotThrowException = cms.EDProducer("ExceptionThrowingProducer")
0067 
0068 print('testNumber', options.testNumber)
0069 
0070 # Below, the EventID's are selected such that it is likely that in the process
0071 # configured by this file that more than 1 run, more than 1 lumi and more than 1 event
0072 # (stream) will be in flight when the exception is thrown.
0073 
0074 if options.testNumber == 1:
0075     process.throwException.eventIDThrowOnEvent = cms.untracked.EventID(3, 1, 5)
0076 elif options.testNumber == 2:
0077     process.throwException.eventIDThrowOnGlobalBeginRun = cms.untracked.EventID(4, 0, 0)
0078     process.throwException.expectedGlobalBeginRun = cms.untracked.uint32(4)
0079     process.throwException.expectedOffsetNoGlobalEndRun = cms.untracked.uint32(1)
0080     process.throwException.expectedOffsetNoWriteRun = cms.untracked.uint32(1)
0081     process.doNotThrowException.expectedOffsetNoGlobalEndRun = cms.untracked.uint32(1)
0082     process.doNotThrowException.expectedOffsetNoWriteRun = cms.untracked.uint32(1)
0083 elif options.testNumber == 3:
0084     process.throwException.eventIDThrowOnGlobalBeginLumi = cms.untracked.EventID(4, 1, 0)
0085     process.throwException.expectedGlobalBeginLumi = cms.untracked.uint32(4)
0086     process.throwException.expectedOffsetNoGlobalEndLumi = cms.untracked.uint32(1)
0087     process.throwException.expectedOffsetNoWriteLumi = cms.untracked.uint32(1)
0088     process.doNotThrowException.expectedOffsetNoGlobalEndLumi = cms.untracked.uint32(1)
0089     process.doNotThrowException.expectedOffsetNoWriteLumi = cms.untracked.uint32(1)
0090 elif options.testNumber == 4:
0091     process.throwException.eventIDThrowOnGlobalEndRun = cms.untracked.EventID(3, 0, 0)
0092     process.throwException.expectedGlobalBeginRun = cms.untracked.uint32(3)
0093     process.throwException.expectedOffsetNoWriteRun = cms.untracked.uint32(1)
0094     process.doNotThrowException.expectedOffsetNoWriteRun = cms.untracked.uint32(1)
0095 elif options.testNumber == 5:
0096     process.throwException.eventIDThrowOnGlobalEndLumi = cms.untracked.EventID(3, 1, 0)
0097     process.throwException.expectedGlobalBeginLumi = cms.untracked.uint32(3)
0098     process.throwException.expectedOffsetNoWriteLumi = cms.untracked.uint32(1)
0099     process.doNotThrowException.expectedOffsetNoWriteLumi = cms.untracked.uint32(1)
0100 elif options.testNumber == 6:
0101     process.throwException.eventIDThrowOnStreamBeginRun = cms.untracked.EventID(4, 0, 0)
0102     process.throwException.expectedStreamBeginRun = cms.untracked.uint32(4)
0103     process.throwException.expectedOffsetNoStreamEndRun = cms.untracked.uint32(1)
0104     process.doNotThrowException.expectedStreamBeginRun = cms.untracked.uint32(4)
0105     process.doNotThrowException.expectedOffsetNoStreamEndRun = cms.untracked.uint32(1)
0106 elif options.testNumber == 7:
0107     process.throwException.eventIDThrowOnStreamBeginLumi = cms.untracked.EventID(4, 1, 0)
0108     process.throwException.expectedStreamBeginLumi = cms.untracked.uint32(4)
0109     process.throwException.expectedOffsetNoStreamEndLumi = cms.untracked.uint32(1)
0110     process.doNotThrowException.expectedStreamBeginLumi = cms.untracked.uint32(4)
0111     process.doNotThrowException.expectedOffsetNoStreamEndLumi = cms.untracked.uint32(1)
0112 elif options.testNumber == 8:
0113     process.throwException.eventIDThrowOnStreamEndRun = cms.untracked.EventID(3, 0, 0)
0114     process.throwException.expectedStreamBeginRun = cms.untracked.uint32(3)
0115     process.doNotThrowException.expectedStreamBeginRun = cms.untracked.uint32(3)
0116 elif options.testNumber == 9:
0117     process.throwException.eventIDThrowOnStreamEndLumi = cms.untracked.EventID(3, 1, 0)
0118     process.throwException.expectedStreamBeginLumi = cms.untracked.uint32(3)
0119     process.doNotThrowException.expectedStreamBeginLumi = cms.untracked.uint32(3)
0120 else:
0121     print("The parameter named testNumber is out of range. An exception will not be thrown. Supported values range from 1 to 9.")
0122     print("The proper syntax for setting the parameter is:")
0123     print("")
0124     print ("    cmsRun FWCore/Integration/test/testFrameworkExceptionHandling_cfg.py testNumber=1")
0125     print("")
0126 process.path1 = cms.Path(
0127     process.busy1 *
0128     process.throwException
0129 )
0130 process.path2 = cms.Path(process.doNotThrowException)