Commit b16165e7 authored by Daniele Kruse's avatar Daniele Kruse
Browse files

Made the DiskWriteTaskTest.cpp changing things here and there

parent dcea62d8
......@@ -47,7 +47,7 @@ struct TapeCopyInfo {
/**
* The path of the archive file.
*/
std::string archiveFilePath;
//std::string archiveFilePath;
/**
* The ID of the file
......
......@@ -35,7 +35,7 @@ namespace cta {
*/
class ArchiveMount: public TapeMount {
friend class Scheduler;
private:
protected:
/**
* Constructor.
......
......@@ -35,7 +35,7 @@ namespace cta {
*/
class RetrieveMount: public TapeMount {
friend class Scheduler;
private:
protected:
/**
* Constructor.
......
......@@ -480,14 +480,12 @@ TEST_P(SchedulerDatabaseTest, getMountInfo) {
std::list<TapeCopyInfo> tcl;
tcl.push_back(TapeCopyInfo());
tcl.back().blockId = 666;
tcl.back().archiveFilePath = "cta:://cta/myfile";
tcl.back().fSeq = 10;
tcl.back().nsHostName = "NSHost";
tcl.back().vid = "Tape2";
tcl.back().copyNumber = 1;
tcl.push_back(TapeCopyInfo());
tcl.back().blockId = 111;
tcl.back().archiveFilePath = "cta:://cta/myfile";
tcl.back().fSeq = 5;
tcl.back().nsHostName = "NSHost";
tcl.back().vid = "Tape3";
......@@ -528,14 +526,12 @@ TEST_P(SchedulerDatabaseTest, getMountInfo) {
std::list<TapeCopyInfo> tcl2;
tcl2.push_back(TapeCopyInfo());
tcl2.back().blockId = 999;
tcl2.back().archiveFilePath = "cta:://cta/myfile2";
tcl2.back().fSeq = 11;
tcl2.back().nsHostName = "NSHost";
tcl2.back().vid = "Tape3";
tcl2.back().copyNumber = 1;
tcl2.push_back(TapeCopyInfo());
tcl2.back().blockId = 333;
tcl2.back().archiveFilePath = "cta:://cta/myfile2";
tcl2.back().fSeq = 3;
tcl2.back().nsHostName = "NSHost";
tcl2.back().vid = "Tape2";
......
......@@ -95,7 +95,7 @@ add_library(castortapeserverdaemonunittests SHARED
CatalogueDriveStateTest.cpp
CatalogueTest.cpp
DiskReadTaskTest.cpp
# DiskWriteTaskTest.cpp
DiskWriteTaskTest.cpp
# DiskWriteThreadPoolTest.cpp
DriveConfigTest.cpp
# MigrationReportPackerTest.cpp
......
......@@ -53,7 +53,7 @@ bool DiskWriteTask::execute(RecallReportPacker& reporter,log::LogContext& lc,
castor::utils::Timer transferTime(localTime);
log::ScopedParamContainer URLcontext(lc);
URLcontext.add("NSFILEID",m_retrieveJob->archiveFile.fileId)
.add("path", m_retrieveJob->tapeCopy.archiveFilePath)
.add("path", m_retrieveJob->archiveFile.lastKnownPath)
.add("fileTransactionId",m_retrieveJob->m_id)
.add("fSeq",m_retrieveJob->tapeCopy.fSeq);
// This out-of-try-catch variables allows us to record the stage of the
......@@ -90,7 +90,7 @@ bool DiskWriteTask::execute(RecallReportPacker& reporter,log::LogContext& lc,
// Synchronise the counter with the open time counter.
currentErrorToCount = "Error_diskOpenForWrite";
transferTime = localTime;
writeFile.reset(fileFactory.createWriteFile(m_retrieveJob->tapeCopy.archiveFilePath));
writeFile.reset(fileFactory.createWriteFile(m_retrieveJob->archiveFile.lastKnownPath));
URLcontext.add("actualURL", writeFile->URL());
lc.log(LOG_INFO, "Opened disk file for writing");
m_stats.openingTime+=localTime.secs(castor::utils::Timer::resetCounter);
......@@ -254,7 +254,7 @@ void DiskWriteTask::logWithStat(int level,const std::string& msg,log::LogContext
.add("openRWCloseToTransferTimeRatio",
m_stats.transferTime?(m_stats.openingTime+m_stats.readWriteTime+m_stats.closingTime)/m_stats.transferTime:0.0)
.add("FILEID",m_retrieveJob->archiveFile.fileId)
.add("path",m_retrieveJob->tapeCopy.archiveFilePath);
.add("path",m_retrieveJob->archiveFile.lastKnownPath);
lc.log(level,msg);
}
}}}}
......
......@@ -32,39 +32,63 @@
#include "scheduler/mockDB/MockSchedulerDatabase.hpp"
#include "serrno.h"
#include "scheduler/Scheduler.hpp"
#include "nameserver/mockNS/MockNameServer.hpp"
#include "remotens/MockRemoteNS.hpp"
#include <memory>
#include <gtest/gtest.h>
namespace unitTests{
class TestingRetrieveMount: public cta::RetrieveMount {
public:
TestingRetrieveMount(std::unique_ptr<cta::SchedulerDatabase::RetrieveMount> dbrm): RetrieveMount(std::move(dbrm)) {
}
};
class TestingRetrieveJob: public cta::RetrieveJob {
public:
TestingRetrieveJob() {
}
};
using namespace castor::tape::tapeserver::daemon;
using namespace castor::tape::tapeserver::client;
using namespace castor::tape::diskFile;
struct MockRecallReportPacker : public RecallReportPacker {
MOCK_METHOD3(reportCompletedJob,void(const FileStruct&,u_int32_t,u_int64_t));
MOCK_METHOD3(reportFailedJob, void(const FileStruct& ,const std::string&,int));
void reportCompletedJob(std::unique_ptr<cta::RetrieveJob> successfulRetrieveJob, u_int32_t checksum, u_int64_t size) {
reportCompletedJob_(successfulRetrieveJob, checksum, size);
}
void reportFailedJob(std::unique_ptr<cta::RetrieveJob> failedRetrieveJob, const std::string& msg,int error_code) {
reportFailedJob_(failedRetrieveJob, msg, error_code);
}
MOCK_METHOD3(reportCompletedJob_,void(std::unique_ptr<cta::RetrieveJob> &successfulRetrieveJob, u_int32_t checksum, u_int64_t size));
MOCK_METHOD3(reportFailedJob_, void(std::unique_ptr<cta::RetrieveJob> &failedRetrieveJob, const std::string& msg,int error_code));
MOCK_METHOD0(reportEndOfSession, void());
MOCK_METHOD2(reportEndOfSessionWithErrors, void(const std::string,int));
MockRecallReportPacker(cta::RetrieveMount *rm,castor::log::LogContext lc):
RecallReportPacker(rm,lc){}
};
TEST(castor_tape_tapeserver_daemon, DiskWriteTaskFailledBlock){
TEST(castor_tape_tapeserver_daemon, DiskWriteTaskFailedBlock){
using ::testing::_;
MockClient client;
castor::log::StringLogger log("castor_tape_tapeserver_daemon_DiskWriteTaskFailledBlock");
castor::log::StringLogger log("castor_tape_tapeserver_daemon_DiskWriteTaskFailedBlock");
castor::log::LogContext lc(log);
std::unique_ptr<cta::MockSchedulerDatabase> mdb(new cta::MockSchedulerDatabase);
MockRecallReportPacker report(dynamic_cast<cta::RetrieveMount *>((mdb->getNextMount("ll","drive")).get()),lc);
EXPECT_CALL(report,reportFailedJob(_,_,_));
std::unique_ptr<cta::SchedulerDatabase::RetrieveMount> dbrm(new cta::SchedulerDatabase::RetrieveMount);
TestingRetrieveMount trm(std::move(dbrm));
MockRecallReportPacker report(&trm,lc);
EXPECT_CALL(report,reportFailedJob_(_,_,_));
RecallMemoryManager mm(10,100,lc);
DiskFileFactory fileFactory("RFIO","",0);
castor::tape::tapegateway::FileToRecallStruct file;
file.setPath("/dev/null");
file.setFileid(0);
DiskWriteTask t(dynamic_cast<tapegateway::FileToRecallStruct*>(file.clone()),mm);
std::unique_ptr<TestingRetrieveJob> fileToRecall(new TestingRetrieveJob());
fileToRecall->archiveFile.lastKnownPath = "/dev/null";
fileToRecall->archiveFile.fileId = 0;
DiskWriteTask t(fileToRecall.release(),mm);
for(int i=0;i<6;++i){
MemBlock* mb=mm.getFreeBlock();
mb->m_fileid=0;
......@@ -73,7 +97,7 @@ namespace unitTests{
mb->markAsFailed("Test error",SEINTERNAL);
}
t.pushDataBlock(mb);
}
}
MemBlock* mb=mm.getFreeBlock();
t.pushDataBlock(mb);
......
......@@ -95,7 +95,7 @@ void RecallTaskInjector::injectBulkRecalls(const std::vector<cta::RetrieveJob *>
LogContext::ScopedParam(m_lc, Param("NSFILEID", (*it)->archiveFile.fileId)),
LogContext::ScopedParam(m_lc, Param("fSeq", (*it)->tapeCopy.fSeq)),
LogContext::ScopedParam(m_lc, Param("blockID", (*it)->tapeCopy.blockId)),
LogContext::ScopedParam(m_lc, Param("path", (*it)->tapeCopy.archiveFilePath))
LogContext::ScopedParam(m_lc, Param("path", (*it)->archiveFile.lastKnownPath))
};
tape::utils::suppresUnusedVariable(sp);
......
......@@ -74,7 +74,7 @@ public:
.add("BlockId", m_retrieveJob->tapeCopy.blockId)
.add("fSeq", m_retrieveJob->tapeCopy.fSeq)
.add("fileTransactionId", m_retrieveJob->m_id)
.add("path", m_retrieveJob->tapeCopy.archiveFilePath);
.add("path", m_retrieveJob->archiveFile.lastKnownPath);
// We will clock the stats for the file itself, and eventually add those
// stats to the session's.
......
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