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

[scheduler] Improved the unit tests

parent 6d0d4dee
......@@ -975,6 +975,8 @@ void Scheduler::sortAndGetTapesForMountInfo(std::unique_ptr<SchedulerDatabase::T
.totalMounts;
} catch (std::out_of_range &) {}
try {
//The number of existing mounts with ArchiveAllTypes split into ArchiveForUser and ArchiveForRepack to
//take into consideration the mount policy's Archive min request age (issue https://gitlab.cern.ch/cta/operations/-/issues/150)
nbExistingMountsDistinctTypes = existingMountsDistinctType.at(TapePoolMountPair(m->tapePool, m->type))
.totalMounts;
} catch (std::out_of_range &) {}
......@@ -986,7 +988,7 @@ void Scheduler::sortAndGetTapesForMountInfo(std::unique_ptr<SchedulerDatabase::T
} catch (std::out_of_range &) {}
}
uint32_t effectiveExistingMounts = 0;
if (common::dataStructures::getMountBasicType(m->type) == common::dataStructures::MountType::ArchiveAllTypes) effectiveExistingMounts = nbExistingMountsDistinctTypes;
if (common::dataStructures::getMountBasicType(m->type) == common::dataStructures::MountType::ArchiveAllTypes) effectiveExistingMounts = existingMounts;
bool mountPassesACriteria = false;
uint64_t minBytesToWarrantAMount = m_minBytesToWarrantAMount;
uint64_t minFilesToWarrantAMount = m_minFilesToWarrantAMount;
......@@ -998,7 +1000,7 @@ void Scheduler::sortAndGetTapesForMountInfo(std::unique_ptr<SchedulerDatabase::T
mountPassesACriteria = true;
if (m->filesQueued / (1 + effectiveExistingMounts) >= minFilesToWarrantAMount)
mountPassesACriteria = true;
if (!effectiveExistingMounts && ((time(NULL) - m->oldestJobStartTime) > m->minRequestAge))
if (!nbExistingMountsDistinctTypes && ((time(NULL) - m->oldestJobStartTime) > m->minRequestAge))
mountPassesACriteria = true;
if (m->sleepingMount) {
sleepingMount = true;
......
......@@ -5405,7 +5405,7 @@ TEST_P(SchedulerTest, getNextMountWithArchiveForUserAndArchiveForRepackShouldRet
jobDump.tapePool = s_tapePoolName;
mountPolicy.maxDrivesAllowed = 3;
mountPolicy.archiveMinRequestAge = 0;
cta::objectstore::ArchiveQueue::JobToAdd archiveJobToAdd{jobDump,"",1,2,mountPolicy,time(nullptr)};
cta::objectstore::ArchiveQueue::JobToAdd archiveJobToAdd{jobDump,"",1,2,mountPolicy,1};
cta::objectstore::ArchiveQueue aq(archiveForUserQueueAddress,backend);
{
cta::objectstore::ScopedExclusiveLock sel(aq);
......@@ -5414,8 +5414,6 @@ TEST_P(SchedulerTest, getNextMountWithArchiveForUserAndArchiveForRepackShouldRet
aq.addJobsAndCommit(jobsToAdd,agentReference,lc);
}
::sleep(1);
ASSERT_TRUE(scheduler.getNextMountDryRun(s_libraryName,tapeDrive1,lc));
auto mount = scheduler.getNextMount(s_libraryName,tapeDrive1,lc);
......@@ -5432,7 +5430,7 @@ TEST_P(SchedulerTest, getNextMountWithArchiveForUserAndArchiveForRepackShouldRet
}
jobDump.status = cta::objectstore::serializers::ArchiveJobStatus::AJS_ToTransferForRepack;
cta::objectstore::ArchiveQueue::JobToAdd archiveRepackJobToAdd{jobDump,"",2,2,mountPolicy,time(nullptr)};
cta::objectstore::ArchiveQueue::JobToAdd archiveRepackJobToAdd{jobDump,"",2,2,mountPolicy,1};
cta::objectstore::ArchiveQueue aqRepack(archiveForRepackQueueAddress,backend);
{
......@@ -5442,8 +5440,6 @@ TEST_P(SchedulerTest, getNextMountWithArchiveForUserAndArchiveForRepackShouldRet
aqRepack.addJobsAndCommit(jobsToAdd,agentReference,lc);
}
::sleep(1);
ASSERT_TRUE(scheduler.getNextMountDryRun(s_libraryName,tapeDrive2,lc));
//Get the next mount
......
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