Commit 53f9a4e6 authored by Steven Murray's avatar Steven Murray
Browse files

The uncommented tests of DataTransferSessionTest now create tape file entries...

The uncommented tests of DataTransferSessionTest now create tape file entries in the archive namespace
parent 14f87d50
......@@ -477,7 +477,7 @@ bool cta::Utils::isValidUInt(const std::string &str)
//------------------------------------------------------------------------------
// getAdler32
//------------------------------------------------------------------------------
uint32_t cta::Utils::getAdler32(const char *buf, const uint32_t len)
uint32_t cta::Utils::getAdler32(const uint8_t *buf, const uint32_t len)
throw() {
const uint32_t checksum = adler32(0L, Z_NULL, 0);
return adler32(checksum, (const Bytef*)buf, len);
......
......@@ -215,7 +215,7 @@ public:
* @param len The length of the buffer in bytes.
* @return the alder32 checksum of the specified buffer.
*/
static uint32_t getAdler32(const char *buf, const uint32_t len) throw();
static uint32_t getAdler32(const uint8_t *buf, const uint32_t len) throw();
}; // class Utils
......
......@@ -462,7 +462,7 @@ TEST_F(cta_UtilsTest, adler32_empty_buf) {
TEST_F(cta_UtilsTest, adler32_buf_of_character_1) {
using namespace cta;
const char buf = '1';
const uint8_t buf = '1';
ASSERT_EQ((uint32_t)0x320032, Utils::getAdler32(&buf, 1));
}
......
......@@ -25,15 +25,19 @@ cta::TapeFileLocation::TapeFileLocation():
fSeq(0),
blockId(0),
vid(""),
copyNumber(0) {
copyNb(0) {
}
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::TapeFileLocation::TapeFileLocation(const uint64_t fSeq, const uint64_t blockId, const std::string &vid, const uint8_t copyNumber):
cta::TapeFileLocation::TapeFileLocation(
const uint64_t fSeq,
const uint64_t blockId,
const std::string &vid,
const uint8_t copyNb):
fSeq(fSeq),
blockId(blockId),
vid(vid),
copyNumber(copyNumber) {
copyNb(copyNb) {
}
......@@ -39,9 +39,9 @@ struct TapeFileLocation {
* @param fSeq The sequence number of the file.
* @param blockId The block identifier of the file.
* @param vid The vid of the tape containing the file. TODO: to be put in the mount object in the future
* @param copyNumber The copy number of the tape file. TODO: to be put in the mount object in the future
* @param copyNb The copy number of the tape file. TODO: to be put in the mount object in the future
*/
TapeFileLocation(const uint64_t fSeq, const uint64_t blockId, const std::string &vid, const uint8_t copyNumber);
TapeFileLocation(const uint64_t fSeq, const uint64_t blockId, const std::string &vid, const uint8_t copyNb);
/**
* The sequence number of the file.
......@@ -61,7 +61,7 @@ struct TapeFileLocation {
/**
* The copy number of the tape file. TODO: to be put in the mount object in the future
*/
uint8_t copyNumber;
uint8_t copyNb;
}; // struct TapeFileLocation
......
......@@ -969,14 +969,14 @@ void OStoreDB::queue(const cta::RetrieveToFileRequest& rqst) {
// Now add all the candidate tape copies to the request. With validation
for (auto tc=rqst.getTapeCopies().begin(); tc!=rqst.getTapeCopies().end(); tc++) {
// Check the tape copy copynumber (range = [1 - copyCount] )
if (tc->copyNumber > rqst.getTapeCopies().size() || tc->copyNumber < 1) {
if (tc->copyNb > rqst.getTapeCopies().size() || tc->copyNb < 1) {
throw TapeCopyNumberOutOfRange("In OStoreDB::queue(RetrieveToFile): copy number out of range");
}
}
// Add all the tape copies to the request
try {
for (auto tc=rqst.getTapeCopies().begin(); tc!=rqst.getTapeCopies().end(); tc++) {
rtfr.addJob(tc->copyNumber, tc->vid, vidToAddress.at(tc->vid));
rtfr.addJob(tc->copyNb, tc->vid, vidToAddress.at(tc->vid));
}
} catch (std::out_of_range &) {
throw NoSuchTape("In OStoreDB::queue(RetrieveToFile): tape not found");
......@@ -990,7 +990,7 @@ void OStoreDB::queue(const cta::RetrieveToFileRequest& rqst) {
{
// First tape copy is always better than nothing.
auto tc=rqst.getTapeCopies().begin();
selectedCopyNumber = tc->copyNumber;
selectedCopyNumber = tc->copyNb;
selectedVid = tc->vid;
// Get info for the tape.
{
......@@ -1007,7 +1007,7 @@ void OStoreDB::queue(const cta::RetrieveToFileRequest& rqst) {
t.fetch();
if (t.getJobsSummary().bytes > bestTapeQueuedBytes) {
bestTapeQueuedBytes = t.getJobsSummary().bytes;
selectedCopyNumber = tc->copyNumber;
selectedCopyNumber = tc->copyNb;
selectedVid = tc->vid;
}
}
......
......@@ -482,12 +482,12 @@ TEST_P(SchedulerDatabaseTest, getMountInfo) {
tcl.back().blockId = 666;
tcl.back().fSeq = 10;
tcl.back().vid = "Tape2";
tcl.back().copyNumber = 1;
tcl.back().copyNb = 1;
tcl.push_back(TapeFileLocation());
tcl.back().blockId = 111;
tcl.back().fSeq = 5;
tcl.back().vid = "Tape3";
tcl.back().copyNumber = 2;
tcl.back().copyNb = 2;
ASSERT_NO_THROW(db.queue(cta::RetrieveToFileRequest("cta:://cta/myfile", 1234, tcl, "eos://myeos/myeosfile", 10, cl)));
mountCandidates.reset(NULL);
ASSERT_NO_THROW(mountCandidates = db.getMountInfo());
......@@ -526,12 +526,12 @@ TEST_P(SchedulerDatabaseTest, getMountInfo) {
tcl2.back().blockId = 999;
tcl2.back().fSeq = 11;
tcl2.back().vid = "Tape3";
tcl2.back().copyNumber = 1;
tcl2.back().copyNb = 1;
tcl2.push_back(TapeFileLocation());
tcl2.back().blockId = 333;
tcl2.back().fSeq = 3;
tcl2.back().vid = "Tape2";
tcl2.back().copyNumber = 2;
tcl2.back().copyNb = 2;
db.queue(cta::RetrieveToFileRequest("cta:://cta/myfile2", 1234, tcl2, "eos://myeos/myeosfile2", 10, cl));
mountCandidates.reset(NULL);
ASSERT_NO_THROW(mountCandidates = db.getMountInfo());
......
......@@ -214,20 +214,16 @@ TEST_F(castor_tape_tapeserver_daemon_DataTransferSessionTest, DataTransferSessio
remoteFilePath << "file:" << m_tmpDir << "/test" << fseq;
remoteFilePaths.push_back(remoteFilePath.str());
// Create an entry in the archive namespace
// Create an archive file entry in the archive namespace
std::ostringstream archiveFilePath;
archiveFilePath << "/test" << fseq;
const mode_t archiveFileMode = 0655;
const uint64_t archiveFileSize = 256*1024;
ns.createFile(
ASSERT_NO_THROW(ns.createFile(
requester,
archiveFilePath.str(),
archiveFileMode,
archiveFileSize);
// TODO
// We need to add the tape file entry to the name server
archiveFileSize));
// Write the file to tape
std::unique_ptr<cta::RetrieveJob> ftr(new MockRetrieveJob());
......@@ -244,6 +240,23 @@ TEST_F(castor_tape_tapeserver_daemon_DataTransferSessionTest, DataTransferSessio
// Close the file
wf.close();
// Create tape file entry in the archive namespace
cta::NameServerTapeFile tapeFile;
tapeFile.copyNb = 1;
tapeFile.tapeFileLocation.fSeq = fseq;
tapeFile.tapeFileLocation.blockId = wf.getPosition();
tapeFile.tapeFileLocation.vid = volInfo.vid;
tapeFile.tapeFileLocation.copyNb = 1;
tapeFile.size = archiveFileSize;
tapeFile.compressedSize = archiveFileSize; // No compression
cta::Checksum tapeFileChecksum(cta::Checksum::CHECKSUMTYPE_ADLER32,
cta::ByteArray(cta::Utils::getAdler32(data, sizeof data)));
tapeFile.checksum = tapeFileChecksum;
ASSERT_NO_THROW(ns.addTapeFile(
requester,
archiveFilePath.str(),
tapeFile));
// Schedule the retrieval of the file
std::list<std::string> archiveFilePaths;
archiveFilePaths.push_back(archiveFilePath.str());
......@@ -346,19 +359,16 @@ TEST_F(castor_tape_tapeserver_daemon_DataTransferSessionTest, DataTransferSessio
remoteFilePath << "file:" << m_tmpDir << "/test" << fseq;
remoteFilePaths.push_back(remoteFilePath.str());
// Create an entry in the archive namespace
// Create an archive file entry in the archive namespace
std::ostringstream archiveFilePath;
archiveFilePath << "/test" << fseq;
const mode_t archiveFileMode = 0655;
const uint64_t archiveFileSize = 256*1024;
ns.createFile(
ASSERT_NO_THROW(ns.createFile(
requester,
archiveFilePath.str(),
archiveFileMode,
archiveFileSize);
// TODO
// We need to add the tape file entry to the name server with at least one entry
// pointing beyond the end of data
archiveFileSize));
// Write the file to tape
std::unique_ptr<cta::RetrieveJob> ftr(new MockRetrieveJob());
......@@ -375,6 +385,24 @@ TEST_F(castor_tape_tapeserver_daemon_DataTransferSessionTest, DataTransferSessio
// Close the file
wf.close();
// Create tape file entry in the archive namespace that is beyond the end
// of data
cta::NameServerTapeFile tapeFile;
tapeFile.copyNb = 1;
tapeFile.tapeFileLocation.fSeq = fseq + 10000;
tapeFile.tapeFileLocation.blockId = wf.getPosition() + 10000;
tapeFile.tapeFileLocation.vid = volInfo.vid;
tapeFile.tapeFileLocation.copyNb = 1;
tapeFile.size = archiveFileSize;
tapeFile.compressedSize = archiveFileSize; // No compression
cta::Checksum tapeFileChecksum(cta::Checksum::CHECKSUMTYPE_ADLER32,
cta::ByteArray(cta::Utils::getAdler32(data, sizeof data)));
tapeFile.checksum = tapeFileChecksum;
ASSERT_NO_THROW(ns.addTapeFile(
requester,
archiveFilePath.str(),
tapeFile));
// Schedule the retrieval of the file
std::list<std::string> archiveFilePaths;
archiveFilePaths.push_back(archiveFilePath.str());
......@@ -527,19 +555,16 @@ TEST_F(castor_tape_tapeserver_daemon_DataTransferSessionTest, DataTransferSessio
remoteFilePath << "file:" << m_tmpDir << "/test" << fseq;
remoteFilePaths.push_back(remoteFilePath.str());
// Create an entry in the archive namespace
// Create an archive file entry in the archive namespace
std::ostringstream archiveFilePath;
archiveFilePath << "/test" << fseq;
const mode_t archiveFileMode = 0655;
const uint64_t archiveFileSize = 256*1024;
ns.createFile(
ASSERT_NO_THROW(ns.createFile(
requester,
archiveFilePath.str(),
archiveFileMode,
archiveFileSize);
// TODO
// We need to add the tape file entry to the name server with at least one entry
// pointing beyond the end of data
archiveFileSize));
// Write the file to tape
std::unique_ptr<cta::RetrieveJob> ftr(new MockRetrieveJob());
......@@ -556,6 +581,23 @@ TEST_F(castor_tape_tapeserver_daemon_DataTransferSessionTest, DataTransferSessio
// Close the file
wf.close();
// Create tape file entry in the archive namespace
cta::NameServerTapeFile tapeFile;
tapeFile.copyNb = 1;
tapeFile.tapeFileLocation.fSeq = fseq;
tapeFile.tapeFileLocation.blockId = wf.getPosition();
tapeFile.tapeFileLocation.vid = volInfo.vid;
tapeFile.tapeFileLocation.copyNb = 1;
tapeFile.size = archiveFileSize;
tapeFile.compressedSize = archiveFileSize; // No compression
cta::Checksum tapeFileChecksum(cta::Checksum::CHECKSUMTYPE_ADLER32,
cta::ByteArray(cta::Utils::getAdler32(data, sizeof data)));
tapeFile.checksum = tapeFileChecksum;
ASSERT_NO_THROW(ns.addTapeFile(
requester,
archiveFilePath.str(),
tapeFile));
// Schedule the retrieval of the file
std::list<std::string> archiveFilePaths;
archiveFilePaths.push_back(archiveFilePath.str());
......
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