Commit 9d2b9f3d authored by Eric Cano's avatar Eric Cano
Browse files

Partially fixed data transfer session unit test.

Fixed libraby linking which led to multiple initialization of static variable (detected by valgrind's drd).
Worked around cmake's failing dependency management for generated protocol buffer sources (double make in spec file).
Partially fixed the first data transfer session unit test (still disabled).
Fixed a typo in an error message.
parent 7c128290
...@@ -2980,7 +2980,7 @@ common::dataStructures::RetrieveFileQueueCriteria RdbmsCatalogue::prepareToRetri ...@@ -2980,7 +2980,7 @@ common::dataStructures::RetrieveFileQueueCriteria RdbmsCatalogue::prepareToRetri
mountPolicy = mountPolicies.requesterGroupMountPolicies.front(); mountPolicy = mountPolicies.requesterGroupMountPolicies.front();
} else { } else {
exception::UserError ue; exception::UserError ue;
ue.getMessage() << "Cannot prepare to retrieve the file with archive file ID because no mount policy exists " ue.getMessage() << "Cannot prepare to retrieve the file with archive file ID because no mount policy exists "
"for " + user.name + ":" + user.group; "for " + user.name + ":" + user.group;
throw ue; throw ue;
} }
......
...@@ -68,4 +68,3 @@ namespace cta { ...@@ -68,4 +68,3 @@ namespace cta {
}; };
} }
} }
...@@ -56,6 +56,8 @@ mkdir -p build ...@@ -56,6 +56,8 @@ mkdir -p build
cd build cd build
# The cmake step does the selection between client/server compilation or just client # The cmake step does the selection between client/server compilation or just client
cmake .. -DCOMPILE_PACKAGING:STRING=0 cmake .. -DCOMPILE_PACKAGING:STRING=0
# Workaround for the inability of cmake to handle properly the dependencies to generated code.
%{__make} -s %{_smp_mflags} -k || true
%{__make} -s %{_smp_mflags} %{__make} -s %{_smp_mflags}
%install %install
......
...@@ -50,4 +50,3 @@ namespace castor { ...@@ -50,4 +50,3 @@ namespace castor {
}; };
} }
} }
...@@ -3,16 +3,16 @@ cmake_minimum_required (VERSION 2.6) ...@@ -3,16 +3,16 @@ cmake_minimum_required (VERSION 2.6)
include_directories(${PROJECT_SOURCE_DIR}/tapeserver) include_directories(${PROJECT_SOURCE_DIR}/tapeserver)
include_directories(${PROJECT_SOURCE_DIR}/tapeserver/h) include_directories(${PROJECT_SOURCE_DIR}/tapeserver/h)
add_library (ctaserverutils #add_library (ctaserverutils
ProcessCapDummy.cpp # ProcessCapDummy.cpp
Semaphores.cpp # Semaphores.cpp
Mutex.cpp # Mutex.cpp
Threading.cpp # Threading.cpp
ProcessCap.cpp # ProcessCap.cpp
SmartCap.cpp # SmartCap.cpp
Daemon.cpp) # Daemon.cpp)
#
target_link_libraries(ctaserverutils cap ctautils) #target_link_libraries(ctaserverutils cap ctautils)
add_library (ctaserverunittests SHARED add_library (ctaserverunittests SHARED
AtomicCounterTest.cpp AtomicCounterTest.cpp
...@@ -23,6 +23,6 @@ add_library (ctaserverunittests SHARED ...@@ -23,6 +23,6 @@ add_library (ctaserverunittests SHARED
ThreadingMTTests.cpp ThreadingMTTests.cpp
ThreadingTests.cpp) ThreadingTests.cpp)
target_link_libraries (ctaserverunittests) target_link_libraries (ctaserverunittests ctautils)
install(TARGETS ctaserverunittests DESTINATION usr/${CMAKE_INSTALL_LIBDIR}) install(TARGETS ctaserverunittests DESTINATION usr/${CMAKE_INSTALL_LIBDIR})
...@@ -97,13 +97,13 @@ endif(CMAKE_COMPILER_IS_GNUCC) ...@@ -97,13 +97,13 @@ endif(CMAKE_COMPILER_IS_GNUCC)
add_library(ctaTapeServerDaemon add_library(ctaTapeServerDaemon
${CTATAPESERVERDAEMON_LIBRARY_SRCS}) ${CTATAPESERVERDAEMON_LIBRARY_SRCS})
target_link_libraries(ctaTapeServerDaemon ctamessages ctatapereactor ctacommon ctaremotens protobuf ctascheduler ctalegacymsg ctaserverutils ctacatalogue) target_link_libraries(ctaTapeServerDaemon ctamessages ctatapereactor ctacommon ctaremotens protobuf ctascheduler ctalegacymsg ctacatalogue)
add_dependencies(ctaTapeServerDaemon ctamessagesprotobuf) add_dependencies(ctaTapeServerDaemon ctamessagesprotobuf)
add_executable(cta-tapeserverd TapeDaemon.cpp) add_executable(cta-tapeserverd TapeDaemon.cpp)
target_link_libraries(cta-tapeserverd ctaTapeServerDaemon SCSI System Utils target_link_libraries(cta-tapeserverd ctaTapeServerDaemon SCSI System Utils
File TapeDrive ctacommon ctatapereactor ${LIBCAP_LIB} ${ZLIB_LIBRARIES} File TapeDrive ctacommon ctatapereactor ${LIBCAP_LIB} ${ZLIB_LIBRARIES}
ctamessages zmq ctaio ctautils ctaserverutils) ctamessages zmq ctaio ctautils)
#install (TARGETS cta-tapeserverd DESTINATION usr/bin) #install (TARGETS cta-tapeserverd DESTINATION usr/bin)
add_library(ctatapeserverdaemonutils SHARED add_library(ctatapeserverdaemonutils SHARED
...@@ -131,7 +131,6 @@ add_library(ctatapeserverdaemonunittests SHARED ...@@ -131,7 +131,6 @@ add_library(ctatapeserverdaemonunittests SHARED
target_link_libraries(ctatapeserverdaemonunittests target_link_libraries(ctatapeserverdaemonunittests
ctamediachangerutils ctamediachangerutils
ctamessagesutils ctamessagesutils
ctaserverutils
ctatapeserverdaemonutils) ctatapeserverdaemonutils)
#ctaschedulerutils #ctaschedulerutils
......
...@@ -291,7 +291,7 @@ protected: ...@@ -291,7 +291,7 @@ protected:
const cta::common::dataStructures::SecurityIdentity s_adminOnAdminHost = { "admin1", "host1" }; const cta::common::dataStructures::SecurityIdentity s_adminOnAdminHost = { "admin1", "host1" };
const std::string s_tapePoolName = "TestTapePool"; const std::string s_tapePoolName = "TestTapePool";
const std::string s_libraryName = "TestLogicalLibrary"; const std::string s_libraryName = "TestLogicalLibrary";
const std::string s_vid = "TestVid"; const std::string s_vid = "TstVid"; // We really need size <= 6 characters due to tape label format.
//TempFile m_tempSqliteFile; //TempFile m_tempSqliteFile;
/** /**
* Temporary directory created with mkdtemp that will be used to contain the * Temporary directory created with mkdtemp that will be used to contain the
...@@ -337,21 +337,24 @@ TEST_P(DataTransferSessionTest, DISABLED_DataTransferSessionGooddayRecall) { ...@@ -337,21 +337,24 @@ TEST_P(DataTransferSessionTest, DISABLED_DataTransferSessionGooddayRecall) {
// files can be tested for at the end of the test // files can be tested for at the end of the test
std::list<std::string> remoteFilePaths; std::list<std::string> remoteFilePaths;
// 5) Create the tapepool, library and tape for the scheduler. // 5) Create the environment for the migration to happen (library + tape)
// Make mounts immediate. const std::string libraryComment = "Library comment";
// scheduler.createAdminUserWithoutAuthorizingRequester(requester, requester.getUser(), ""); ASSERT_NO_THROW(catalogue.createLogicalLibrary(s_adminOnAdminHost, s_libraryName,
// scheduler.createAdminHostWithoutAuthorizingRequester(requester, requester.getHost(), ""); libraryComment));
// scheduler.createTapePool(requester, "TapePool", 1, ""); {
// cta::MountCriteria immediateMount; auto libraries = catalogue.getLogicalLibraries();
// immediateMount.maxAge = 0; ASSERT_EQ(1, libraries.size());
// immediateMount.maxBytesQueued = 1; ASSERT_EQ(s_libraryName, libraries.front().name);
// immediateMount.maxFilesQueued = 1; ASSERT_EQ(libraryComment, libraries.front().comment);
// immediateMount.quota = 10; }
// scheduler.setTapePoolMountCriteria("TapePool", cta::MountCriteriaByDirection(immediateMount, immediateMount)); const uint64_t capacityInBytes = 12345678;
// scheduler.createLogicalLibrary(requester, "T10KD6", ""); const std::string tapeComment = "Tape comment";
// scheduler.createTape(requester, "V12345", "T10KD6", "TapePool", 10*1000*1000, ""); bool notDisabled = false;
bool notFull = false;
catalogue.createTape(s_adminOnAdminHost, s_vid, s_libraryName,
s_tapePoolName, "", capacityInBytes, notDisabled, notFull, tapeComment);
// 5) Prepare files for reading by writing them to the mock system // 6) Prepare files for reading by writing them to the mock system
{ {
// Label the tape // Label the tape
castor::tape::tapeFile::LabelSession ls(*mockSys.fake.m_pathToDrive["/dev/nst0"], castor::tape::tapeFile::LabelSession ls(*mockSys.fake.m_pathToDrive["/dev/nst0"],
...@@ -396,17 +399,26 @@ TEST_P(DataTransferSessionTest, DISABLED_DataTransferSessionGooddayRecall) { ...@@ -396,17 +399,26 @@ TEST_P(DataTransferSessionTest, DISABLED_DataTransferSessionGooddayRecall) {
tapeFileWritten.checksumType="ADLER32"; tapeFileWritten.checksumType="ADLER32";
tapeFileWritten.checksumValue=cta::utils::getAdler32String(data, archiveFileSize); tapeFileWritten.checksumValue=cta::utils::getAdler32String(data, archiveFileSize);
tapeFileWritten.vid=volInfo.vid; tapeFileWritten.vid=volInfo.vid;
tapeFileWritten.blockId=0;
tapeFileWritten.size=archiveFileSize; tapeFileWritten.size=archiveFileSize;
tapeFileWritten.fSeq=fseq; tapeFileWritten.fSeq=fseq;
tapeFileWritten.copyNb=1; tapeFileWritten.copyNb=1;
tapeFileWritten.compressedSize=archiveFileSize; // No compression tapeFileWritten.compressedSize=archiveFileSize; // No compression
tapeFileWritten.diskInstance = s_diskInstance;
tapeFileWritten.diskFileId = fseq;
tapeFileWritten.diskFilePath = remoteFilePath.str();
tapeFileWritten.diskFileUser = s_userName;
tapeFileWritten.diskFileGroup = "someGroup";
tapeFileWritten.diskFileRecoveryBlob = "B106";
tapeFileWritten.storageClassName = s_storageClassName;
tapeFileWritten.tapeDrive = "drive0";
catalogue.fileWrittenToTape(tapeFileWritten); catalogue.fileWrittenToTape(tapeFileWritten);
// Schedule the retrieval of the file // Schedule the retrieval of the file
cta::common::dataStructures::SecurityIdentity sid; cta::common::dataStructures::SecurityIdentity sid;
cta::common::dataStructures::RetrieveRequest rReq; cta::common::dataStructures::RetrieveRequest rReq;
rReq.archiveFileID=fseq; rReq.archiveFileID=fseq;
rReq.requester.name = s_userName;
rReq.requester.group = "someGroup";
std::list<std::string> archiveFilePaths; std::list<std::string> archiveFilePaths;
archiveFilePaths.push_back(archiveFilePath.str()); archiveFilePaths.push_back(archiveFilePath.str());
scheduler.queueRetrieve(sid, rReq); scheduler.queueRetrieve(sid, rReq);
...@@ -414,7 +426,7 @@ TEST_P(DataTransferSessionTest, DISABLED_DataTransferSessionGooddayRecall) { ...@@ -414,7 +426,7 @@ TEST_P(DataTransferSessionTest, DISABLED_DataTransferSessionGooddayRecall) {
} }
// 6) Create the data transfer session // 6) Create the data transfer session
DriveConfig driveConfig("T10D6116", "T10KD6", "/dev/tape_T10D6116", "manual"); DriveConfig driveConfig("T10D6116", "TestLogicalLibrary", "/dev/tape_T10D6116", "manual");
DataTransferConfig castorConf; DataTransferConfig castorConf;
castorConf.bufsz = 1024*1024; // 1 MB memory buffers castorConf.bufsz = 1024*1024; // 1 MB memory buffers
castorConf.nbBufs = 10; castorConf.nbBufs = 10;
...@@ -427,14 +439,16 @@ TEST_P(DataTransferSessionTest, DISABLED_DataTransferSessionGooddayRecall) { ...@@ -427,14 +439,16 @@ TEST_P(DataTransferSessionTest, DISABLED_DataTransferSessionGooddayRecall) {
castor::mediachanger::MediaChangerFacade mc(acs, mmc, rmc); castor::mediachanger::MediaChangerFacade mc(acs, mmc, rmc);
castor::server::ProcessCap capUtils; castor::server::ProcessCap capUtils;
castor::messages::TapeserverProxyDummy initialProcess; castor::messages::TapeserverProxyDummy initialProcess;
DataTransferSession sess("tapeHost", logger, mockSys, castor::tape::tapeserver::daemon::DataTransferSession sess("tapeHost", logger, mockSys,
driveConfig, mc, initialProcess, capUtils, castorConf, scheduler); driveConfig, mc, initialProcess, capUtils, castorConf, scheduler);
std::cout << typeid(sess).name() << std::endl;
// 7) Run the data transfer session // 7) Run the data transfer session
ASSERT_NO_THROW(sess.execute()); sess.execute();
// 8) Check the session git the correct VID // 8) Check the session git the correct VID
ASSERT_EQ("V12345", sess.getVid()); ASSERT_EQ(s_vid, sess.getVid());
// 9) Check the remote files exist and have the correct size // 9) Check the remote files exist and have the correct size
for(auto pathItor = remoteFilePaths.cbegin(); pathItor != for(auto pathItor = remoteFilePaths.cbegin(); pathItor !=
......
...@@ -42,7 +42,7 @@ endif(CMAKE_COMPILER_IS_GNUCC) ...@@ -42,7 +42,7 @@ endif(CMAKE_COMPILER_IS_GNUCC)
add_library(File add_library(File
${TAPESERVER_FILE_LIBRARY_SRCS}) ${TAPESERVER_FILE_LIBRARY_SRCS})
target_link_libraries (File XrdCl cryptopp ctaserverutils) target_link_libraries (File XrdCl cryptopp)
if(CMAKE_COMPILER_IS_GNUCC) if(CMAKE_COMPILER_IS_GNUCC)
if(GCC_VERSION_GE_4_8_0) if(GCC_VERSION_GE_4_8_0)
......
...@@ -46,9 +46,18 @@ set (UTILS_LIB_SRC_FILES ...@@ -46,9 +46,18 @@ set (UTILS_LIB_SRC_FILES
../BaseObject.cpp ../BaseObject.cpp
../Services.cpp ../Services.cpp
../Factories.cpp ../Factories.cpp
../System.cpp) ../System.cpp
../server/ProcessCapDummy.cpp
../server/Semaphores.cpp
../server/Mutex.cpp
../server/Threading.cpp
../server/ProcessCap.cpp
../server/SmartCap.cpp
../server/Daemon.cpp)
add_library (ctautils ${UTILS_LIB_SRC_FILES}) add_library (ctautils SHARED ${UTILS_LIB_SRC_FILES})
target_link_libraries(ctautils castorlog)
add_library (ctautilsunittests SHARED add_library (ctautilsunittests SHARED
SmartArrayPtrTest.cpp SmartArrayPtrTest.cpp
......
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