Skip to content

Commit

Permalink
Fix unit test failures after removing legacy modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr15Jones committed Oct 5, 2021
1 parent 9c36c49 commit 277322d
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 132 deletions.
83 changes: 20 additions & 63 deletions FWCore/Framework/test/stubs/TestMergeResults.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,13 @@ namespace edmtest {
class TestMergeResults : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one::WatchLuminosityBlocks> {
public:
explicit TestMergeResults(edm::ParameterSet const&);
virtual ~TestMergeResults();

virtual void analyze(edm::Event const& e, edm::EventSetup const& c);
virtual void beginRun(edm::Run const&, edm::EventSetup const&);
virtual void endRun(edm::Run const&, edm::EventSetup const&);
virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
virtual void respondToOpenInputFile(edm::FileBlock const& fb);
virtual void respondToCloseInputFile(edm::FileBlock const& fb);
void endJob();
void analyze(edm::Event const& e, edm::EventSetup const& c) override;
void beginRun(edm::Run const&, edm::EventSetup const&) override;
void endRun(edm::Run const&, edm::EventSetup const&) override;
void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
void endJob() override;

private:
void checkExpectedLumiProducts(unsigned int index,
Expand Down Expand Up @@ -99,20 +96,15 @@ namespace edmtest {

std::vector<int> expectedDroppedEvent_;
std::vector<int> expectedDroppedEvent1_;

int nRespondToOpenInputFile_;
int nRespondToCloseInputFile_;
int expectedRespondToOpenInputFile_;
int expectedRespondToCloseInputFile_;

std::vector<std::string> expectedInputFileNames_;
std::vector<int> expectedDroppedEvent1NEvents_;

bool verbose_;

unsigned int indexRun_;
unsigned int indexLumi_;
unsigned int parentIndex_;
unsigned int droppedIndex1_;
int droppedIndex1EventCount_;
unsigned int processHistoryIndex_;

edm::Handle<edmtest::Thing> h_thing;
Expand Down Expand Up @@ -148,21 +140,16 @@ namespace edmtest {

expectedDroppedEvent_(ps.getUntrackedParameter<std::vector<int> >("expectedDroppedEvent", default_)),
expectedDroppedEvent1_(ps.getUntrackedParameter<std::vector<int> >("expectedDroppedEvent1", default_)),

nRespondToOpenInputFile_(0),
nRespondToCloseInputFile_(0),
expectedRespondToOpenInputFile_(ps.getUntrackedParameter<int>("expectedRespondToOpenInputFile", -1)),
expectedRespondToCloseInputFile_(ps.getUntrackedParameter<int>("expectedRespondToCloseInputFile", -1)),

expectedInputFileNames_(
ps.getUntrackedParameter<std::vector<std::string> >("expectedInputFileNames", defaultvstring_)),
expectedDroppedEvent1NEvents_(
ps.getUntrackedParameter<std::vector<int> >("expectedDroppedEvent1NEvents", default_)),

verbose_(ps.getUntrackedParameter<bool>("verbose", false)),

indexRun_(0),
indexLumi_(0),
parentIndex_(0),
droppedIndex1_(0),
droppedIndex1EventCount_(0),
processHistoryIndex_(0),
testAlias_(ps.getUntrackedParameter<bool>("testAlias", false)) {
auto ap_thing = std::make_unique<edmtest::Thing>();
Expand Down Expand Up @@ -193,6 +180,7 @@ namespace edmtest {
mayConsume<edmtest::Thing>(edm::InputTag{parent, "event", "PROD"});
}
if (expectedDroppedEvent1_.size() > droppedIndex1_) {
assert(expectedDroppedEvent1_.size() == expectedDroppedEvent1NEvents_.size());
consumes<edmtest::ThingWithIsEqual>(edm::InputTag{"makeThingToBeDropped1", "event", "PROD"});
}
consumes<edmtest::Thing>(edm::InputTag{"thingWithMergeProducer", "event", "PROD"});
Expand Down Expand Up @@ -289,10 +277,6 @@ namespace edmtest {

// -----------------------------------------------------------------

TestMergeResults::~TestMergeResults() {}

// -----------------------------------------------------------------

void TestMergeResults::analyze(edm::Event const& e, edm::EventSetup const&) {
assert(e.processHistory().id() == e.processHistoryID());

Expand All @@ -311,6 +295,14 @@ namespace edmtest {
// This one is used to test the merging step when a specific product
// has been dropped or not created in some of the input files.
if (expectedDroppedEvent1_.size() > droppedIndex1_) {
++droppedIndex1EventCount_;
if (droppedIndex1EventCount_ > expectedDroppedEvent1NEvents_[droppedIndex1_]) {
++droppedIndex1_;
std::cout << "advance " << droppedIndex1_ << std::endl;
droppedIndex1EventCount_ = 1;
}
assert(droppedIndex1_ < expectedDroppedEvent1_.size());

edm::InputTag tag("makeThingToBeDropped1", "event", "PROD");
e.getByLabel(tag, h_thingWithIsEqual);
if (expectedDroppedEvent1_[droppedIndex1_] == -1) {
Expand Down Expand Up @@ -510,44 +502,9 @@ namespace edmtest {
indexLumi_ += 3;
}

void TestMergeResults::respondToOpenInputFile(edm::FileBlock const& fb) {
if (verbose_)
edm::LogInfo("TestMergeResults") << "respondToOpenInputFile";

if (!expectedInputFileNames_.empty()) {
if (expectedInputFileNames_.size() <= static_cast<unsigned>(nRespondToOpenInputFile_) ||
expectedInputFileNames_[nRespondToOpenInputFile_] != fb.fileName()) {
std::cerr << "Error while testing merging of run/lumi products in TestMergeResults.cc\n"
<< "Unexpected input filename, expected name = " << expectedInputFileNames_[nRespondToOpenInputFile_]
<< " actual name = " << fb.fileName() << std::endl;
abort();
}
}
++nRespondToOpenInputFile_;
}

void TestMergeResults::respondToCloseInputFile(edm::FileBlock const&) {
if (verbose_)
edm::LogInfo("TestMergeResults") << "respondToCloseInputFile";
++nRespondToCloseInputFile_;
++droppedIndex1_;
}

void TestMergeResults::endJob() {
if (verbose_)
edm::LogInfo("TestMergeResults") << "endJob";

if (expectedRespondToOpenInputFile_ > -1 && nRespondToOpenInputFile_ != expectedRespondToOpenInputFile_) {
std::cerr << "Error while testing merging of run/lumi products in TestMergeResults.cc\n"
<< "Unexpected number of calls to the function respondToOpenInputFile" << std::endl;
abort();
}

if (expectedRespondToCloseInputFile_ > -1 && nRespondToCloseInputFile_ != expectedRespondToCloseInputFile_) {
std::cerr << "Error while testing merging of run/lumi products in TestMergeResults.cc\n"
<< "Unexpected number of calls to the function respondToCloseInputFile" << std::endl;
abort();
}
}

void TestMergeResults::checkExpectedRunProducts(unsigned int index,
Expand Down
13 changes: 1 addition & 12 deletions FWCore/Integration/test/testRunMergeMERGE2_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,7 @@
),

expectedDroppedEvent1 = cms.untracked.vint32(13, 13, -1, -1, -1, 13),

expectedRespondToOpenInputFile = cms.untracked.int32(6),
expectedRespondToCloseInputFile = cms.untracked.int32(6),

expectedInputFileNames = cms.untracked.vstring(
'file:testRunMerge0.root',
'file:testRunMerge1.root',
'file:testRunMerge2extra.root',
'file:testRunMerge3extra.root',
'file:testRunMerge4.root',
'file:testRunMerge5.root'
),
expectedDroppedEvent1NEvents = cms.untracked.vint32(1,10,10,10,1,99),

verbose = cms.untracked.bool(False),
testAlias = cms.untracked.bool(True)
Expand Down
12 changes: 1 addition & 11 deletions FWCore/Integration/test/testRunMergeMERGE4_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,7 @@
),

expectedDroppedEvent1 = cms.untracked.vint32(13, -1, -1, -1, 13),

expectedRespondToOpenInputFile = cms.untracked.int32(5),
expectedRespondToCloseInputFile = cms.untracked.int32(5),

expectedInputFileNames = cms.untracked.vstring(
'file:testRunMerge1.root',
'file:testRunMerge2.root',
'file:testRunMerge3.root',
'file:testRunMerge4.root',
'file:testRunMerge7.root'
),
expectedDroppedEvent1NEvents = cms.untracked.vint32(10,10,10,1,1),

verbose = cms.untracked.bool(False)
)
Expand Down
16 changes: 3 additions & 13 deletions FWCore/Integration/test/testRunMergeMERGE_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
process = cms.Process("MERGE")

process.load("FWCore.MessageService.MessageLogger_cfi")
process.MessageLogger.cerr.FwkReport.reportEvery = 1000
process.MessageLogger.cerr.threshold = 'ERROR'
#process.MessageLogger.cerr.FwkReport.reportEvery = 1000
#process.MessageLogger.cerr.threshold = 'ERROR'

import FWCore.Framework.test.cmsExceptionsFatalOption_cff
process.options = cms.untracked.PSet(
Expand Down Expand Up @@ -97,17 +97,7 @@
),

expectedDroppedEvent1 = cms.untracked.vint32(13, -1, -1, -1, 13),

expectedRespondToOpenInputFile = cms.untracked.int32(5),
expectedRespondToCloseInputFile = cms.untracked.int32(5),

expectedInputFileNames = cms.untracked.vstring(
'file:testRunMerge1.root',
'file:testRunMerge2.root',
'file:testRunMerge3.root',
'file:testRunMerge4.root',
'file:testRunMerge5.root'
),
expectedDroppedEvent1NEvents = cms.untracked.vint32(10,10,10,1,99),

verbose = cms.untracked.bool(False),
testAlias = cms.untracked.bool(True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,6 @@ For products only read from previous processes, 'skip current process' is added
EndPathStatusInserter/'e'
EndPathStatusInserter/'p1ep2'

The following legacy modules are configured. Support for legacy modules
is going to end soon. These modules need to be converted to have type
edm::global, edm::stream, edm::one, or in rare cases edm::limited.
IntVectorProducer intVectorProducer
%MSG
Process name = PROD2
paths:
path1
Expand Down
13 changes: 0 additions & 13 deletions FWCore/Integration/test/unit_test_outputs/testGetBy1.log
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ Module type=IntProducer, Module label=intProducerA, Parameter Set ID=38971365e81
++++ finished: constructing module with label 'intVectorProducer' id = 14
++ preallocate: 1 concurrent runs, 1 concurrent luminosity sections, 1 streams
++ starting: begin job
The following legacy modules are configured. Support for legacy modules
is going to end soon. These modules need to be converted to have type
edm::global, edm::stream, edm::one, or in rare cases edm::limited.
IntVectorProducer intVectorProducer
%MSG
++++ starting: begin job for module with label 'intProducerA' id = 9
Module type=IntProducer, Module label=intProducerA, Parameter Set ID=38971365e8174cb2ccc12430661ba6d4
++++ finished: begin job for module with label 'intProducerA' id = 9
Expand Down Expand Up @@ -213,8 +208,6 @@ GlobalContext: transition = BeginRun
runIndex = 0 luminosityBlockIndex = 4294967295 unixTime = 0 microsecondOffset = 1
ProcessContext: PROD1 be16549dc0c1f4b03231a8b98d235dac

++++++ starting: global begin run for module: label = 'intVectorProducer' id = 14
++++++ finished: global begin run for module: label = 'intVectorProducer' id = 14
++++++ starting: global begin run for module: label = 'a1' id = 5
GlobalContext: transition = BeginRun
run: 1 luminosityBlock: 0
Expand Down Expand Up @@ -327,8 +320,6 @@ GlobalContext: transition = BeginLuminosityBlock
runIndex = 0 luminosityBlockIndex = 0 unixTime = 0 microsecondOffset = 1
ProcessContext: PROD1 be16549dc0c1f4b03231a8b98d235dac

++++++ starting: global begin lumi for module: label = 'intVectorProducer' id = 14
++++++ finished: global begin lumi for module: label = 'intVectorProducer' id = 14
++++++ starting: global begin lumi for module: label = 'a1' id = 5
GlobalContext: transition = BeginLuminosityBlock
run: 1 luminosityBlock: 1
Expand Down Expand Up @@ -1173,8 +1164,6 @@ GlobalContext: transition = EndLuminosityBlock
runIndex = 0 luminosityBlockIndex = 0 unixTime = 0 microsecondOffset = 1
ProcessContext: PROD1 be16549dc0c1f4b03231a8b98d235dac

++++++ starting: global end lumi for module: label = 'intVectorProducer' id = 14
++++++ finished: global end lumi for module: label = 'intVectorProducer' id = 14
++++++ starting: global end lumi for module: label = 'a1' id = 5
GlobalContext: transition = EndLuminosityBlock
run: 1 luminosityBlock: 1
Expand Down Expand Up @@ -1313,8 +1302,6 @@ GlobalContext: transition = EndRun
runIndex = 0 luminosityBlockIndex = 4294967295 unixTime = 0 microsecondOffset = 15000001
ProcessContext: PROD1 be16549dc0c1f4b03231a8b98d235dac

++++++ starting: global end run for module: label = 'intVectorProducer' id = 14
++++++ finished: global end run for module: label = 'intVectorProducer' id = 14
++++++ starting: global end run for module: label = 'a1' id = 5
GlobalContext: transition = EndRun
run: 1 luminosityBlock: 0
Expand Down
13 changes: 0 additions & 13 deletions FWCore/Integration/test/unit_test_outputs/testGetBy2.log
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ Module type=IntProducer, Module label=intProducer, Parameter Set ID=0e62dace196e
++++ finished: constructing module with label 'intVectorProducer' id = 7
++ preallocate: 1 concurrent runs, 1 concurrent luminosity sections, 1 streams
++ starting: begin job
The following legacy modules are configured. Support for legacy modules
is going to end soon. These modules need to be converted to have type
edm::global, edm::stream, edm::one, or in rare cases edm::limited.
IntVectorProducer intVectorProducer
%MSG
++++ starting: begin job for module with label 'intProducerU' id = 6
++++ finished: begin job for module with label 'intProducerU' id = 6
++++ starting: begin job for module with label 'intVectorProducer' id = 7
Expand Down Expand Up @@ -128,8 +123,6 @@ GlobalContext: transition = BeginRun
runIndex = 0 luminosityBlockIndex = 4294967295 unixTime = 0 microsecondOffset = 1
ProcessContext: PROD2 7da3661f4f7dead5e42f07cf3ddf5a59

++++++ starting: global begin run for module: label = 'intVectorProducer' id = 7
++++++ finished: global begin run for module: label = 'intVectorProducer' id = 7
++++ finished: global begin run 1 : time = 1
GlobalContext: transition = BeginRun
run: 1 luminosityBlock: 0
Expand Down Expand Up @@ -182,8 +175,6 @@ GlobalContext: transition = BeginLuminosityBlock
runIndex = 0 luminosityBlockIndex = 0 unixTime = 0 microsecondOffset = 1
ProcessContext: PROD2 7da3661f4f7dead5e42f07cf3ddf5a59

++++++ starting: global begin lumi for module: label = 'intVectorProducer' id = 7
++++++ finished: global begin lumi for module: label = 'intVectorProducer' id = 7
++++ finished: global begin lumi: run = 1 lumi = 1 time = 1
GlobalContext: transition = BeginLuminosityBlock
run: 1 luminosityBlock: 1
Expand Down Expand Up @@ -716,8 +707,6 @@ GlobalContext: transition = EndLuminosityBlock
runIndex = 0 luminosityBlockIndex = 0 unixTime = 0 microsecondOffset = 1
ProcessContext: PROD2 7da3661f4f7dead5e42f07cf3ddf5a59

++++++ starting: global end lumi for module: label = 'intVectorProducer' id = 7
++++++ finished: global end lumi for module: label = 'intVectorProducer' id = 7
++++ finished: global end lumi: run = 1 lumi = 1 time = 1
GlobalContext: transition = EndLuminosityBlock
run: 1 luminosityBlock: 1
Expand Down Expand Up @@ -782,8 +771,6 @@ GlobalContext: transition = EndRun
runIndex = 0 luminosityBlockIndex = 4294967295 unixTime = 0 microsecondOffset = 15000001
ProcessContext: PROD2 7da3661f4f7dead5e42f07cf3ddf5a59

++++++ starting: global end run for module: label = 'intVectorProducer' id = 7
++++++ finished: global end run for module: label = 'intVectorProducer' id = 7
++++ finished: global end run 1 : time = 15000001
GlobalContext: transition = EndRun
run: 1 luminosityBlock: 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1 ProducerWithPSetDesc (EDProducer) "pluginTestProducerWithPSetDesc.so"
1 ProducerWithPSetDesc (global::EDProducer) "pluginTestProducerWithPSetDesc.so"
1.1 testProducerWithPsetDesc
testingAutoGeneratedCfi untracked bool optional True
p_int int32 2147483647
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1 ProducerWithPSetDesc (EDProducer) "pluginTestProducerWithPSetDesc.so"
1 ProducerWithPSetDesc (global::EDProducer) "pluginTestProducerWithPSetDesc.so"

This plugin has 4 PSet descriptions. The description used to validate a
configuration is selected by matching the module labels. If none match, then
Expand Down

0 comments on commit 277322d

Please sign in to comment.