Skip to content

Commit c09d976

Browse files
authored
Merge pull request #47032 from makortel/reducedHistoryCheck
Add a new test for reduced ProcessHistory
2 parents 79e4b35 + a969e1e commit c09d976

13 files changed

+507
-218
lines changed

FWCore/Framework/src/ScheduleItems.cc

+9-2
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,15 @@ namespace edm {
134134

135135
act_table_ = std::make_unique<ExceptionToActionTable>(parameterSet);
136136
std::string processName = parameterSet.getParameter<std::string>("@process_name");
137-
processConfiguration_ = std::make_shared<ProcessConfiguration>(
138-
processName, getReleaseVersion(), getPassID()); // propagate_const<T> has no reset() function
137+
std::string releaseVersion;
138+
if (parameterSet.existsAs<std::string>("@special_override_release_version_only_for_testing", false)) {
139+
releaseVersion =
140+
parameterSet.getUntrackedParameter<std::string>("@special_override_release_version_only_for_testing");
141+
} else {
142+
releaseVersion = getReleaseVersion();
143+
}
144+
// propagate_const<T> has no reset() function
145+
processConfiguration_ = std::make_shared<ProcessConfiguration>(processName, releaseVersion, getPassID());
139146
auto common = std::make_shared<CommonParams>(
140147
parameterSet.getUntrackedParameterSet("maxEvents").getUntrackedParameter<int>("input"),
141148
parameterSet.getUntrackedParameterSet("maxLuminosityBlocks").getUntrackedParameter<int>("input"),

FWCore/Framework/test/stubs/RunLumiEventAnalyzer.cc

+53-17
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,87 @@
1-
2-
#include "FWCore/Framework/test/stubs/RunLumiEventAnalyzer.h"
3-
41
#include "DataFormats/Common/interface/Handle.h"
52
#include "DataFormats/Common/interface/TriggerResults.h"
63
#include "FWCore/Framework/interface/Event.h"
74
#include "FWCore/Framework/interface/LuminosityBlock.h"
85
#include "FWCore/Framework/interface/MakerMacros.h"
96
#include "FWCore/Framework/interface/Run.h"
7+
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
108
#include "FWCore/MessageLogger/interface/MessageLogger.h"
119
#include "FWCore/ParameterSet/interface/ParameterSet.h"
10+
#include "FWCore/Utilities/interface/EDGetToken.h"
1211
#include "FWCore/Utilities/interface/Exception.h"
12+
#include "FWCore/Utilities/interface/propagate_const.h"
1313

1414
#include <cassert>
15-
#include <iostream>
15+
#include <vector>
1616

1717
namespace edmtest {
18+
class RunLumiEventAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one::WatchLuminosityBlocks> {
19+
public:
20+
explicit RunLumiEventAnalyzer(edm::ParameterSet const& pset);
21+
22+
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
23+
24+
void analyze(edm::Event const& event, edm::EventSetup const& es) final;
25+
void beginRun(edm::Run const& run, edm::EventSetup const& es) final;
26+
void endRun(edm::Run const& run, edm::EventSetup const& es) final;
27+
void beginLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& es) final;
28+
void endLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& es) final;
29+
void endJob();
30+
31+
private:
32+
std::vector<unsigned long long> expectedRunLumisEvents0_;
33+
std::vector<unsigned long long> expectedRunLumisEvents1_;
34+
edm::propagate_const<std::vector<unsigned long long>*> const expectedRunLumisEvents_;
35+
bool const verbose_;
36+
bool const dumpTriggerResults_;
37+
int const expectedEndingIndex0_;
38+
int const expectedEndingIndex1_;
39+
int const expectedEndingIndex_;
40+
edm::EDGetTokenT<edm::TriggerResults> triggerResultsToken_;
41+
int index_ = 0;
42+
};
1843

1944
RunLumiEventAnalyzer::RunLumiEventAnalyzer(edm::ParameterSet const& pset)
2045
: expectedRunLumisEvents0_(),
2146
expectedRunLumisEvents1_(),
2247
expectedRunLumisEvents_(&expectedRunLumisEvents0_),
23-
index_(0),
24-
verbose_(pset.getUntrackedParameter<bool>("verbose", false)),
25-
dumpTriggerResults_(pset.getUntrackedParameter<bool>("dumpTriggerResults", false)),
26-
expectedEndingIndex0_(pset.getUntrackedParameter<int>("expectedEndingIndex", -1)),
27-
expectedEndingIndex1_(pset.getUntrackedParameter<int>("expectedEndingIndex1", -1)),
48+
verbose_(pset.getUntrackedParameter<bool>("verbose")),
49+
dumpTriggerResults_(pset.getUntrackedParameter<bool>("dumpTriggerResults")),
50+
expectedEndingIndex0_(pset.getUntrackedParameter<int>("expectedEndingIndex")),
51+
expectedEndingIndex1_(pset.getUntrackedParameter<int>("expectedEndingIndex1")),
2852
expectedEndingIndex_(expectedEndingIndex0_) {
29-
if (pset.existsAs<std::vector<unsigned int> >("expectedRunLumiEvents", false)) {
30-
std::vector<unsigned int> temp = pset.getUntrackedParameter<std::vector<unsigned int> >("expectedRunLumiEvents");
53+
if (pset.existsAs<std::vector<unsigned int>>("expectedRunLumiEvents", false)) {
54+
std::vector<unsigned int> temp = pset.getUntrackedParameter<std::vector<unsigned int>>("expectedRunLumiEvents");
3155
expectedRunLumisEvents0_.assign(temp.begin(), temp.end());
3256
} else {
33-
expectedRunLumisEvents0_ = pset.getUntrackedParameter<std::vector<unsigned long long> >(
34-
"expectedRunLumiEvents", std::vector<unsigned long long>());
57+
expectedRunLumisEvents0_ = pset.getUntrackedParameter<std::vector<unsigned long long>>("expectedRunLumiEvents");
3558
}
3659

37-
if (pset.existsAs<std::vector<unsigned int> >("expectedRunLumiEvents1", false)) {
38-
std::vector<unsigned int> temp = pset.getUntrackedParameter<std::vector<unsigned int> >("expectedRunLumiEvents1");
60+
if (pset.existsAs<std::vector<unsigned int>>("expectedRunLumiEvents1", false)) {
61+
std::vector<unsigned int> temp = pset.getUntrackedParameter<std::vector<unsigned int>>("expectedRunLumiEvents1");
3962
expectedRunLumisEvents1_.assign(temp.begin(), temp.end());
4063
} else {
41-
expectedRunLumisEvents1_ = pset.getUntrackedParameter<std::vector<unsigned long long> >(
42-
"expectedRunLumiEvents1", std::vector<unsigned long long>());
64+
expectedRunLumisEvents1_ = pset.getUntrackedParameter<std::vector<unsigned long long>>("expectedRunLumiEvents1");
4365
}
4466
if (dumpTriggerResults_) {
4567
triggerResultsToken_ = consumes(edm::InputTag("TriggerResults"));
4668
}
4769
}
4870

71+
void RunLumiEventAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
72+
edm::ParameterSetDescription desc;
73+
desc.addUntracked<bool>("verbose", false);
74+
desc.addUntracked<bool>("dumpTriggerResults", false);
75+
desc.addUntracked<int>("expectedEndingIndex", -1);
76+
desc.addUntracked<int>("expectedEndingIndex1", -1);
77+
desc.addNode(edm::ParameterDescription<std::vector<unsigned long long>>("expectedRunLumiEvents", {}, false) xor
78+
edm::ParameterDescription<std::vector<unsigned int>>("expectedRunLumiEvents", {}, false));
79+
desc.addNode(edm::ParameterDescription<std::vector<unsigned long long>>("expectedRunLumiEvents1", {}, false) xor
80+
edm::ParameterDescription<std::vector<unsigned int>>("expectedRunLumiEvents1", {}, false));
81+
82+
descriptions.addDefault(desc);
83+
}
84+
4985
void RunLumiEventAnalyzer::analyze(edm::Event const& event, edm::EventSetup const&) {
5086
if (verbose_) {
5187
edm::LogAbsolute("RunLumiEvent") << "RUN_LUMI_EVENT " << event.run() << ", " << event.luminosityBlock() << ", "

FWCore/Framework/test/stubs/RunLumiEventAnalyzer.h

-44
This file was deleted.

FWCore/Framework/test/stubs/TestMergeResults.cc

+100-57
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ namespace edmtest {
4545
public:
4646
explicit TestMergeResults(edm::ParameterSet const&);
4747

48+
static void fillDescriptions(edm::ConfigurationDescriptions&);
49+
4850
void analyze(edm::Event const& e, edm::EventSetup const& c) override;
4951
void beginRun(edm::Run const&, edm::EventSetup const&) override;
5052
void endRun(edm::Run const&, edm::EventSetup const&) override;
@@ -74,84 +76,70 @@ namespace edmtest {
7476
int actualValue,
7577
bool unexpectedImproperlyMergedValue = false) const;
7678

77-
std::vector<int> default_;
78-
std::vector<std::string> defaultvstring_;
79-
80-
std::vector<int> expectedBeginRunProd_;
81-
std::vector<int> expectedEndRunProd_;
82-
std::vector<int> expectedBeginLumiProd_;
83-
std::vector<int> expectedEndLumiProd_;
79+
std::vector<int> const expectedBeginRunProd_;
80+
std::vector<int> const expectedEndRunProd_;
81+
std::vector<int> const expectedBeginLumiProd_;
82+
std::vector<int> const expectedEndLumiProd_;
8483

85-
std::vector<int> expectedBeginRunNew_;
86-
std::vector<int> expectedEndRunNew_;
87-
std::vector<int> expectedBeginLumiNew_;
88-
std::vector<int> expectedEndLumiNew_;
84+
std::vector<int> const expectedBeginRunNew_;
85+
std::vector<int> const expectedEndRunNew_;
86+
std::vector<int> const expectedBeginLumiNew_;
87+
std::vector<int> const expectedEndLumiNew_;
8988

90-
std::vector<int> expectedEndRunProdImproperlyMerged_;
91-
std::vector<int> expectedEndLumiProdImproperlyMerged_;
89+
std::vector<int> const expectedEndRunProdImproperlyMerged_;
90+
std::vector<int> const expectedEndLumiProdImproperlyMerged_;
9291

93-
std::vector<std::string> expectedParents_;
92+
std::vector<std::string> const expectedParents_;
9493

95-
std::vector<std::string> expectedProcessHistoryInRuns_;
94+
std::vector<std::string> const expectedProcessHistoryInRuns_;
9695

97-
std::vector<int> expectedDroppedEvent_;
98-
std::vector<int> expectedDroppedEvent1_;
99-
std::vector<int> expectedDroppedEvent1NEvents_;
96+
std::vector<int> const expectedDroppedEvent_;
97+
std::vector<int> const expectedDroppedEvent1_;
98+
std::vector<int> const expectedDroppedEvent1NEvents_;
10099

101-
bool verbose_;
100+
bool const verbose_;
101+
bool const testAlias_;
102102

103-
unsigned int indexRun_;
104-
unsigned int indexLumi_;
105-
unsigned int parentIndex_;
106-
unsigned int droppedIndex1_;
107-
int droppedIndex1EventCount_;
108-
unsigned int processHistoryIndex_;
103+
unsigned int indexRun_ = 0;
104+
unsigned int indexLumi_ = 0;
105+
unsigned int parentIndex_ = 0;
106+
unsigned int droppedIndex1_ = 0;
107+
int droppedIndex1EventCount_ = 0;
108+
unsigned int processHistoryIndex_ = 0;
109109

110110
edm::Handle<edmtest::Thing> h_thing;
111111
edm::Handle<edmtest::ThingWithMerge> h_thingWithMerge;
112112
edm::Handle<edmtest::ThingWithIsEqual> h_thingWithIsEqual;
113-
114-
bool testAlias_;
115113
};
116114

117115
// -----------------------------------------------------------------
118116

119117
TestMergeResults::TestMergeResults(edm::ParameterSet const& ps)
120-
: default_(),
121-
defaultvstring_(),
122-
expectedBeginRunProd_(ps.getUntrackedParameter<std::vector<int> >("expectedBeginRunProd", default_)),
123-
expectedEndRunProd_(ps.getUntrackedParameter<std::vector<int> >("expectedEndRunProd", default_)),
124-
expectedBeginLumiProd_(ps.getUntrackedParameter<std::vector<int> >("expectedBeginLumiProd", default_)),
125-
expectedEndLumiProd_(ps.getUntrackedParameter<std::vector<int> >("expectedEndLumiProd", default_)),
126-
127-
expectedBeginRunNew_(ps.getUntrackedParameter<std::vector<int> >("expectedBeginRunNew", default_)),
128-
expectedEndRunNew_(ps.getUntrackedParameter<std::vector<int> >("expectedEndRunNew", default_)),
129-
expectedBeginLumiNew_(ps.getUntrackedParameter<std::vector<int> >("expectedBeginLumiNew", default_)),
130-
expectedEndLumiNew_(ps.getUntrackedParameter<std::vector<int> >("expectedEndLumiNew", default_)),
118+
: expectedBeginRunProd_(ps.getUntrackedParameter<std::vector<int>>("expectedBeginRunProd")),
119+
expectedEndRunProd_(ps.getUntrackedParameter<std::vector<int>>("expectedEndRunProd")),
120+
expectedBeginLumiProd_(ps.getUntrackedParameter<std::vector<int>>("expectedBeginLumiProd")),
121+
expectedEndLumiProd_(ps.getUntrackedParameter<std::vector<int>>("expectedEndLumiProd")),
122+
123+
expectedBeginRunNew_(ps.getUntrackedParameter<std::vector<int>>("expectedBeginRunNew")),
124+
expectedEndRunNew_(ps.getUntrackedParameter<std::vector<int>>("expectedEndRunNew")),
125+
expectedBeginLumiNew_(ps.getUntrackedParameter<std::vector<int>>("expectedBeginLumiNew")),
126+
expectedEndLumiNew_(ps.getUntrackedParameter<std::vector<int>>("expectedEndLumiNew")),
131127

132128
expectedEndRunProdImproperlyMerged_(
133-
ps.getUntrackedParameter<std::vector<int> >("expectedEndRunProdImproperlyMerged", default_)),
129+
ps.getUntrackedParameter<std::vector<int>>("expectedEndRunProdImproperlyMerged")),
134130
expectedEndLumiProdImproperlyMerged_(
135-
ps.getUntrackedParameter<std::vector<int> >("expectedEndLumiProdImproperlyMerged", default_)),
131+
ps.getUntrackedParameter<std::vector<int>>("expectedEndLumiProdImproperlyMerged")),
136132

137-
expectedParents_(ps.getUntrackedParameter<std::vector<std::string> >("expectedParents", defaultvstring_)),
133+
expectedParents_(ps.getUntrackedParameter<std::vector<std::string>>("expectedParents")),
138134
expectedProcessHistoryInRuns_(
139-
ps.getUntrackedParameter<std::vector<std::string> >("expectedProcessHistoryInRuns", defaultvstring_)),
140-
141-
expectedDroppedEvent_(ps.getUntrackedParameter<std::vector<int> >("expectedDroppedEvent", default_)),
142-
expectedDroppedEvent1_(ps.getUntrackedParameter<std::vector<int> >("expectedDroppedEvent1", default_)),
143-
expectedDroppedEvent1NEvents_(
144-
ps.getUntrackedParameter<std::vector<int> >("expectedDroppedEvent1NEvents", default_)),
145-
146-
verbose_(ps.getUntrackedParameter<bool>("verbose", false)),
147-
148-
indexRun_(0),
149-
indexLumi_(0),
150-
parentIndex_(0),
151-
droppedIndex1_(0),
152-
droppedIndex1EventCount_(0),
153-
processHistoryIndex_(0),
154-
testAlias_(ps.getUntrackedParameter<bool>("testAlias", false)) {
135+
ps.getUntrackedParameter<std::vector<std::string>>("expectedProcessHistoryInRuns")),
136+
137+
expectedDroppedEvent_(ps.getUntrackedParameter<std::vector<int>>("expectedDroppedEvent")),
138+
expectedDroppedEvent1_(ps.getUntrackedParameter<std::vector<int>>("expectedDroppedEvent1")),
139+
expectedDroppedEvent1NEvents_(ps.getUntrackedParameter<std::vector<int>>("expectedDroppedEvent1NEvents")),
140+
141+
verbose_(ps.getUntrackedParameter<bool>("verbose")),
142+
testAlias_(ps.getUntrackedParameter<bool>("testAlias")) {
155143
auto ap_thing = std::make_unique<edmtest::Thing>();
156144
edm::Wrapper<edmtest::Thing> w_thing(std::move(ap_thing));
157145
assert(!w_thing.isMergeable());
@@ -277,6 +265,61 @@ namespace edmtest {
277265

278266
// -----------------------------------------------------------------
279267

268+
void TestMergeResults::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
269+
edm::ParameterSetDescription desc;
270+
desc.addUntracked<std::vector<int>>("expectedBeginRunProd", {})
271+
->setComment(
272+
"Check the expected values of Thing, ThingWithMerge, ThingWithIsEqual from process PROD at beginRun.");
273+
desc.addUntracked<std::vector<int>>("expectedEndRunProd", {})
274+
->setComment(
275+
"Check the expected values of Thing, ThingWithMerge, ThingWithIsEqual from process PROD at nendRun.");
276+
desc.addUntracked<std::vector<int>>("expectedBeginLumiProd", {})
277+
->setComment(
278+
"Check the expected values of Thing, ThingWithMerge, ThingWithIsEqual from process PROD at "
279+
"beginLuminosityBlock.");
280+
desc.addUntracked<std::vector<int>>("expectedEndLumiProd", {})
281+
->setComment(
282+
"Check the expected values of Thing, ThingWithMerge, ThingWithIsEqual from process PROD at "
283+
"endLuminosityBlock.");
284+
285+
desc.addUntracked<std::vector<int>>("expectedBeginRunNew", {})
286+
->setComment(
287+
"Check the expected values of Thing, ThingWithMerge, ThingWithIsEqual from the latest process at "
288+
"beginRun.");
289+
desc.addUntracked<std::vector<int>>("expectedEndRunNew", {})
290+
->setComment(
291+
"Check the expected values of Thing, ThingWithMerge, ThingWithIsEqual from the latest process at endRun.");
292+
desc.addUntracked<std::vector<int>>("expectedBeginLumiNew", {})
293+
->setComment(
294+
"Check the expected values of Thing, ThingWithMerge, ThingWithIsEqual from the latest process at "
295+
"beginLuminosityBlock.");
296+
desc.addUntracked<std::vector<int>>("expectedEndLumiNew", {})
297+
->setComment(
298+
"Check the expected values of Thing, ThingWithMerge, ThingWithIsEqual from the latest process at "
299+
"endLuminosityBlock.");
300+
301+
desc.addUntracked<std::vector<int>>("expectedEndRunProdImproperlyMerged", {});
302+
desc.addUntracked<std::vector<int>>("expectedEndLumiProdImproperlyMerged", {});
303+
desc.addUntracked<std::vector<std::string>>("expectedParents", {});
304+
desc.addUntracked<std::vector<std::string>>("expectedProcessHistoryInRuns", {});
305+
desc.addUntracked<std::vector<int>>("expectedDroppedEvent", {});
306+
desc.addUntracked<std::vector<int>>("expectedDroppedEvent1", {});
307+
desc.addUntracked<std::vector<int>>("expectedDroppedEvent1NEvents", {});
308+
309+
desc.addUntracked<bool>("testAlias", false);
310+
desc.addUntracked<bool>("verbose", false);
311+
312+
desc.setComment(
313+
"The expected{Begin,End}(Run,Lumi}{Prod,New} parameters follow the same pattern. The expected values come in "
314+
"sets of three: value expected in Thing, ThingWithMerge, and ThingWithIsEqual. Each set of 3 is tested at the "
315+
"specific transition, and then the next set of 3 is tested at the next transition, and so on. When the "
316+
"sequence of parameter values is exhausted, the checking is stopped. The values if 0 are just placedholders, "
317+
"i.e. if the value is a 0, the check is not made.");
318+
319+
descriptions.addDefault(desc);
320+
}
321+
322+
// -----------------------------------------------------------------
280323
void TestMergeResults::analyze(edm::Event const& e, edm::EventSetup const&) {
281324
assert(e.processHistory().id() == e.processHistoryID());
282325

0 commit comments

Comments
 (0)