Commit 74abb6f0 authored by Daniele Kruse's avatar Daniele Kruse
Browse files

Started adapting RecallTaskInjectorTest

parent e2d65393
......@@ -40,135 +40,142 @@
namespace unitTests
{
using namespace castor::tape::tapeserver::daemon;
using namespace castor::tape;
const int blockSize=4096;
class FakeDiskWriteThreadPool: public DiskWriteThreadPool
{
public:
using DiskWriteThreadPool::m_tasks;
FakeDiskWriteThreadPool(castor::log::LogContext & lc):
DiskWriteThreadPool(1,*((RecallReportPacker*)NULL),
*((RecallWatchDog*)NULL),lc, "RFIO","/dev/null",0){}
virtual ~FakeDiskWriteThreadPool() {};
};
class FakeSingleTapeReadThread : public TapeSingleThreadInterface<TapeReadTask>
{
public:
using TapeSingleThreadInterface<TapeReadTask>::m_tasks;
FakeSingleTapeReadThread(castor::tape::tapeserver::drive::DriveInterface& drive,
castor::mediachanger::MediaChangerFacade & mc,
castor::tape::tapeserver::daemon::TapeServerReporter & tsr,
const castor::tape::tapeserver::client::ClientInterface::VolumeInfo& volInfo,
castor::server::ProcessCap& cap,
castor::log::LogContext & lc):
TapeSingleThreadInterface<TapeReadTask>(drive, mc, tsr, volInfo,cap, lc){}
~FakeSingleTapeReadThread(){
const unsigned int size= m_tasks.size();
for(unsigned int i=0;i<size;++i){
delete m_tasks.pop();
class TestingRetrieveMount: public cta::RetrieveMount {
public:
TestingRetrieveMount(std::unique_ptr<cta::SchedulerDatabase::RetrieveMount> dbrm): RetrieveMount(std::move(dbrm)) {
}
}
virtual void run ()
{
m_tasks.push(NULL);
}
virtual void push(TapeReadTask* t){
m_tasks.push(t);
}
virtual void countTapeLogError(const std::string & error) {};
};
TEST(castor_tape_tapeserver_daemon, RecallTaskInjectorNominal) {
const int nbCalls=2;
castor::log::StringLogger log("castor_tape_tapeserver_daemon_RecallTaskInjectorTest");
castor::log::LogContext lc(log);
RecallMemoryManager mm(50U,50U,lc);
castor::tape::tapeserver::drive::FakeDrive drive;
FakeClient client(nbCalls);
FakeDiskWriteThreadPool diskWrite(lc);
castor::messages::AcsProxyDummy acs;
castor::mediachanger::MmcProxyDummy mmc;
castor::legacymsg::RmcProxyDummy rmc;
castor::mediachanger::MediaChangerFacade mc(acs, mmc, rmc);
castor::messages::TapeserverProxyDummy initialProcess;
castor::tape::tapeserver::client::ClientInterface::VolumeInfo volume;
volume.density="8000GC";
volume.labelObsolete="AUL";
volume.vid="V12345";
volume.mountType=cta::MountType::RETRIEVE;
castor::tape::tapeserver::daemon::TapeServerReporter gsr(initialProcess,
DriveConfig(),"0.0.0.0",volume,lc);
castor::server::ProcessCapDummy cap;
FakeSingleTapeReadThread tapeRead(drive, mc, gsr, volume, cap,lc);
//tapeserver::daemon::RecallReportPacker rrp(client,2,lc);
tapeserver::daemon::RecallTaskInjector rti(mm,tapeRead,diskWrite,client,6,blockSize,lc);
};
ASSERT_EQ(true,rti.synchronousInjection());
ASSERT_EQ(nbFile,diskWrite.m_tasks.size());
ASSERT_EQ(nbFile,tapeRead.m_tasks.size());
rti.startThreads();
rti.requestInjection(false);
rti.requestInjection(true);
rti.finish();
rti.waitThreads();
//pushed nbFile*2 files + 1 end of work
ASSERT_EQ(nbFile*nbCalls+1,diskWrite.m_tasks.size());
ASSERT_EQ(nbFile*nbCalls+1,tapeRead.m_tasks.size());
for(unsigned int i=0;i<nbFile*nbCalls;++i)
using namespace castor::tape::tapeserver::daemon;
using namespace castor::tape;
const int blockSize=4096;
class FakeDiskWriteThreadPool: public DiskWriteThreadPool
{
delete diskWrite.m_tasks.pop();
delete tapeRead.m_tasks.pop();
}
for(int i=0;i<1;++i)
public:
using DiskWriteThreadPool::m_tasks;
FakeDiskWriteThreadPool(castor::log::LogContext & lc):
DiskWriteThreadPool(1,*((RecallReportPacker*)NULL),
*((RecallWatchDog*)NULL),lc, "RFIO","/dev/null",0){}
virtual ~FakeDiskWriteThreadPool() {};
};
class FakeSingleTapeReadThread : public TapeSingleThreadInterface<TapeReadTask>
{
DiskWriteTask* diskWriteTask=diskWrite.m_tasks.pop();
TapeReadTask* tapeReadTask=tapeRead.m_tasks.pop();
public:
using TapeSingleThreadInterface<TapeReadTask>::m_tasks;
FakeSingleTapeReadThread(castor::tape::tapeserver::drive::DriveInterface& drive,
castor::mediachanger::MediaChangerFacade & mc,
castor::tape::tapeserver::daemon::TapeServerReporter & tsr,
const castor::tape::tapeserver::daemon::VolumeInfo& volInfo,
castor::server::ProcessCap& cap,
castor::log::LogContext & lc):
TapeSingleThreadInterface<TapeReadTask>(drive, mc, tsr, volInfo,cap, lc){}
~FakeSingleTapeReadThread(){
const unsigned int size= m_tasks.size();
for(unsigned int i=0;i<size;++i){
delete m_tasks.pop();
}
}
virtual void run ()
{
m_tasks.push(NULL);
}
virtual void push(TapeReadTask* t){
m_tasks.push(t);
}
virtual void countTapeLogError(const std::string & error) {};
};
TEST(castor_tape_tapeserver_daemon, RecallTaskInjectorNominal) {
const int nbCalls=2;
castor::log::StringLogger log("castor_tape_tapeserver_daemon_RecallTaskInjectorTest");
castor::log::LogContext lc(log);
RecallMemoryManager mm(50U,50U,lc);
castor::tape::tapeserver::drive::FakeDrive drive;
std::unique_ptr<cta::SchedulerDatabase::RetrieveMount> dbrm(new cta::SchedulerDatabase::RetrieveMount);
TestingRetrieveMount trm(std::move(dbrm));
//static_cast is needed otherwise compilation fails on SL5 with a raw NULL
ASSERT_EQ(static_cast<DiskWriteTask*>(NULL),diskWriteTask);
ASSERT_EQ(static_cast<TapeReadTask*>(NULL),tapeReadTask);
delete diskWriteTask;
delete tapeReadTask;
FakeDiskWriteThreadPool diskWrite(lc);
castor::messages::AcsProxyDummy acs;
castor::mediachanger::MmcProxyDummy mmc;
castor::legacymsg::RmcProxyDummy rmc;
castor::mediachanger::MediaChangerFacade mc(acs, mmc, rmc);
castor::messages::TapeserverProxyDummy initialProcess;
castor::tape::tapeserver::daemon::VolumeInfo volume;
volume.density="8000GC";
volume.labelObsolete="AUL";
volume.vid="V12345";
volume.mountType=cta::MountType::RETRIEVE;
castor::tape::tapeserver::daemon::TapeServerReporter gsr(initialProcess,
DriveConfig(),"0.0.0.0",volume,lc);
castor::server::ProcessCapDummy cap;
FakeSingleTapeReadThread tapeRead(drive, mc, gsr, volume, cap,lc);
tapeserver::daemon::RecallTaskInjector rti(mm,tapeRead,diskWrite,trm,6,blockSize,lc);
ASSERT_EQ(true,rti.synchronousInjection());
ASSERT_EQ(nbFile,diskWrite.m_tasks.size());
ASSERT_EQ(nbFile,tapeRead.m_tasks.size());
rti.startThreads();
rti.requestInjection(false);
rti.requestInjection(true);
rti.finish();
rti.waitThreads();
//pushed nbFile*2 files + 1 end of work
ASSERT_EQ(nbFile*nbCalls+1,diskWrite.m_tasks.size());
ASSERT_EQ(nbFile*nbCalls+1,tapeRead.m_tasks.size());
for(unsigned int i=0;i<nbFile*nbCalls;++i)
{
delete diskWrite.m_tasks.pop();
delete tapeRead.m_tasks.pop();
}
for(int i=0;i<1;++i)
{
DiskWriteTask* diskWriteTask=diskWrite.m_tasks.pop();
TapeReadTask* tapeReadTask=tapeRead.m_tasks.pop();
//static_cast is needed otherwise compilation fails on SL5 with a raw NULL
ASSERT_EQ(static_cast<DiskWriteTask*>(NULL),diskWriteTask);
ASSERT_EQ(static_cast<TapeReadTask*>(NULL),tapeReadTask);
delete diskWriteTask;
delete tapeReadTask;
}
}
TEST(castor_tape_tapeserver_daemon, RecallTaskInjectorNoFiles) {
castor::log::StringLogger log("castor_tape_tapeserver_daemon_RecallTaskInjectorTest");
castor::log::LogContext lc(log);
RecallMemoryManager mm(50U,50U,lc);
castor::tape::tapeserver::drive::FakeDrive drive;
FakeClient client(0);
FakeDiskWriteThreadPool diskWrite(lc);
castor::messages::AcsProxyDummy acs;
castor::mediachanger::MmcProxyDummy mmc;
castor::legacymsg::RmcProxyDummy rmc;
castor::mediachanger::MediaChangerFacade mc(acs, mmc, rmc);
castor::messages::TapeserverProxyDummy initialProcess;
castor::tape::tapeserver::daemon::VolumeInfo volume;
volume.density="8000GC";
volume.labelObsolete="AUL";
volume.vid="V12345";
volume.mountType=cta::MountType::RETRIEVE;
castor::server::ProcessCapDummy cap;
castor::tape::tapeserver::daemon::TapeServerReporter tsr(initialProcess,
DriveConfig(),"0.0.0.0",volume,lc);
FakeSingleTapeReadThread tapeRead(drive, mc, tsr, volume,cap, lc);
//tapeserver::daemon::RecallReportPacker rrp(client,2,lc);
tapeserver::daemon::RecallTaskInjector rti(mm,tapeRead,diskWrite,client,6,blockSize,lc);
ASSERT_EQ(false,rti.synchronousInjection());
ASSERT_EQ(0U,diskWrite.m_tasks.size());
ASSERT_EQ(0U,tapeRead.m_tasks.size());
}
}
TEST(castor_tape_tapeserver_daemon, RecallTaskInjectorNoFiles) {
castor::log::StringLogger log("castor_tape_tapeserver_daemon_RecallTaskInjectorTest");
castor::log::LogContext lc(log);
RecallMemoryManager mm(50U,50U,lc);
castor::tape::tapeserver::drive::FakeDrive drive;
FakeClient client(0);
FakeDiskWriteThreadPool diskWrite(lc);
castor::messages::AcsProxyDummy acs;
castor::mediachanger::MmcProxyDummy mmc;
castor::legacymsg::RmcProxyDummy rmc;
castor::mediachanger::MediaChangerFacade mc(acs, mmc, rmc);
castor::messages::TapeserverProxyDummy initialProcess;
castor::tape::tapeserver::client::ClientInterface::VolumeInfo volume;
volume.density="8000GC";
volume.labelObsolete="AUL";
volume.vid="V12345";
volume.mountType=cta::MountType::RETRIEVE;
castor::server::ProcessCapDummy cap;
castor::tape::tapeserver::daemon::TapeServerReporter tsr(initialProcess,
DriveConfig(),"0.0.0.0",volume,lc);
FakeSingleTapeReadThread tapeRead(drive, mc, tsr, volume,cap, lc);
//tapeserver::daemon::RecallReportPacker rrp(client,2,lc);
tapeserver::daemon::RecallTaskInjector rti(mm,tapeRead,diskWrite,client,6,blockSize,lc);
ASSERT_EQ(false,rti.synchronousInjection());
ASSERT_EQ(0U,diskWrite.m_tasks.size());
ASSERT_EQ(0U,tapeRead.m_tasks.size());
}
}
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