Commit 45f9d374 authored by Eric Cano's avatar Eric Cano
Browse files

Fixed the first data transfer session unit test which now passes (enabled).

parent 570e6e2b
......@@ -1263,37 +1263,22 @@ auto OStoreDB::RetrieveMount::getNextJob() -> std::unique_ptr<SchedulerDatabase:
}
void OStoreDB::RetrieveMount::complete(time_t completionTime) {
throw cta::exception::Exception(std::string("Not implemented: ") + __PRETTY_FUNCTION__);
// // When the session is complete, we can reset the status of the tape and the
// // drive
// // Reset the drive
// objectstore::RootEntry re(m_objectStore);
// objectstore::ScopedSharedLock rel(re);
// re.fetch();
// objectstore::DriveRegister dr(re.getDriveRegisterAddress(), m_objectStore);
// objectstore::ScopedExclusiveLock drl(dr);
// dr.fetch();
// // Reset the drive state.
// dr.reportDriveStatus(mountInfo.drive, mountInfo.logicalLibrary,
// cta::common::DriveStatus::Up, completionTime,
// cta::MountType::NONE, 0,
// 0, 0, 0, "", "");
// dr.commit();
// // Find the tape and unbusy it.
// objectstore::TapePool tp (re.getTapePoolAddress(mountInfo.tapePool), m_objectStore);
// rel.release();
// objectstore::ScopedSharedLock tpl(tp);
// tp.fetch();
// objectstore::Tape t(tp.getTapeAddress(mountInfo.vid), m_objectStore);
// objectstore::ScopedExclusiveLock tl(t);
// tpl.release();
// t.fetch();
// t.releaseBusy();
// t.commit();
// objectstore::ScopedExclusiveLock agl(m_agent);
// m_agent.fetch();
// m_agent.removeFromOwnership(t.getAddressIfSet());
// m_agent.commit();
// When the session is complete, we can reset the status of the tape and the
// drive
// Reset the drive
objectstore::RootEntry re(m_objectStore);
objectstore::ScopedSharedLock rel(re);
re.fetch();
objectstore::DriveRegister dr(re.getDriveRegisterAddress(), m_objectStore);
objectstore::ScopedExclusiveLock drl(dr);
dr.fetch();
// Reset the drive state.
dr.reportDriveStatus(mountInfo.drive, mountInfo.logicalLibrary,
cta::common::DriveStatus::Up, completionTime,
cta::MountType::NONE, 0,
0, 0, 0, "", "");
dr.commit();
rel.release();
}
void OStoreDB::RetrieveMount::setDriveStatus(cta::common::DriveStatus status, time_t completionTime) {
......
......@@ -304,7 +304,7 @@ protected:
}; // class DataTransferSessionTest
TEST_P(DataTransferSessionTest, DISABLED_DataTransferSessionGooddayRecall) {
TEST_P(DataTransferSessionTest, DataTransferSessionGooddayRecall) {
// 0) Prepare the logger for everyone
castor::log::StringLogger logger("tapeServerUnitTest");
......@@ -419,6 +419,7 @@ TEST_P(DataTransferSessionTest, DISABLED_DataTransferSessionGooddayRecall) {
rReq.archiveFileID=fseq;
rReq.requester.name = s_userName;
rReq.requester.group = "someGroup";
rReq.dstURL = remoteFilePaths.back();
std::list<std::string> archiveFilePaths;
archiveFilePaths.push_back(archiveFilePath.str());
scheduler.queueRetrieve(sid, rReq);
......@@ -441,8 +442,6 @@ TEST_P(DataTransferSessionTest, DISABLED_DataTransferSessionGooddayRecall) {
castor::messages::TapeserverProxyDummy initialProcess;
castor::tape::tapeserver::daemon::DataTransferSession sess("tapeHost", logger, mockSys,
driveConfig, mc, initialProcess, capUtils, castorConf, scheduler);
std::cout << typeid(sess).name() << std::endl;
// 7) Run the data transfer session
sess.execute();
......@@ -451,11 +450,10 @@ TEST_P(DataTransferSessionTest, DISABLED_DataTransferSessionGooddayRecall) {
ASSERT_EQ(s_vid, sess.getVid());
// 9) Check the remote files exist and have the correct size
for(auto pathItor = remoteFilePaths.cbegin(); pathItor !=
remoteFilePaths.cend(); pathItor++) {
for(auto & path: remoteFilePaths) {
struct stat statBuf;
bzero(&statBuf, sizeof(statBuf));
const int statRc = stat(pathItor->substr(7).c_str(), &statBuf); //remove the "file://" for stat-ing
const int statRc = stat(path.substr(7).c_str(), &statBuf); //remove the "file://" for stat-ing
ASSERT_EQ(0, statRc);
ASSERT_EQ(1000, statBuf.st_size); //same size of data
}
......
......@@ -144,7 +144,7 @@ void RecallReportPacker::ReportEndofSession::execute(RecallReportPacker& parent)
//------------------------------------------------------------------------------
//ReportEndofSession::goingToEnd
//------------------------------------------------------------------------------
bool RecallReportPacker::ReportEndofSession::goingToEnd(RecallReportPacker& packer) {
bool RecallReportPacker::ReportEndofSession::goingToEnd() {
return false;
}
......@@ -162,7 +162,7 @@ void RecallReportPacker::ReportDriveStatus::execute(RecallReportPacker& parent){
//------------------------------------------------------------------------------
//ReportDriveStatus::goingToEnd
//------------------------------------------------------------------------------
bool RecallReportPacker::ReportDriveStatus::goingToEnd(RecallReportPacker& packer) {
bool RecallReportPacker::ReportDriveStatus::goingToEnd() {
if(m_status==cta::common::DriveStatus::Unmounting) return true;
return false;
}
......@@ -191,7 +191,7 @@ void RecallReportPacker::ReportEndofSessionWithErrors::execute(RecallReportPacke
//------------------------------------------------------------------------------
//ReportEndofSessionWithErrors::goingToEnd
//------------------------------------------------------------------------------
bool RecallReportPacker::ReportEndofSessionWithErrors::goingToEnd(RecallReportPacker& packer) {
bool RecallReportPacker::ReportEndofSessionWithErrors::goingToEnd() {
return false;
}
......@@ -220,12 +220,11 @@ void RecallReportPacker::WorkerThread::run(){
try{
while(1) {
std::unique_ptr<Report> rep(m_parent.m_fifo.pop());
// Record whether we found end before calling the potentially exception
// throwing execute().)
if (rep->goingToEnd()) endFound=true;
rep->execute(m_parent);
if(rep->goingToEnd(m_parent)) {
endFound = true;
break;
}
if (endFound) break;
}
} catch(const castor::exception::Exception& e){
//we get there because to tried to close the connection and it failed
......@@ -272,7 +271,7 @@ void RecallReportPacker::WorkerThread::run(){
if (!endFound) {
while (1) {
std::unique_ptr<Report> report(m_parent.m_fifo.pop());
if (report->goingToEnd(m_parent))
if (report->goingToEnd())
break;
}
}
......
......@@ -125,15 +125,15 @@ private:
public:
virtual ~Report(){}
virtual void execute(RecallReportPacker& packer)=0;
virtual bool goingToEnd(RecallReportPacker& packer) {return false;}
virtual bool goingToEnd() {return false;}
};
class ReportTestGoingToEnd : public Report {
public:
ReportTestGoingToEnd() {}
virtual void execute(RecallReportPacker& reportPacker) {
void execute(RecallReportPacker& reportPacker) override {
reportPacker.m_retrieveMount->diskComplete();
reportPacker.m_retrieveMount->tapeComplete();}
virtual bool goingToEnd(RecallReportPacker& packer) {return true;}
bool goingToEnd() override {return true;}
};
class ReportSuccessful : public Report {
/**
......@@ -143,7 +143,7 @@ private:
public:
ReportSuccessful(std::unique_ptr<cta::RetrieveJob> successfulRetrieveJob):
m_successfulRetrieveJob(std::move(successfulRetrieveJob)){}
virtual void execute(RecallReportPacker& reportPacker);
void execute(RecallReportPacker& reportPacker) override;
};
class ReportError : public Report {
/**
......@@ -155,22 +155,22 @@ private:
m_failedRetrieveJob(std::move(failedRetrieveJob)) {
}
virtual void execute(RecallReportPacker& reportPacker);
void execute(RecallReportPacker& reportPacker) override;
};
class ReportDriveStatus : public Report {
cta::common::DriveStatus m_status;
public:
ReportDriveStatus(cta::common::DriveStatus status): m_status(status) {}
virtual void execute(RecallReportPacker& reportPacker);
virtual bool goingToEnd(RecallReportPacker& packer);
void execute(RecallReportPacker& reportPacker) override;
bool goingToEnd() override;
};
class ReportEndofSession : public Report {
public:
ReportEndofSession(){}
virtual void execute(RecallReportPacker& reportPacker);
virtual bool goingToEnd(RecallReportPacker& packer);
void execute(RecallReportPacker& reportPacker) override;
bool goingToEnd() override;
};
class ReportEndofSessionWithErrors : public Report {
......@@ -180,15 +180,15 @@ private:
ReportEndofSessionWithErrors(std::string msg,int error_code):
m_message(msg),m_error_code(error_code){}
virtual void execute(RecallReportPacker& reportPacker);
virtual bool goingToEnd(RecallReportPacker& packer);
void execute(RecallReportPacker& reportPacker) override;
bool goingToEnd() override;
};
class WorkerThread: public castor::server::Thread {
RecallReportPacker & m_parent;
public:
WorkerThread(RecallReportPacker& parent);
virtual void run();
void run() override;
} m_workerThread;
castor::server::Mutex m_producterProtection;
......
Supports Markdown
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