Skip to content
Snippets Groups Projects
Commit eccdf12a authored by Michael Davis's avatar Michael Davis
Browse files

[os-generic-queues] Adds test for ContainerTraits<RetrieveQueue>::getElementSummary()

parent 246b65cf
No related branches found
No related tags found
No related merge requests found
......@@ -184,6 +184,13 @@ TEST(ObjectStore, RetrieveQueueAlgorithms) {
popCriteria.files = 100;
auto poppedJobs = retrieveAlgos.popNextBatch("VID", popCriteria, lc);
ASSERT_EQ(poppedJobs.summary.files, 10);
// Validate that the summary has the same information as the popped elements
ContainerTraits<RetrieveQueue>::PoppedElementsSummary s;
for(auto &e: poppedJobs.elements) {
s += ContainerTraits<RetrieveQueue>::getElementSummary(e);
}
ASSERT_EQ(s, poppedJobs.summary);
} catch (ContainerTraits<RetrieveQueue>::OwnershipSwitchFailure & ex) {
for (auto & e: ex.failedElements) {
try {
......
......@@ -30,7 +30,7 @@ const std::string ContainerTraits<RetrieveQueue>::c_identifierType = "vid";
// ContainerTraitsTypes
void ContainerTraitsTypes<RetrieveQueue>::PoppedElementsSummary::
addDeltaToLog(const PoppedElementsSummary &previous, log::ScopedParamContainer &params) {
addDeltaToLog(const PoppedElementsSummary &previous, log::ScopedParamContainer &params) const {
params.add("filesAdded", files - previous.files)
.add("bytesAdded", bytes - previous.bytes)
.add("filesBefore", previous.files)
......@@ -40,7 +40,7 @@ addDeltaToLog(const PoppedElementsSummary &previous, log::ScopedParamContainer &
}
void ContainerTraitsTypes<RetrieveQueue>::ContainerSummary::
addDeltaToLog(const ContainerSummary &previous, log::ScopedParamContainer &params) {
addDeltaToLog(const ContainerSummary &previous, log::ScopedParamContainer &params) const {
params.add("queueFilesBefore", previous.files)
.add("queueBytesBefore", previous.bytes)
.add("queueFilesAfter", files)
......@@ -66,7 +66,7 @@ void ContainerTraitsTypes<RetrieveQueue>::PoppedElementsList::insertBack(PoppedE
}
void ContainerTraitsTypes<RetrieveQueue>::PoppedElementsBatch::
addToLog(log::ScopedParamContainer &params) {
addToLog(log::ScopedParamContainer &params) const {
params.add("bytes", summary.bytes)
.add("files", summary.files);
}
......
......@@ -29,7 +29,7 @@ struct ContainerTraitsTypes<RetrieveQueue>
struct ContainerSummary : public RetrieveQueue::JobsSummary {
ContainerSummary() : RetrieveQueue::JobsSummary() {}
ContainerSummary(const RetrieveQueue::JobsSummary &c) : RetrieveQueue::JobsSummary() {}
void addDeltaToLog(const ContainerSummary&, log::ScopedParamContainer&);
void addDeltaToLog(const ContainerSummary&, log::ScopedParamContainer&) const;
};
struct InsertedElement {
......@@ -61,7 +61,10 @@ struct ContainerTraitsTypes<RetrieveQueue>
struct PoppedElementsSummary {
uint64_t bytes = 0;
uint64_t files = 0;
bool operator<(const PopCriteria &pc) {
bool operator==(const PoppedElementsSummary &pes) const {
return bytes == pes.bytes && files == pes.files;
}
bool operator<(const PopCriteria &pc) const {
return bytes < pc.bytes && files < pc.files;
}
PoppedElementsSummary& operator+=(const PoppedElementsSummary &other) {
......@@ -69,7 +72,7 @@ struct ContainerTraitsTypes<RetrieveQueue>
files += other.files;
return *this;
}
void addDeltaToLog(const PoppedElementsSummary&, log::ScopedParamContainer&);
void addDeltaToLog(const PoppedElementsSummary&, log::ScopedParamContainer&) const;
};
struct PoppedElementsList : public std::list<PoppedElement> {
void insertBack(PoppedElementsList&&);
......@@ -78,7 +81,7 @@ struct ContainerTraitsTypes<RetrieveQueue>
struct PoppedElementsBatch {
PoppedElementsList elements;
PoppedElementsSummary summary;
void addToLog(log::ScopedParamContainer&);
void addToLog(log::ScopedParamContainer&) const;
};
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment