Commit a0bf18c9 authored by Michael Davis's avatar Michael Davis
Browse files

[objectstore] Fixes unit tests

Objectstore GC Repack unit tests rely on a specific string in an exception message.
parent 36d3e007
......@@ -61,6 +61,7 @@ set (COMMON_LIB_SRC_FILES
dataStructures/QueueAndMountSummary.cpp
dataStructures/ReadTestResult.cpp
dataStructures/RepackInfo.cpp
dataStructures/RepackQueueType.cpp
dataStructures/RequesterGroupMountRule.cpp
dataStructures/RequesterIdentity.cpp
dataStructures/RequesterMountRule.cpp
......
......@@ -55,19 +55,19 @@ std::string toString(RepackInfo::Status status) {
}
}
cta::objectstore::RepackQueueType RepackInfo::getQueueType(){
RepackQueueType RepackInfo::getQueueType(){
switch(status){
case RepackInfo::Status::Pending:
return cta::objectstore::RepackQueueType::Pending;
return RepackQueueType::Pending;
case RepackInfo::Status::ToExpand:
return cta::objectstore::RepackQueueType::ToExpand;
return RepackQueueType::ToExpand;
case RepackInfo::Status::Running:
case RepackInfo::Status::Starting:
if(!isExpandFinished) return cta::objectstore::RepackQueueType::ToExpand;
if(!isExpandFinished) return RepackQueueType::ToExpand;
goto explicit_default;
default:
explicit_default:
throw cta::exception::Exception("The status "+toString(status)+" have no corresponding queue.");
throw cta::exception::Exception("The status "+toString(status)+" has no corresponding queue type.");
}
}
......
......@@ -20,7 +20,7 @@
#include <string>
#include <list>
#include "objectstore/RepackQueueType.hpp"
#include "RepackQueueType.hpp"
#include "EntryLog.hpp"
#include "common/optional.hpp"
......@@ -89,7 +89,7 @@ struct RepackInfo {
// std::string repackStatus;
// std::map<uint64_t,std::string> errors;
// EntryLog creationLog;
cta::objectstore::RepackQueueType getQueueType();
RepackQueueType getQueueType();
}; // struct RepackInfo
std::string toString(RepackInfo::Type type);
......
/*
/**
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
* Copyright © 2021 CERN
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -19,7 +19,7 @@
#include "RepackQueueType.hpp"
#include "common/exception/Exception.hpp"
namespace cta { namespace objectstore {
namespace cta { namespace common { namespace dataStructures {
std::string toString(RepackQueueType queueType) {
switch(queueType) {
......@@ -31,4 +31,4 @@ std::string toString(RepackQueueType queueType) {
throw exception::Exception("In toString(RepackQueueType): unexpected queue type.");
}
}} // namespace cta::objectstore
\ No newline at end of file
}}} // namespace cta::common::dataStructures
/*
/**
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
* Copyright © 2021 CERN
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -20,7 +20,7 @@
#include <string>
namespace cta { namespace objectstore {
namespace cta { namespace common { namespace dataStructures {
enum class RepackQueueType { Pending, ToExpand };
std::string toString(RepackQueueType queueType);
}} // namespace cta::objectstore
}}} // namespace cta::common::dataStructures
......@@ -91,7 +91,6 @@ add_library (ctaobjectstore SHARED
RepackQueue.cpp
RepackQueuePendingAlgorithms.cpp
RepackQueueToExpandAlgorithms.cpp
RepackQueueType.cpp
BackendVFS.cpp
BackendRados.cpp
BackendPopulator.cpp
......
......@@ -741,7 +741,7 @@ TEST(ObjectStore, GarbageCollectorRepackRequestPending) {
cta::objectstore::RootEntry re(be);
cta::objectstore::ScopedExclusiveLock rel(re);
re.fetch();
std::string repackQueueAddr = re.addOrGetRepackQueueAndCommit(agentRef,cta::objectstore::RepackQueueType::Pending);
std::string repackQueueAddr = re.addOrGetRepackQueueAndCommit(agentRef,cta::common::dataStructures::RepackQueueType::Pending);
cta::objectstore::RepackQueue rq(repackQueueAddr,be);
cta::objectstore::ScopedExclusiveLock rql(rq);
rq.fetch();
......@@ -822,7 +822,7 @@ TEST(ObjectStore, GarbageCollectorRepackRequestToExpand) {
cta::objectstore::RootEntry re(be);
cta::objectstore::ScopedExclusiveLock rel(re);
re.fetch();
std::string repackQueueAddr = re.addOrGetRepackQueueAndCommit(agentRef,cta::objectstore::RepackQueueType::ToExpand);
std::string repackQueueAddr = re.addOrGetRepackQueueAndCommit(agentRef,cta::common::dataStructures::RepackQueueType::ToExpand);
cta::objectstore::RepackQueue rq(repackQueueAddr,be);
cta::objectstore::ScopedExclusiveLock rql(rq);
rq.fetch();
......@@ -905,7 +905,7 @@ TEST(ObjectStore, GarbageCollectorRepackRequestRunningExpandNotFinished) {
cta::objectstore::RootEntry re(be);
cta::objectstore::ScopedExclusiveLock rel(re);
re.fetch();
std::string repackQueueAddr = re.addOrGetRepackQueueAndCommit(agentRef,cta::objectstore::RepackQueueType::ToExpand);
std::string repackQueueAddr = re.addOrGetRepackQueueAndCommit(agentRef,cta::common::dataStructures::RepackQueueType::ToExpand);
cta::objectstore::RepackQueue rq(repackQueueAddr,be);
cta::objectstore::ScopedExclusiveLock rql(rq);
rq.fetch();
......@@ -993,7 +993,7 @@ TEST(ObjectStore, GarbageCollectorRepackRequestRunningExpandFinished) {
cta::objectstore::RootEntry re(be);
cta::objectstore::ScopedExclusiveLock rel(re);
re.fetch();
std::string repackQueueAddr = re.addOrGetRepackQueueAndCommit(agentRef,cta::objectstore::RepackQueueType::ToExpand);
std::string repackQueueAddr = re.addOrGetRepackQueueAndCommit(agentRef,cta::common::dataStructures::RepackQueueType::ToExpand);
cta::objectstore::RepackQueue rq(repackQueueAddr,be);
cta::objectstore::ScopedExclusiveLock rql(rq);
rq.fetch();
......@@ -1004,7 +1004,7 @@ TEST(ObjectStore, GarbageCollectorRepackRequestRunningExpandFinished) {
cta::objectstore::RootEntry re(be);
cta::objectstore::ScopedExclusiveLock rel(re);
re.fetch();
std::string repackQueueAddr = re.addOrGetRepackQueueAndCommit(agentRef,cta::objectstore::RepackQueueType::Pending);
std::string repackQueueAddr = re.addOrGetRepackQueueAndCommit(agentRef,cta::common::dataStructures::RepackQueueType::Pending);
cta::objectstore::RepackQueue rq(repackQueueAddr,be);
cta::objectstore::ScopedExclusiveLock rql(rq);
rq.fetch();
......@@ -1019,7 +1019,7 @@ TEST(ObjectStore, GarbageCollectorRepackRequestRunningExpandFinished) {
//Check the logs contains the failed to requeue message
std::string logToCheck = strLogger.getLog();
logToCheck += "";
ASSERT_NE(std::string::npos,logToCheck.find("MSG=\"In RepackRequest::garbageCollect(): failed to requeue the RepackRequest (leaving it as it is) : The status Running have no corresponding queue.\""));
ASSERT_NE(std::string::npos,logToCheck.find("MSG=\"In RepackRequest::garbageCollect(): failed to requeue the RepackRequest (leaving it as it is) : The status Running has no corresponding queue type.\""));
}
TEST(ObjectStore, GarbageCollectorRepackRequestStarting) {
......@@ -1097,7 +1097,7 @@ TEST(ObjectStore, GarbageCollectorRepackRequestStarting) {
//Check the logs contains the failed to requeue message
std::string logToCheck = strLogger.getLog();
logToCheck += "";
ASSERT_NE(std::string::npos,logToCheck.find("MSG=\"In RepackRequest::garbageCollect(): failed to requeue the RepackRequest (leaving it as it is) : The status Starting have no corresponding queue.\""));
ASSERT_NE(std::string::npos,logToCheck.find("MSG=\"In RepackRequest::garbageCollect(): failed to requeue the RepackRequest (leaving it as it is) : The status Starting has no corresponding queue type.\""));
}
TEST(ObjectStore, GarbageCollectorRetrieveAllStatusesAndQueues) {
......
......@@ -273,7 +273,7 @@ void Helpers::getLockedAndFetchedJobQueue<RetrieveQueue>(RetrieveQueue& retrieve
// Helpers::getLockedAndFetchedRepackQueue()
//------------------------------------------------------------------------------
void Helpers::getLockedAndFetchedRepackQueue(RepackQueue& queue, ScopedExclusiveLock& queueLock, AgentReference& agentReference,
RepackQueueType queueType, log::LogContext& lc) {
common::dataStructures::RepackQueueType queueType, log::LogContext& lc) {
// Try and find the repack queue.
Backend & be = queue.m_objectStore;
for (auto i: cta::range<size_t>(5)) {
......
......@@ -24,7 +24,7 @@
#include "catalogue/Catalogue.hpp"
#include "scheduler/OStoreDB/OStoreDB.hpp"
#include "JobQueueType.hpp"
#include "RepackQueueType.hpp"
#include "common/dataStructures/RepackQueueType.hpp"
#include <string>
#include <set>
#include <future>
......@@ -73,7 +73,7 @@ public:
*/
static void getLockedAndFetchedRepackQueue(RepackQueue & queue,
ScopedExclusiveLock & queueLock, AgentReference & agentReference,
RepackQueueType queueType, log::LogContext & lc);
common::dataStructures::RepackQueueType queueType, log::LogContext & lc);
CTA_GENERATE_EXCEPTION_CLASS(NoTapeAvailableForRetrieve);
/**
......
......@@ -429,11 +429,11 @@ getElementSummary(const PoppedElement& poppedElement) -> PoppedElementsSummary {
template<>
struct ContainerTraits<RepackQueue,RepackQueuePending>::QueueType{
objectstore::RepackQueueType value = objectstore::RepackQueueType::Pending;
common::dataStructures::RepackQueueType value = common::dataStructures::RepackQueueType::Pending;
};
template<>
struct ContainerTraits<RepackQueue,RepackQueueToExpand>::QueueType{
objectstore::RepackQueueType value = objectstore::RepackQueueType::ToExpand;
common::dataStructures::RepackQueueType value = common::dataStructures::RepackQueueType::ToExpand;
};
}} // namespace cta::objectstore
......@@ -809,14 +809,14 @@ void RootEntry::removeRepackIndexAndCommit(log::LogContext& lc) {
// ================ Repack index manipulation ==================================
// =============================================================================
std::string RootEntry::getRepackQueueAddress(RepackQueueType queueType) {
std::string RootEntry::getRepackQueueAddress(common::dataStructures::RepackQueueType queueType) {
checkPayloadReadable();
switch (queueType) {
case RepackQueueType::Pending:
case common::dataStructures::RepackQueueType::Pending:
if (!m_payload.has_repackrequestspendingqueuepointer())
throw NoSuchRepackQueue("In RootEntry::getRepackQueueAddress: pending queue no set.");
return m_payload.repackrequestspendingqueuepointer().address();
case RepackQueueType::ToExpand:
case common::dataStructures::RepackQueueType::ToExpand:
if (!m_payload.has_repackrequeststoexpandqueuepointer())
throw NoSuchRepackQueue("In RootEntry::getRepackQueueAddress: toExpand queue not set.");
return m_payload.repackrequeststoexpandqueuepointer().address();
......@@ -824,14 +824,14 @@ std::string RootEntry::getRepackQueueAddress(RepackQueueType queueType) {
throw cta::exception::Exception("In RootEntry::getRepackQueueAddress(): unexptected queue type.");
}
void RootEntry::clearRepackQueueAddress(RepackQueueType queueType) {
void RootEntry::clearRepackQueueAddress(common::dataStructures::RepackQueueType queueType) {
checkPayloadWritable();
switch (queueType) {
case RepackQueueType::Pending:
case common::dataStructures::RepackQueueType::Pending:
if (!m_payload.has_repackrequestspendingqueuepointer())
throw NoSuchRepackQueue("In RootEntry::clearRepackQueueAddress: pending queue no set.");
return m_payload.mutable_repackrequestspendingqueuepointer()->Clear();
case RepackQueueType::ToExpand:
case common::dataStructures::RepackQueueType::ToExpand:
if (!m_payload.has_repackrequeststoexpandqueuepointer())
throw NoSuchRepackQueue("In RootEntry::clearRepackQueueAddress: toExpand queue not set.");
return m_payload.mutable_repackrequeststoexpandqueuepointer()->Clear();
......@@ -839,16 +839,16 @@ void RootEntry::clearRepackQueueAddress(RepackQueueType queueType) {
throw cta::exception::Exception("In RootEntry::clearRepackQueueAddress(): unexptected queue type.");
}
void RootEntry::removeRepackQueueAndCommit(RepackQueueType queueType, log::LogContext& lc) {
void RootEntry::removeRepackQueueAndCommit(common::dataStructures::RepackQueueType queueType, log::LogContext& lc) {
checkPayloadWritable();
// find the address of the repack queue object
try {
bool hasQueue;
switch (queueType) {
case RepackQueueType::Pending:
case common::dataStructures::RepackQueueType::Pending:
hasQueue = m_payload.has_repackrequestspendingqueuepointer();
break;
case RepackQueueType::ToExpand:
case common::dataStructures::RepackQueueType::ToExpand:
hasQueue = m_payload.has_repackrequeststoexpandqueuepointer();
}
if (!hasQueue) {
......@@ -856,10 +856,10 @@ void RootEntry::removeRepackQueueAndCommit(RepackQueueType queueType, log::LogCo
}
std::string queueAddress;
switch (queueType) {
case RepackQueueType::Pending:
case common::dataStructures::RepackQueueType::Pending:
queueAddress = m_payload.repackrequestspendingqueuepointer().address();
break;
case RepackQueueType::ToExpand:
case common::dataStructures::RepackQueueType::ToExpand:
queueAddress = m_payload.repackrequeststoexpandqueuepointer().address();
}
// Open the repack queue object
......@@ -896,10 +896,10 @@ void RootEntry::removeRepackQueueAndCommit(RepackQueueType queueType, log::LogCo
deleteFromRootEntry:
// ... and remove it from our entry
switch (queueType) {
case RepackQueueType::Pending:
case common::dataStructures::RepackQueueType::Pending:
m_payload.clear_repackrequestspendingqueuepointer();
break;
case RepackQueueType::ToExpand:
case common::dataStructures::RepackQueueType::ToExpand:
m_payload.clear_repackrequeststoexpandqueuepointer();
}
commit();
......@@ -914,7 +914,7 @@ void RootEntry::removeRepackQueueAndCommit(RepackQueueType queueType, log::LogCo
}
}
std::string RootEntry::addOrGetRepackQueueAndCommit(AgentReference& agentRef, RepackQueueType queueType) {
std::string RootEntry::addOrGetRepackQueueAndCommit(AgentReference& agentRef, common::dataStructures::RepackQueueType queueType) {
checkPayloadWritable();
// Check the repack queue does not already exist
try {
......@@ -924,17 +924,17 @@ std::string RootEntry::addOrGetRepackQueueAndCommit(AgentReference& agentRef, Re
// Insert the archive queue pointer in the root entry, then the queue.
std::string repackQueueNameHeader = "RepackQueue";
switch(queueType) {
case RepackQueueType::Pending: repackQueueNameHeader+="Pending"; break;
case RepackQueueType::ToExpand: repackQueueNameHeader+="ToExpand"; break;
case common::dataStructures::RepackQueueType::Pending: repackQueueNameHeader+="Pending"; break;
case common::dataStructures::RepackQueueType::ToExpand: repackQueueNameHeader+="ToExpand"; break;
default: break;
}
std::string repackQueueAddress = agentRef.nextId(repackQueueNameHeader);
// Now move create a reference in the root entry
switch(queueType) {
case RepackQueueType::Pending:
case common::dataStructures::RepackQueueType::Pending:
m_payload.mutable_repackrequestspendingqueuepointer()->set_address(repackQueueAddress);
break;
case RepackQueueType::ToExpand:
case common::dataStructures::RepackQueueType::ToExpand:
m_payload.mutable_repackrequeststoexpandqueuepointer()->set_address(repackQueueAddress);
break;
}
......
......@@ -21,7 +21,7 @@
#include "objectstore/cta.pb.h"
#include "JobQueueType.hpp"
#include "RepackQueueType.hpp"
#include "common/dataStructures/RepackQueueType.hpp"
#include "Backend.hpp"
#include "ObjectOps.hpp"
#include "EntryLogSerDeser.hpp"
......@@ -140,12 +140,12 @@ public:
// Repack queues manipulations ===============================================
CTA_GENERATE_EXCEPTION_CLASS(RepackQueueNotEmpty);
CTA_GENERATE_EXCEPTION_CLASS(NoSuchRepackQueue);
std::string getRepackQueueAddress(RepackQueueType queueType);
std::string addOrGetRepackQueueAndCommit(AgentReference & agentRef, RepackQueueType queueType);
void removeRepackQueueAndCommit(RepackQueueType queueType, log::LogContext & lc);
std::string getRepackQueueAddress(common::dataStructures::RepackQueueType queueType);
std::string addOrGetRepackQueueAndCommit(AgentReference & agentRef, common::dataStructures::RepackQueueType queueType);
void removeRepackQueueAndCommit(common::dataStructures::RepackQueueType queueType, log::LogContext & lc);
private:
void setRepackQueueAddress(RepackQueueType queueType, const std::string &queueAddress);
void clearRepackQueueAddress(RepackQueueType queueType);
void setRepackQueueAddress(common::dataStructures::RepackQueueType queueType, const std::string &queueAddress);
void clearRepackQueueAddress(common::dataStructures::RepackQueueType queueType);
public:
// Dump the root entry
......
......@@ -1900,7 +1900,7 @@ auto OStoreDB::getRepackStatistics() -> std::unique_ptr<SchedulerDatabase::Repac
typedRet(new OStoreDB::RepackRequestPromotionStatistics(m_objectStore, *m_agentReference));
// Try to get the lock
try {
typedRet->m_pendingRepackRequestQueue.setAddress(re.getRepackQueueAddress(RepackQueueType::Pending));
typedRet->m_pendingRepackRequestQueue.setAddress(re.getRepackQueueAddress(common::dataStructures::RepackQueueType::Pending));
typedRet->m_lockOnPendingRepackRequestsQueue.lock(typedRet->m_pendingRepackRequestQueue);
} catch (...) {
throw SchedulerDatabase::RepackRequestStatistics::NoPendingRequestQueue("In OStoreDB::getRepackStatistics(): could not lock the pending requests queue.");
......
......@@ -3382,7 +3382,7 @@ TEST_P(SchedulerTest, expandRepackRequestAddCopiesOnly) {
cta::objectstore::RootEntry re(backend);
re.fetchNoLock();
std::string repackQueueAddress = re.getRepackQueueAddress(RepackQueueType::Pending);
std::string repackQueueAddress = re.getRepackQueueAddress(common::dataStructures::RepackQueueType::Pending);
cta::objectstore::RepackQueuePending repackQueuePending(repackQueueAddress,backend);
repackQueuePending.fetchNoLock();
......@@ -3640,7 +3640,7 @@ TEST_P(SchedulerTest, expandRepackRequestMoveAndAddCopies){
cta::objectstore::RootEntry re(backend);
re.fetchNoLock();
std::string repackQueueAddress = re.getRepackQueueAddress(RepackQueueType::Pending);
std::string repackQueueAddress = re.getRepackQueueAddress(common::dataStructures::RepackQueueType::Pending);
cta::objectstore::RepackQueuePending repackQueuePending(repackQueueAddress,backend);
repackQueuePending.fetchNoLock();
......@@ -3888,7 +3888,7 @@ TEST_P(SchedulerTest, cancelRepackRequest) {
cta::objectstore::RootEntry re(backend);
re.fetchNoLock();
std::string repackQueueAddress = re.getRepackQueueAddress(RepackQueueType::Pending);
std::string repackQueueAddress = re.getRepackQueueAddress(common::dataStructures::RepackQueueType::Pending);
cta::objectstore::RepackQueuePending repackQueuePending(repackQueueAddress,backend);
repackQueuePending.fetchNoLock();
......@@ -3940,7 +3940,7 @@ TEST_P(SchedulerTest, cancelRepackRequest) {
cta::objectstore::RootEntry re(backend);
re.fetchNoLock();
std::string repackQueueAddress = re.getRepackQueueAddress(RepackQueueType::Pending);
std::string repackQueueAddress = re.getRepackQueueAddress(common::dataStructures::RepackQueueType::Pending);
cta::objectstore::RepackQueuePending repackQueuePending(repackQueueAddress,backend);
repackQueuePending.fetchNoLock();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment