Commit ff8896f5 authored by Cedric Caffy's avatar Cedric Caffy
Browse files

Rebased on top of master + Catalogue::getTapePools() adapted to comply with the new tape states

- Removed the counting of the readonly tapes as they don't exist
- Count the ACTIVE tapes instead of not disabled ones
- Repack disabled tape system test now undisables the tape after having
  reclaimed it
parent a567b179
......@@ -1952,19 +1952,31 @@ TEST_P(cta_catalogue_CatalogueTest, createTapePool_tapes_of_mixed_state) {
ASSERT_EQ(0, pool.dataBytes);
ASSERT_EQ(0, pool.nbPhysicalFiles);
}
cta::catalogue::TapeSearchCriteria criteria;
criteria.vid = m_tape1.vid;
ASSERT_EQ(0,m_catalogue->getTapes(criteria).size());
 
m_catalogue->createTape(m_admin, m_tape1);
 
auto tape_disabled_01 = m_tape1;
tape_disabled_01.vid = "D000001";
tape_disabled_01.disabled = true;
tape_disabled_01.state = common::dataStructures::Tape::DISABLED;
tape_disabled_01.stateReason = "unit Test";
m_catalogue->createTape(m_admin, tape_disabled_01);
 
auto tape_disabled_02 = m_tape1;
tape_disabled_02.vid = "D000002";
tape_disabled_02.disabled = true;
tape_disabled_02.state = common::dataStructures::Tape::DISABLED;
tape_disabled_02.stateReason = "unit Test";
m_catalogue->createTape(m_admin, tape_disabled_02);
 
auto tape_broken_01 = m_tape1;
tape_broken_01.vid = "B000002";
tape_broken_01.state = common::dataStructures::Tape::BROKEN;
tape_broken_01.stateReason = "unit Test";
m_catalogue->createTape(m_admin, tape_broken_01);
auto tape_full_01 = m_tape1;
tape_full_01.vid = "F000001";
tape_full_01.full = true;
......@@ -1980,64 +1992,30 @@ TEST_P(cta_catalogue_CatalogueTest, createTapePool_tapes_of_mixed_state) {
tape_full_03.full = true;
m_catalogue->createTape(m_admin, tape_full_03);
 
auto tape_readOnly_01 = m_tape1;
tape_readOnly_01.vid = "RO00001";
tape_readOnly_01.readOnly = true;
m_catalogue->createTape(m_admin, tape_readOnly_01);
auto tape_readOnly_02 = m_tape1;
tape_readOnly_02.vid = "RO00002";
tape_readOnly_02.readOnly = true;
m_catalogue->createTape(m_admin, tape_readOnly_02);
auto tape_readOnly_03 = m_tape1;
tape_readOnly_03.vid = "RO00003";
tape_readOnly_03.readOnly = true;
m_catalogue->createTape(m_admin, tape_readOnly_03);
auto tape_readOnly_04 = m_tape1;
tape_readOnly_04.vid = "RO00004";
tape_readOnly_04.readOnly = true;
m_catalogue->createTape(m_admin, tape_readOnly_04);
auto tape_disabled_full_readOnly_01 = m_tape1;
tape_disabled_full_readOnly_01.vid = "DFRO001";
tape_disabled_full_readOnly_01.disabled = true;
tape_disabled_full_readOnly_01.full = true;
tape_disabled_full_readOnly_01.readOnly = true;
m_catalogue->createTape(m_admin, tape_disabled_full_readOnly_01);
auto tape_disabled_full_readOnly_02 = m_tape1;
tape_disabled_full_readOnly_02.vid = "DFRO002";
tape_disabled_full_readOnly_02.disabled = true;
tape_disabled_full_readOnly_02.full = true;
tape_disabled_full_readOnly_02.readOnly = true;
m_catalogue->createTape(m_admin, tape_disabled_full_readOnly_02);
auto tape_disabled_full_readOnly_03 = m_tape1;
tape_disabled_full_readOnly_03.vid = "DFRO003";
tape_disabled_full_readOnly_03.disabled = true;
tape_disabled_full_readOnly_03.full = true;
tape_disabled_full_readOnly_03.readOnly = true;
m_catalogue->createTape(m_admin, tape_disabled_full_readOnly_03);
auto tape_disabled_full_readOnly_04 = m_tape1;
tape_disabled_full_readOnly_04.vid = "DFRO004";
tape_disabled_full_readOnly_04.disabled = true;
tape_disabled_full_readOnly_04.full = true;
tape_disabled_full_readOnly_04.readOnly = true;
m_catalogue->createTape(m_admin, tape_disabled_full_readOnly_04);
auto tape_disabled_full_readOnly_05 = m_tape1;
tape_disabled_full_readOnly_05.vid = "DFRO005";
tape_disabled_full_readOnly_05.disabled = true;
tape_disabled_full_readOnly_05.full = true;
tape_disabled_full_readOnly_05.readOnly = true;
m_catalogue->createTape(m_admin, tape_disabled_full_readOnly_05);
auto tape_broken_full_01 = m_tape1;
tape_broken_full_01.vid = "BFO001";
tape_broken_full_01.state = common::dataStructures::Tape::BROKEN;
tape_broken_full_01.stateReason = "unit Test";
tape_broken_full_01.full = true;
m_catalogue->createTape(m_admin, tape_broken_full_01);
auto tape_disabled_full_01 = m_tape1;
tape_disabled_full_01.vid = "DFO001";
tape_disabled_full_01.state = common::dataStructures::Tape::DISABLED;
tape_disabled_full_01.stateReason = "unit Test";
tape_disabled_full_01.full = true;
m_catalogue->createTape(m_admin, tape_disabled_full_01);
auto tape_disabled_full_02 = m_tape1;
tape_disabled_full_02.vid = "DFO002";
tape_disabled_full_02.full = true;
tape_disabled_full_02.state = common::dataStructures::Tape::DISABLED;
tape_disabled_full_02.stateReason = "unit Test";
m_catalogue->createTape(m_admin, tape_disabled_full_02);
 
const auto tapes = m_catalogue->getTapes();
 
ASSERT_EQ(15, tapes.size());
ASSERT_EQ(10, tapes.size());
 
{
const auto pools = m_catalogue->getTapePools();
......@@ -2046,13 +2024,12 @@ TEST_P(cta_catalogue_CatalogueTest, createTapePool_tapes_of_mixed_state) {
const auto &pool = pools.front();
ASSERT_EQ(m_tape1.tapePoolName, pool.name);
ASSERT_EQ(m_vo.name, pool.vo.name);
ASSERT_EQ(15, pool.nbTapes);
ASSERT_EQ(15, pool.nbEmptyTapes);
ASSERT_EQ(7, pool.nbDisabledTapes);
ASSERT_EQ(8, pool.nbFullTapes);
ASSERT_EQ(9, pool.nbReadOnlyTapes);
ASSERT_EQ(10, pool.nbTapes);
ASSERT_EQ(10, pool.nbEmptyTapes);
ASSERT_EQ(4, pool.nbDisabledTapes);
ASSERT_EQ(6, pool.nbFullTapes);
ASSERT_EQ(1, pool.nbWritableTapes);
ASSERT_EQ(15 * m_mediaType.capacityInBytes, pool.capacityBytes);
ASSERT_EQ(10 * m_mediaType.capacityInBytes, pool.capacityBytes);
ASSERT_EQ(0, pool.dataBytes);
ASSERT_EQ(0, pool.nbPhysicalFiles);
}
......@@ -2063,13 +2040,12 @@ TEST_P(cta_catalogue_CatalogueTest, createTapePool_tapes_of_mixed_state) {
 
ASSERT_EQ(m_tape1.tapePoolName, pool->name);
ASSERT_EQ(m_vo.name, pool->vo.name);
ASSERT_EQ(15, pool->nbTapes);
ASSERT_EQ(15, pool->nbEmptyTapes);
ASSERT_EQ(7, pool->nbDisabledTapes);
ASSERT_EQ(8, pool->nbFullTapes);
ASSERT_EQ(9, pool->nbReadOnlyTapes);
ASSERT_EQ(10, pool->nbTapes);
ASSERT_EQ(10, pool->nbEmptyTapes);
ASSERT_EQ(4, pool->nbDisabledTapes);
ASSERT_EQ(6, pool->nbFullTapes);
ASSERT_EQ(1, pool->nbWritableTapes);
ASSERT_EQ(15 * m_mediaType.capacityInBytes, pool->capacityBytes);
ASSERT_EQ(10 * m_mediaType.capacityInBytes, pool->capacityBytes);
ASSERT_EQ(0, pool->dataBytes);
ASSERT_EQ(0, pool->nbPhysicalFiles);
}
......@@ -4879,14 +4855,16 @@ TEST_P(cta_catalogue_CatalogueTest, deleteNonEmptyTape) {
}
 
const uint64_t fileSize = 1234 * 1000000000UL;
const uint64_t archiveFileId = 1234;
const std::string diskFileId = "5678";
{
auto file1WrittenUP=cta::make_unique<cta::catalogue::TapeFileWritten>();
auto & file1Written = *file1WrittenUP;
std::set<cta::catalogue::TapeItemWrittenPointer> file1WrittenSet;
file1WrittenSet.insert(file1WrittenUP.release());
file1Written.archiveFileId = 1234;
file1Written.archiveFileId = archiveFileId;
file1Written.diskInstance = diskInstance;
file1Written.diskFileId = "5678";
file1Written.diskFileId = diskFileId;
file1Written.diskFileOwnerUid = PUBLIC_DISK_USER;
file1Written.diskFileGid = PUBLIC_DISK_GROUP;
file1Written.size = fileSize;
......@@ -5557,8 +5535,8 @@ TEST_P(cta_catalogue_CatalogueTest, modifyTapeState) {
}
{
auto tapes = m_catalogue->getAllTapes();
auto tape = tapes.at(vid);
auto vidToTapeMap = m_catalogue->getTapesByVid({vid});
auto tape = vidToTapeMap.at(vid);
ASSERT_EQ(vid,tape.vid);
ASSERT_EQ(common::dataStructures::Tape::BROKEN,tape.state);
ASSERT_EQ(reason,tape.stateReason);
......@@ -9422,7 +9400,7 @@ TEST_P(cta_catalogue_CatalogueTest, filesWrittenToTape_many_archive_files) {
ASSERT_EQ(nbArchiveFiles, pool.nbPhysicalFiles);
}
 
m_catalogue->setTapeDisabled(m_admin, tape1.vid, true);
m_catalogue->setTapeDisabled(m_admin, tape1.vid, "unit Test");
 
{
const auto pools = m_catalogue->getTapePools();
......@@ -9444,7 +9422,7 @@ TEST_P(cta_catalogue_CatalogueTest, filesWrittenToTape_many_archive_files) {
ASSERT_EQ(nbArchiveFiles, pool.nbPhysicalFiles);
}
 
m_catalogue->setTapeDisabled(m_admin, tape1.vid, false);
m_catalogue->modifyTapeState(m_admin, tape1.vid, common::dataStructures::Tape::ACTIVE,cta::nullopt);
 
{
const auto pools = m_catalogue->getTapePools();
......@@ -9509,50 +9487,6 @@ TEST_P(cta_catalogue_CatalogueTest, filesWrittenToTape_many_archive_files) {
ASSERT_EQ(nbArchiveFiles * archiveFileSize, pool.dataBytes);
ASSERT_EQ(nbArchiveFiles, pool.nbPhysicalFiles);
}
m_catalogue->setTapeReadOnly(m_admin, tape1.vid, true);
{
const auto pools = m_catalogue->getTapePools();
ASSERT_EQ(2, pools.size());
const auto tapePoolMap = tapePoolListToMap(pools);
auto tapePoolMapItor = tapePoolMap.find(tapePoolName1);
ASSERT_NE(tapePoolMapItor, tapePoolMap.end());
const auto &pool = tapePoolMapItor->second;
ASSERT_EQ(tapePoolName1, pool.name);
ASSERT_EQ(1, pool.nbTapes);
ASSERT_EQ(0, pool.nbEmptyTapes);
ASSERT_EQ(0, pool.nbDisabledTapes);
ASSERT_EQ(0, pool.nbFullTapes);
ASSERT_EQ(1, pool.nbReadOnlyTapes);
ASSERT_EQ(0, pool.nbWritableTapes);
ASSERT_EQ(m_mediaType.capacityInBytes, pool.capacityBytes);
ASSERT_EQ(nbArchiveFiles * archiveFileSize, pool.dataBytes);
ASSERT_EQ(nbArchiveFiles, pool.nbPhysicalFiles);
}
m_catalogue->setTapeReadOnly(m_admin, tape1.vid, false);
{
const auto pools = m_catalogue->getTapePools();
ASSERT_EQ(2, pools.size());
const auto tapePoolMap = tapePoolListToMap(pools);
auto tapePoolMapItor = tapePoolMap.find(tapePoolName1);
ASSERT_NE(tapePoolMapItor, tapePoolMap.end());
const auto &pool = tapePoolMapItor->second;
ASSERT_EQ(tapePoolName1, pool.name);
ASSERT_EQ(1, pool.nbTapes);
ASSERT_EQ(0, pool.nbEmptyTapes);
ASSERT_EQ(0, pool.nbDisabledTapes);
ASSERT_EQ(0, pool.nbFullTapes);
ASSERT_EQ(0, pool.nbReadOnlyTapes);
ASSERT_EQ(1, pool.nbWritableTapes);
ASSERT_EQ(m_mediaType.capacityInBytes, pool.capacityBytes);
ASSERT_EQ(nbArchiveFiles * archiveFileSize, pool.dataBytes);
ASSERT_EQ(nbArchiveFiles, pool.nbPhysicalFiles);
}
}
 
TEST_P(cta_catalogue_CatalogueTest, DISABLED_concurrent_filesWrittenToTape_many_archive_files) {
......
......@@ -2025,10 +2025,9 @@ std::list<TapePool> RdbmsCatalogue::getTapePools() const {
"COALESCE(COUNT(TAPE.VID), 0) AS NB_TAPES,"
"COALESCE(SUM(CASE WHEN TAPE.DATA_IN_BYTES = 0 THEN 1 ELSE 0 END), 0) AS NB_EMPTY_TAPES,"
"COALESCE(SUM(CASE WHEN TAPE.IS_DISABLED <> '0' THEN 1 ELSE 0 END), 0) AS NB_DISABLED_TAPES,"
"COALESCE(SUM(CASE WHEN TAPE.TAPE_STATE = :STATE_DISABLED THEN 1 ELSE 0 END), 0) AS NB_DISABLED_TAPES,"
"COALESCE(SUM(CASE WHEN TAPE.IS_FULL <> '0' THEN 1 ELSE 0 END), 0) AS NB_FULL_TAPES,"
"COALESCE(SUM(CASE WHEN TAPE.IS_READ_ONLY <> '0' THEN 1 ELSE 0 END), 0) AS NB_READ_ONLY_TAPES,"
"COALESCE(SUM(CASE WHEN TAPE.IS_DISABLED = '0' AND TAPE.IS_FULL = '0' AND TAPE.IS_READ_ONLY = '0' THEN 1 ELSE 0 END), 0) AS NB_WRITABLE_TAPES,"
"COALESCE(SUM(CASE WHEN TAPE.TAPE_STATE = :STATE_ACTIVE AND TAPE.IS_FULL = '0' THEN 1 ELSE 0 END), 0) AS NB_WRITABLE_TAPES,"
"COALESCE(SUM(MEDIA_TYPE.CAPACITY_IN_BYTES), 0) AS CAPACITY_IN_BYTES,"
"COALESCE(SUM(TAPE.DATA_IN_BYTES), 0) AS DATA_IN_BYTES,"
"COALESCE(SUM(TAPE.LAST_FSEQ), 0) AS NB_PHYSICAL_FILES,"
......@@ -2068,6 +2067,8 @@ std::list<TapePool> RdbmsCatalogue::getTapePools() const {
auto conn = m_connPool.getConn();
auto stmt = conn.createStmt(sql);
stmt.bindString(":STATE_DISABLED",common::dataStructures::Tape::stateToString(common::dataStructures::Tape::DISABLED));
stmt.bindString(":STATE_ACTIVE",common::dataStructures::Tape::stateToString(common::dataStructures::Tape::ACTIVE));
auto rset = stmt.executeQuery();
while (rset.next()) {
TapePool pool;
......@@ -2081,7 +2082,6 @@ std::list<TapePool> RdbmsCatalogue::getTapePools() const {
pool.nbEmptyTapes = rset.columnUint64("NB_EMPTY_TAPES");
pool.nbDisabledTapes = rset.columnUint64("NB_DISABLED_TAPES");
pool.nbFullTapes = rset.columnUint64("NB_FULL_TAPES");
pool.nbReadOnlyTapes = rset.columnUint64("NB_READ_ONLY_TAPES");
pool.nbWritableTapes = rset.columnUint64("NB_WRITABLE_TAPES");
pool.capacityBytes = rset.columnUint64("CAPACITY_IN_BYTES");
pool.dataBytes = rset.columnUint64("DATA_IN_BYTES");
......@@ -2121,10 +2121,9 @@ cta::optional<TapePool> RdbmsCatalogue::getTapePool(const std::string &tapePoolN
"COALESCE(COUNT(TAPE.VID), 0) AS NB_TAPES,"
"COALESCE(SUM(CASE WHEN TAPE.DATA_IN_BYTES = 0 THEN 1 ELSE 0 END), 0) AS NB_EMPTY_TAPES,"
"COALESCE(SUM(CASE WHEN TAPE.IS_DISABLED <> '0' THEN 1 ELSE 0 END), 0) AS NB_DISABLED_TAPES,"
"COALESCE(SUM(CASE WHEN TAPE.TAPE_STATE = :STATE_DISABLED THEN 1 ELSE 0 END), 0) AS NB_DISABLED_TAPES,"
"COALESCE(SUM(CASE WHEN TAPE.IS_FULL <> '0' THEN 1 ELSE 0 END), 0) AS NB_FULL_TAPES,"
"COALESCE(SUM(CASE WHEN TAPE.IS_READ_ONLY <> '0' THEN 1 ELSE 0 END), 0) AS NB_READ_ONLY_TAPES,"
"COALESCE(SUM(CASE WHEN TAPE.IS_DISABLED = '0' AND TAPE.IS_FULL = '0' AND TAPE.IS_READ_ONLY = '0' THEN 1 ELSE 0 END), 0) AS NB_WRITABLE_TAPES,"
"COALESCE(SUM(CASE WHEN TAPE.TAPE_STATE = :STATE_ACTIVE AND TAPE.IS_FULL = '0' THEN 1 ELSE 0 END), 0) AS NB_WRITABLE_TAPES,"
"COALESCE(SUM(MEDIA_TYPE.CAPACITY_IN_BYTES), 0) AS CAPACITY_IN_BYTES,"
"COALESCE(SUM(TAPE.DATA_IN_BYTES), 0) AS DATA_IN_BYTES,"
"COALESCE(SUM(TAPE.LAST_FSEQ), 0) AS NB_PHYSICAL_FILES,"
......@@ -2167,6 +2166,9 @@ cta::optional<TapePool> RdbmsCatalogue::getTapePool(const std::string &tapePoolN
auto conn = m_connPool.getConn();
auto stmt = conn.createStmt(sql);
stmt.bindString(":TAPE_POOL_NAME", tapePoolName);
stmt.bindString(":STATE_DISABLED",common::dataStructures::Tape::stateToString(common::dataStructures::Tape::DISABLED));
stmt.bindString(":STATE_ACTIVE",common::dataStructures::Tape::stateToString(common::dataStructures::Tape::ACTIVE));
auto rset = stmt.executeQuery();
if (!rset.next()) {
......@@ -2183,7 +2185,6 @@ cta::optional<TapePool> RdbmsCatalogue::getTapePool(const std::string &tapePoolN
pool.nbEmptyTapes = rset.columnUint64("NB_EMPTY_TAPES");
pool.nbDisabledTapes = rset.columnUint64("NB_DISABLED_TAPES");
pool.nbFullTapes = rset.columnUint64("NB_FULL_TAPES");
pool.nbReadOnlyTapes = rset.columnUint64("NB_READ_ONLY_TAPES");
pool.nbWritableTapes = rset.columnUint64("NB_WRITABLE_TAPES");
pool.capacityBytes = rset.columnUint64("CAPACITY_IN_BYTES");
pool.dataBytes = rset.columnUint64("DATA_IN_BYTES");
......@@ -5705,7 +5706,8 @@ try {
policy.retrieveMinRequestAge = rset.columnUint64("RETRIEVE_MIN_REQUEST_AGE");
policy.maxDrivesAllowed = rset.columnUint64("MAX_DRIVES_ALLOWED");
policy.maxDrivesAllowedPerVo = rset.columnUint64("MAX_DRIVES_ALLOWED_PER_VO");
policy.comment = rset.columnString("USER_COMMENT");
policy.creationLog.username = rset.columnString("CREATION_LOG_USER_NAME");
......
......@@ -122,6 +122,9 @@ repackDisableTape() {
echo "Reclaiming tape ${VID_TO_REPACK}"
kubectl -n ${NAMESPACE} exec ctacli -- cta-admin tape reclaim --vid ${VID_TO_REPACK}
echo "Setting the tape ${VID_TO_REPACK} back to ACTIVE"
kubectl -n ${NAMESPACE} exec ctacli -- cta-admin tape ch --state ACTIVE --vid ${VID_TO_REPACK}
echo
echo "*************************************************************"
echo "STEP $1. Launching a Repack Request on a disabled tape TEST OK"
......
......@@ -1657,7 +1657,6 @@ std::list<common::dataStructures::QueueAndMountSummary> Scheduler::getQueuesAndM
mountOrQueue.emptyTapes = tapePool->nbEmptyTapes;
mountOrQueue.disabledTapes = tapePool->nbDisabledTapes;
mountOrQueue.fullTapes = tapePool->nbFullTapes;
mountOrQueue.readOnlyTapes = tapePool->nbReadOnlyTapes;
mountOrQueue.writableTapes = tapePool->nbWritableTapes;
}
} else if (common::dataStructures::MountType::Retrieve==mountOrQueue.mountType) {
......
......@@ -2532,28 +2532,17 @@ TEST_P(DataTransferSessionTest, CleanerSessionFailsShouldPutTheDriveDown) {
ASSERT_EQ(s_libraryName, libraries.front().name);
ASSERT_EQ(libraryComment, libraries.front().comment);
}
const std::string tapeComment = "Tape comment";
bool notDisabled = false;
bool notFull = false;
bool notReadOnly = false;
{
cta::catalogue::CreateTapeAttributes tape;
tape.vid = s_vid;
tape.mediaType = s_mediaType;
tape.vendor = s_vendor;
tape.logicalLibraryName = s_libraryName;
tape.tapePoolName = s_tapePoolName;
tape.full = notFull;
tape.disabled = notDisabled;
tape.readOnly = notReadOnly;
tape.comment = tapeComment;
cta::catalogue::CreateTapeAttributes tape = getDefaultTape();
catalogue.createTape(s_adminOnAdminHost, tape);
}
// 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");
auto mountPolicy = getImmediateMountMountPolicy();
catalogue.createMountPolicy(requester, mountPolicy);
std::string mountPolicyName = mountPolicy.name;
catalogue.createRequesterMountRule(requester, mountPolicyName, s_diskInstance, requester.username, "Rule comment");
//delete is unnecessary
//pointer with ownership will be passed to the application,
......
Subproject commit 668b482304a1fc3037e99ad41a40517f0638a018
Subproject commit 52f53bdf8f6f08f4344c8e28cc098c471cda31af
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