Commit 2f96d904 authored by Cedric CAFFY's avatar Cedric CAFFY
Browse files

Tape files of a reclaimed tape are now deleted from the catalogue during the reclaim process

Deleted the checking of the presence of non superseded files during an Archive Mount.
parent 3d0781eb
......@@ -338,14 +338,6 @@ public:
* @param vid The volume identifier of the tape to be reclaimed.
*/
virtual void reclaimTape(const common::dataStructures::SecurityIdentity &admin, const std::string &vid) = 0;
/**
* This method should ONLY be used for TESTS. It does exactly the same as the real reclaimTape but it does not verify the
* SUPERSEDED_BY_VID and SUPERSEDED_BY_FSEQ attributes
* @param admin The administrator.
* @param vid The volume identifier of the tape to be reclaimed.
*/
virtual void fakeReclaimTapeForTests(const common::dataStructures::SecurityIdentity& admin, const std::string &vid) = 0;
virtual void modifyTapeMediaType(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const std::string &mediaType) = 0;
virtual void modifyTapeVendor(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const std::string &vendor) = 0;
......@@ -599,16 +591,6 @@ public:
* @return True if the tape exists.
*/
virtual bool tapeExists(const std::string &vid) const = 0;
/**
* Returns true if non superseded files exist after fSeq in the tape where vid is passed in parameter
* If there is only superseded files after fSeq, these tape files will be deleted
*
* @param vid the vid of the tape to check if non superseded files exist after fSeq
* @param fSeq the fSeq after which we want to check if non superseded files exist
* @return true if non superseded files exist, false otherwise
*/
virtual bool existNonSupersededFilesAfterFSeqAndDeleteTapeFilesForWriting(const std::string &vid, const uint64_t fSeq) const = 0;
}; // class Catalogue
......
......@@ -232,10 +232,6 @@ public:
void reclaimTape(const common::dataStructures::SecurityIdentity &admin, const std::string &vid) override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->reclaimTape(admin, vid);}, m_maxTriesToConnect);
}
void fakeReclaimTapeForTests(const common::dataStructures::SecurityIdentity &admin, const std::string &vid) override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->fakeReclaimTapeForTests(admin, vid);}, m_maxTriesToConnect);
}
void modifyTapeMediaType(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const std::string &mediaType) override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyTapeMediaType(admin, vid, mediaType);}, m_maxTriesToConnect);
......@@ -388,11 +384,6 @@ public:
bool tapeExists(const std::string &vid) const override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->tapeExists(vid);}, m_maxTriesToConnect);
}
bool existNonSupersededFilesAfterFSeqAndDeleteTapeFilesForWriting(const std::string& vid, const uint64_t fSeq) const override {
return retryOnLostConnection(m_log,[&]{return m_catalogue->existNonSupersededFilesAfterFSeqAndDeleteTapeFilesForWriting(vid,fSeq);},m_maxTriesToConnect);
}
protected:
......
......@@ -12151,122 +12151,6 @@ TEST_P(cta_catalogue_CatalogueTest, reclaimTape_full_lastFSeq_1_one_tape_file_su
}
}
TEST_P(cta_catalogue_CatalogueTest, exist_non_superseded_files_after_fseq) {
using namespace cta;
const std::string diskInstanceName1 = "disk_instance_1";
ASSERT_TRUE(m_catalogue->getTapes().empty());
const std::string vid1 = "VID123";
const std::string vid2 = "VID234";
const std::string mediaType = "media_type";
const std::string vendor = "vendor";
const std::string logicalLibraryName = "logical_library_name";
const bool logicalLibraryIsDisabled= false;
const std::string tapePoolName = "tape_pool_name";
const std::string vo = "vo";
const uint64_t nbPartialTapes = 2;
const bool isEncrypted = true;
const cta::optional<std::string> supply("value for the supply pool mechanism");
const uint64_t capacityInBytes = (uint64_t)10 * 1000 * 1000 * 1000 * 1000;
const bool disabledValue = true;
const bool fullValue = false;
const std::string createTapeComment = "Create tape";
m_catalogue->createLogicalLibrary(m_admin, logicalLibraryName, logicalLibraryIsDisabled, "Create logical library");
m_catalogue->createTapePool(m_admin, tapePoolName, vo, nbPartialTapes, isEncrypted, supply, "Create tape pool");
m_catalogue->createTape(m_admin, vid1, mediaType, vendor, logicalLibraryName, tapePoolName, capacityInBytes,
disabledValue, fullValue, createTapeComment);
//A tape with no tape file have no files after FSeq 0
ASSERT_FALSE(m_catalogue->existNonSupersededFilesAfterFSeqAndDeleteTapeFilesForWriting(vid1,0));
const uint64_t archiveFileId = 1234;
ASSERT_FALSE(m_catalogue->getArchiveFilesItor().hasMore());
ASSERT_THROW(m_catalogue->getArchiveFileById(archiveFileId), exception::Exception);
common::dataStructures::StorageClass storageClass;
storageClass.diskInstance = diskInstanceName1;
storageClass.name = "storage_class";
storageClass.nbCopies = 1;
storageClass.comment = "Create storage class";
m_catalogue->createStorageClass(m_admin, storageClass);
/*
* Insert a file in the tape vid1
*/
{
const uint64_t archiveFileSize = 1;
const std::string tapeDrive = "tape_drive";
const std::string checksumType = "checksum_type";
const std::string checksumValue = "checksum_value";
auto file1WrittenUP=cta::make_unique<cta::catalogue::TapeFileWritten>();
auto & file1Written = *file1WrittenUP;
std::set<cta::catalogue::TapeItemWrittenPointer> file1WrittenSet;
file1WrittenSet.insert(file1WrittenUP.release());
file1Written.archiveFileId = archiveFileId;
file1Written.diskInstance = storageClass.diskInstance;
file1Written.diskFileId = "5678";
file1Written.diskFilePath = "/public_dir/public_file";
file1Written.diskFileUser = "public_disk_user";
file1Written.diskFileGroup = "public_disk_group";
file1Written.size = archiveFileSize;
file1Written.checksumType = checksumType;
file1Written.checksumValue = checksumValue;
file1Written.storageClassName = storageClass.name;
file1Written.vid = vid1;
file1Written.fSeq = 1;
file1Written.blockId = 4321;
file1Written.compressedSize = 1;
file1Written.copyNb = 1;
file1Written.tapeDrive = tapeDrive;
m_catalogue->filesWrittenToTape(file1WrittenSet);
}
//One file written : this file is not superseded by another one, existNonSupersededFilesAfterFSeq = true
ASSERT_TRUE(m_catalogue->existNonSupersededFilesAfterFSeqAndDeleteTapeFilesForWriting(vid1,0));
//No file after the only file inserted, existNonSupersededFilesAfterFseq = false
ASSERT_FALSE(m_catalogue->existNonSupersededFilesAfterFSeqAndDeleteTapeFilesForWriting(vid1,1));
//Insert another file in another tape that will supersed the first one in vid1
{
m_catalogue->createTape(m_admin, vid2, mediaType, vendor, logicalLibraryName, tapePoolName, capacityInBytes,
disabledValue, fullValue, createTapeComment);
const uint64_t archiveFileSize = 1;
const std::string tapeDrive = "tape_drive";
const std::string checksumType = "checksum_type";
const std::string checksumValue = "checksum_value";
auto file1WrittenUP=cta::make_unique<cta::catalogue::TapeFileWritten>();
auto & file1Written = *file1WrittenUP;
std::set<cta::catalogue::TapeItemWrittenPointer> file1WrittenSet;
file1WrittenSet.insert(file1WrittenUP.release());
file1Written.archiveFileId = archiveFileId;
file1Written.diskInstance = storageClass.diskInstance;
file1Written.diskFileId = "5678";
file1Written.diskFilePath = "/public_dir/public_file";
file1Written.diskFileUser = "public_disk_user";
file1Written.diskFileGroup = "public_disk_group";
file1Written.size = archiveFileSize;
file1Written.checksumType = checksumType;
file1Written.checksumValue = checksumValue;
file1Written.storageClassName = storageClass.name;
file1Written.vid = vid2;
file1Written.fSeq = 1;
file1Written.blockId = 4321;
file1Written.compressedSize = 1;
file1Written.copyNb = 1;
file1Written.tapeDrive = tapeDrive;
m_catalogue->filesWrittenToTape(file1WrittenSet);
}
//The tape files written to tape vid2 are not superseded by any file, but the tape files in vid1
//are superseded by the tape files in vid2
ASSERT_FALSE(m_catalogue->existNonSupersededFilesAfterFSeqAndDeleteTapeFilesForWriting(vid1,0));
ASSERT_TRUE(m_catalogue->existNonSupersededFilesAfterFSeqAndDeleteTapeFilesForWriting(vid2,0));
}
TEST_P(cta_catalogue_CatalogueTest, ping) {
using namespace cta;
......
......@@ -107,7 +107,6 @@ public:
const std::string &storageClassName, const common::dataStructures::UserIdentity &user) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
common::dataStructures::RetrieveFileQueueCriteria prepareToRetrieveFile(const std::string& instanceName, const uint64_t archiveFileId, const common::dataStructures::UserIdentity& user, log::LogContext &lc) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void reclaimTape(const common::dataStructures::SecurityIdentity& admin, const std::string& vid) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void fakeReclaimTapeForTests(const common::dataStructures::SecurityIdentity& admin, const std::string& vid) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void setTapeDisabled(const common::dataStructures::SecurityIdentity& admin, const std::string& vid, const bool disabledValue) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void setTapeFull(const common::dataStructures::SecurityIdentity& admin, const std::string& vid, const bool fullValue) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void setTapePoolEncryption(const common::dataStructures::SecurityIdentity& admin, const std::string& name, const bool encryptionValue) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
......@@ -116,7 +115,6 @@ public:
void tapeMountedForArchive(const std::string& vid, const std::string& drive) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void tapeMountedForRetrieve(const std::string& vid, const std::string& drive) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
bool tapePoolExists(const std::string& tapePoolName) const { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
bool existNonSupersededFilesAfterFSeqAndDeleteTapeFilesForWriting(const std::string& vid, const uint64_t fSeq) const { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
// Special functions for unit tests.
void addEnabledTape(const std::string & vid) {
......
......@@ -1891,47 +1891,6 @@ bool RdbmsCatalogue::tapeExists(rdbms::Conn &conn, const std::string &vid) const
}
}
bool RdbmsCatalogue::existNonSupersededFilesAfterFSeqAndDeleteTapeFilesForWriting(const std::string& vid, const uint64_t fSeq) const {
try{
auto conn = m_connPool.getConn();
const char *const sql =
"SELECT VID "
"FROM TAPE_FILE "
"WHERE "
"VID = :VID AND "
"FSEQ > :FSEQ AND "
"SUPERSEDED_BY_VID IS NULL AND "
"SUPERSEDED_BY_FSEQ IS NULL";
auto stmt = conn.createStmt(sql);
stmt.bindString(":VID",vid);
stmt.bindUint64(":FSEQ",fSeq);
auto rset = stmt.executeQuery();
if(!rset.next()){
//No non-superseded files detected, we can delete the tape files
const char *const sqlDelete =
"DELETE FROM TAPE_FILE "
"WHERE "
"VID =:VID AND "
"FSEQ > :FSEQ AND "
"SUPERSEDED_BY_VID IS NOT NULL AND "
"SUPERSEDED_BY_FSEQ IS NOT NULL";
auto stmtDelete = conn.createStmt(sqlDelete);
stmtDelete.bindString(":VID",vid);
stmtDelete.bindUint64(":FSEQ",fSeq);
stmtDelete.executeNonQuery();
return false;
}
//Non superseded files are present
return true;
} catch(exception::UserError &) {
throw;
} catch(exception::Exception &ex) {
ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
throw;
}
}
//------------------------------------------------------------------------------
// deleteTape
//------------------------------------------------------------------------------
......@@ -2346,73 +2305,47 @@ common::dataStructures::VidToTapeMap RdbmsCatalogue::getAllTapes() const {
}
//------------------------------------------------------------------------------
// reclaimTape
//getNbNonSupersededFilesOnTape
//------------------------------------------------------------------------------
void RdbmsCatalogue::reclaimTape(const common::dataStructures::SecurityIdentity &admin, const std::string &vid) {
uint64_t RdbmsCatalogue::getNbNonSupersededFilesOnTape(rdbms::Conn& conn, const std::string& vid) const {
try {
const time_t now = time(nullptr);
const char *const sql =
"UPDATE TAPE SET "
"DATA_IN_BYTES = 0,"
"LAST_FSEQ = 0,"
"IS_FULL = '0',"
"LAST_UPDATE_USER_NAME = :LAST_UPDATE_USER_NAME,"
"LAST_UPDATE_HOST_NAME = :LAST_UPDATE_HOST_NAME,"
"LAST_UPDATE_TIME = :LAST_UPDATE_TIME "
"WHERE "
"VID = :UPDATE_VID AND "
"IS_FULL != '0' AND "
"NOT EXISTS (SELECT VID FROM TAPE_FILE WHERE VID = :SELECT_VID "
" AND SUPERSEDED_BY_VID IS NULL "
" AND SUPERSEDED_BY_FSEQ IS NULL)";
auto conn = m_connPool.getConn();
const char *const sql =
"SELECT COUNT(*) AS NB_NON_SUPERSEDED_FILES FROM TAPE_FILE "
"WHERE VID = :VID "
"AND SUPERSEDED_BY_VID IS NULL "
"AND SUPERSEDED_BY_FSEQ IS NULL";
auto stmt = conn.createStmt(sql);
stmt.bindString(":LAST_UPDATE_USER_NAME", admin.username);
stmt.bindString(":LAST_UPDATE_HOST_NAME", admin.host);
stmt.bindUint64(":LAST_UPDATE_TIME", now);
stmt.bindString(":UPDATE_VID", vid);
stmt.bindString(":SELECT_VID", vid);
stmt.executeNonQuery();
// If the update failed due to a user error
if(0 == stmt.getNbAffectedRows()) {
// Try to determine the user error
//
// Please note that this is a best effort diagnosis because there is no
// lock on the database to prevent other concurrent updates from taking
// place on the TAPE and TAPE_FILE tables
TapeSearchCriteria searchCriteria;
searchCriteria.vid = vid;
const auto tapes = getTapes(conn, searchCriteria);
if(tapes.empty()) {
throw exception::UserError(std::string("Cannot reclaim tape ") + vid + " because it does not exist");
} else {
if(!tapes.front().full) {
throw exception::UserError(std::string("Cannot reclaim tape ") + vid + " because it is not FULL");
} else {
throw exception::UserError(std::string("Cannot reclaim tape ") + vid + " because there is at least one tape"
" file in the catalogue that is on the tape");
}
}
}
} catch(exception::UserError &) {
throw;
stmt.bindString(":VID", vid);
auto rset = stmt.executeQuery();
rset.next();
return rset.columnUint64("NB_NON_SUPERSEDED_FILES");
} catch(exception::Exception &ex) {
ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
throw;
}
}
//------------------------------------------------------------------------------
//fakeReclaimTapeForTests
//------------------------------------------------------------------------------
void RdbmsCatalogue::fakeReclaimTapeForTests(const common::dataStructures::SecurityIdentity& admin, const std::string& vid) {
void RdbmsCatalogue::deleteTapeFiles(rdbms::Conn& conn, const std::string& vid) const {
try {
const char * const sql =
"DELETE FROM TAPE_FILE WHERE VID = :VID "
"AND SUPERSEDED_BY_VID IS NOT NULL "
"AND SUPERSEDED_BY_FSEQ IS NOT NULL";
auto stmt = conn.createStmt(sql);
stmt.bindString(":VID", vid);
stmt.executeNonQuery();
} catch(exception::Exception &ex) {
ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
throw;
}
}
void RdbmsCatalogue::resetTapeCounters(rdbms::Conn& conn, const common::dataStructures::SecurityIdentity& admin, const std::string& vid) const {
try {
const time_t now = time(nullptr);
const char *const sql =
"UPDATE TAPE SET "
const char * const sql =
"UPDATE TAPE SET "
"DATA_IN_BYTES = 0,"
"LAST_FSEQ = 0,"
"IS_FULL = '0',"
......@@ -2420,47 +2353,55 @@ void RdbmsCatalogue::fakeReclaimTapeForTests(const common::dataStructures::Secur
"LAST_UPDATE_HOST_NAME = :LAST_UPDATE_HOST_NAME,"
"LAST_UPDATE_TIME = :LAST_UPDATE_TIME "
"WHERE "
"VID = :UPDATE_VID AND "
"IS_FULL != '0'";
auto conn = m_connPool.getConn();
"VID = :VID";
auto stmt = conn.createStmt(sql);
stmt.bindString(":LAST_UPDATE_USER_NAME", admin.username);
stmt.bindString(":LAST_UPDATE_HOST_NAME", admin.host);
stmt.bindUint64(":LAST_UPDATE_TIME", now);
stmt.bindString(":UPDATE_VID", vid);
stmt.bindString(":VID", vid);
stmt.executeNonQuery();
} catch (exception::Exception &ex){
ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
throw;
}
}
// If the update failed due to a user error
if(0 == stmt.getNbAffectedRows()) {
// Try to determine the user error
//
// Please note that this is a best effort diagnosis because there is no
// lock on the database to prevent other concurrent updates from taking
// place on the TAPE and TAPE_FILE tables
TapeSearchCriteria searchCriteria;
searchCriteria.vid = vid;
const auto tapes = getTapes(conn, searchCriteria);
if(tapes.empty()) {
throw exception::UserError(std::string("Cannot reclaim tape ") + vid + " because it does not exist");
} else {
if(!tapes.front().full) {
throw exception::UserError(std::string("Cannot reclaim tape ") + vid + " because it is not FULL");
} else {
throw exception::UserError(std::string("Cannot reclaim tape ") + vid + " because there is at least one tape"
//------------------------------------------------------------------------------
// reclaimTape
//------------------------------------------------------------------------------
void RdbmsCatalogue::reclaimTape(const common::dataStructures::SecurityIdentity &admin, const std::string &vid) {
try{
auto conn = m_connPool.getConn();
TapeSearchCriteria searchCriteria;
searchCriteria.vid = vid;
const auto tapes = getTapes(conn, searchCriteria);
if(tapes.empty()) {
throw exception::UserError(std::string("Cannot reclaim tape ") + vid + " because it does not exist");
} else {
if(!tapes.front().full){
throw exception::UserError(std::string("Cannot reclaim tape ") + vid + " because it is not FULL");
}
}
//The tape exists and is full, we can try to reclaim it
if(getNbNonSupersededFilesOnTape(conn,vid) == 0){
//There is no non-superseded files on the tape, we can reclaim it : delete the files and reset the counters
deleteTapeFiles(conn,vid);
resetTapeCounters(conn,admin,vid);
} else {
throw exception::UserError(std::string("Cannot reclaim tape ") + vid + " because there is at least one tape"
" file in the catalogue that is on the tape");
}
}
}
} catch(exception::UserError &) {
} catch (exception::UserError& ue) {
throw;
} catch(exception::Exception &ex) {
}
catch (exception::Exception &ex) {
ex.getMessage().str(std::string(__FUNCTION__) + ": " + ex.getMessage().str());
throw;
}
}
//------------------------------------------------------------------------------
// getTapeLogFromRset
//------------------------------------------------------------------------------
......
......@@ -332,7 +332,27 @@ public:
* @param vid The volume identifier of the tape to be reclaimed.
*/
void reclaimTape(const common::dataStructures::SecurityIdentity &admin, const std::string &vid) override;
void fakeReclaimTapeForTests(const common::dataStructures::SecurityIdentity& admin, const std::string& vid) override;
/**
* Returns the number of non superseded files contained in the tape identified by its vid
* @param conn the database connection
* @param vid the vid in which we will count non superseded files
* @return the number of non superseded files on the vid
*/
uint64_t getNbNonSupersededFilesOnTape(rdbms::Conn &conn, const std::string &vid) const;
/**
* Delete all the tape files of the VID passed in parameter
* @param conn the database connection
* @param vid the vid in which we want to remove all the tape files
*/
void deleteTapeFiles(rdbms::Conn &conn, const std::string& vid) const;
/**
* Reset the counters of a tape
* @param conn the database connection
* @param admin the administrator
* @param vid the vid to reset the counters
*/
void resetTapeCounters(rdbms::Conn &conn, const common::dataStructures::SecurityIdentity &admin ,const std::string& vid) const;
void modifyTapeMediaType(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const std::string &mediaType) override;
void modifyTapeVendor(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const std::string &vendor) override;
void modifyTapeLogicalLibraryName(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const std::string &logicalLibraryName) override;
......@@ -715,17 +735,6 @@ protected:
* @return True if the tape exists.
*/
bool tapeExists(rdbms::Conn &conn, const std::string &vid) const;
/**
* Returns true if non superseded files exist after fSeq in the tape where vid is passed in parameter
* If there is only superseded files after fSeq, these tape files will be deleted
*
* @param vid the vid of the tape to check if non superseded files exist after fSeq
* @param fSeq the fSeq after which we want to check if non superseded files exist
* @return true if non superseded files exist, false otherwise
*/
bool existNonSupersededFilesAfterFSeqAndDeleteTapeFilesForWriting(const std::string& vid, const uint64_t fSeq) const override;
/**
* Returns the list of tapes that meet the specified search criteria.
......@@ -735,7 +744,7 @@ protected:
* @return The list of tapes.
*/
std::list<common::dataStructures::Tape> getTapes(rdbms::Conn &conn, const TapeSearchCriteria &searchCriteria) const;
/**
* Returns true if the specified logical library exists.
*
......
......@@ -104,16 +104,6 @@ uint32_t cta::ArchiveMount::getNbFiles() const {
return m_dbMount->nbFilesCurrentlyOnTape;
}
//------------------------------------------------------------------------------
// checkTapeFSeqForWriting
//------------------------------------------------------------------------------
void cta::ArchiveMount::checkTapeFSeqAndDeleteTapeFilesForWriting(uint64_t fSeq) const {
if(m_catalogue.existNonSupersededFilesAfterFSeqAndDeleteTapeFilesForWriting(getVid(),fSeq)){
throw cta::exception::Exception("Non superseded files have been detected in the tape "+getVid() +" after "+std::to_string(fSeq));
}
}
//------------------------------------------------------------------------------
// createDiskReporter
//------------------------------------------------------------------------------
......
......@@ -172,14 +172,6 @@ namespace cta {
*/
uint32_t getNbFiles() const override;
/**
* Checks wether the writing is possible after the FSeq passed in parameter
* If TapeFiles are located after FSeq and are not superseded by other TapeFiles
* we throw an exception : We don't want these files to be lost.
* @param fSeq : The fSeq after which we want to check if the writing is possible
*/
void checkTapeFSeqAndDeleteTapeFilesForWriting(uint64_t fSeq) const;
/**
* Creates a disk reporter for the ArchiveJob (this is a wrapper).
* @param URL: report address
......
......@@ -1858,166 +1858,6 @@ TEST_P(DataTransferSessionTest, DataTransferSessionTapeFullOnFlushMigration) {
"mountTotalReadRetries=\"25\" mountTotalWriteRetries=\"25\" mountWriteTransients=\"10\""));
}
TEST_P(DataTransferSessionTest, WriteDataInTapeWithNonSupersededFilesOnIt) {
// 0) Prepare the logger for everyone
cta::log::StringLogger logger("dummy","tapeServerUnitTest",cta::log::DEBUG);
cta::log::LogContext logContext(logger);
setupDefaultCatalogue();
// 1) prepare the fake scheduler
std::string vid = s_vid;
std::string vid2 = s_vid+"2";
// cta::MountType::Enum mountType = cta::MountType::RETRIEVE;
// 3) Prepare the necessary environment (logger, plus system wrapper),
castor::tape::System::mockWrapper mockSys;
mockSys.delegateToFake();
mockSys.disableGMockCallsCounting();
mockSys.fake.setupForVirtualDriveSLC6();
// 4) Create the scheduler
auto & catalogue = getCatalogue();
auto & scheduler = getScheduler();
// Always use the same requester
const cta::common::dataStructures::SecurityIdentity requester("user", "group");
// List to remember the path of each remote file so that the existance of the
// files can be tested for at the end of the test
std::list<std::string> remoteFilePaths;
// 5) Create the environment for the migration to happen (library + tape)
const std::string libraryComment = "Library comment";
const bool libraryIsDisabled = false;
catalogue.createLogicalLibrary(s_adminOnAdminHost, s_libraryName,
libraryIsDisabled, libraryComment);
{
auto libraries = catalogue.getLogicalLibraries();
ASSERT_EQ(1, libraries.size());
ASSERT_EQ(s_libraryName, libraries.front().name);
ASSERT_EQ(libraryComment, libraries.front().comment);
}
const uint64_t capacityInBytes = 12345678;
const std::string tapeComment = "Tape comment";
bool disabled = false;
bool full = false;
catalogue.createTape(s_adminOnAdminHost, s_vid, s_mediaType, s_vendor, s_libraryName, s_tapePoolName, capacityInBytes,
disabled, full, tapeComment);
catalogue.createTape(s_adminOnAdminHost, vid2, s_mediaType, s_vendor, s_libraryName, s_tapePoolName, capacityInBytes,
disabled, full, tapeComment);
// Create the mount criteria
catalogue.createMountPolicy(requester, "immediateMount", 1000, 0, 1000, 0, 1, "Policy comment");
catalogue.createRequesterMountRule(requester, "immediateMount", s_diskInstance, requester.username, "Rule comment");
//delete is unnecessary
//pointer with ownership will be passed to the application,
//which will do the delete
mockSys.fake.m_pathToDrive["/dev/nst0"] = new castor::tape::tapeserver::drive::FakeDrive();
// We can prepare files for writing on the drive.
// Tempfiles are in this scope so they are kept alive
std::vector<std::unique_ptr<unitTests::TempFile>> sourceFiles;
std::list<uint64_t> archiveFileIds;
{
// Label the tape
castor::tape::tapeFile::LabelSession ls(*mockSys.fake.m_pathToDrive["/dev/nst0"], s_vid, false);
catalogue.tapeLabelled(s_vid, "T10D6116");
mockSys.fake.m_pathToDrive["/dev/nst0"]->rewind();
// Create the files and schedule the archivals
for(int fseq=1; fseq <= 10 ; fseq ++) {
// Create a source file.