QTest::newRow("limit 2, two finished, will third be started?")<<2<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Stopped)<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Running);
QTest::newRow("limit 2, two finished, will third aborted be started?")<<2<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Aborted)<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Running);
QTest::newRow("limit 2, will first two start while last will stay stopped?")<<2<<(QList<Job::Status>()<<Job::Stopped<<Job::Stopped<<Job::Stopped)<<(QList<Job::Status>()<<Job::Running<<Job::Running<<Job::Stopped);
QTest::newRow("limit 2, will first two start while last will be stopped?")<<2<<(QList<Job::Status>()<<Job::Stopped<<Job::Stopped<<Job::Running)<<(QList<Job::Status>()<<Job::Running<<Job::Running<<Job::Stopped);
QTest::newRow("no limit, two finished, will third be started?")<<NO_LIMIT<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Stopped)<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Running);
QTest::newRow("no limit, will all three be started?")<<NO_LIMIT<<(QList<Job::Status>()<<Job::Stopped<<Job::Stopped<<Job::Stopped)<<(QList<Job::Status>()<<Job::Running<<Job::Running<<Job::Running);
QTest::newRow("no limit, will all three be started and one remain running?")<<NO_LIMIT<<(QList<Job::Status>()<<Job::Stopped<<Job::Running<<Job::Stopped<<Job::Stopped)<<(QList<Job::Status>()<<Job::Running<<Job::Running<<Job::Running<<Job::Running);
}
voidSchedulerTest::testCountRunningJobs()
{
QFETCH(int,limit);
QFETCH(QList<Job::Status>,status);
QFETCH(int,numRunningJobs);
SettingsHelperhelper(limit);
Schedulerscheduler;
TestQueue*queue=newTestQueue(&scheduler);
scheduler.addQueue(queue);
//uses an own list instead of the iterators to make sure that the order stays the same
QTest::newRow("limit 2, two finished, will third be started?")<<2<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Stopped)<<1;
QTest::newRow("limit 2, two finished, will none be started?")<<2<<(QList<Job::Status>()<<Job::Finished<<Job::Finished)<<0;
QTest::newRow("limit 2, will first two start while last will stay stopped?")<<2<<(QList<Job::Status>()<<Job::Stopped<<Job::Stopped<<Job::Stopped)<<2;
QTest::newRow("limit 2, will first two start while last will be stopped?")<<2<<(QList<Job::Status>()<<Job::Stopped<<Job::Stopped<<Job::Running)<<2;
QTest::newRow("no limit, two finished, will third be started?")<<NO_LIMIT<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Stopped)<<1;
QTest::newRow("no limit, two finished, will third be started and fourth stay running?")<<NO_LIMIT<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Stopped<<Job::Running)<<2;
QTest::newRow("no limit, will all three be started?")<<NO_LIMIT<<(QList<Job::Status>()<<Job::Stopped<<Job::Stopped<<Job::Stopped)<<3;
}
voidSchedulerTest::testStopScheduler()
{
QFETCH(int,limit);
QFETCH(QList<Job::Status>,status);
SettingsHelperhelper(limit);
Schedulerscheduler;
TestQueue*queue=newTestQueue(&scheduler);
scheduler.addQueue(queue);
//uses an own list instead of the iterators to make sure that the order stays the same
for(inti=0;i<status.size();++i){
TestJob*job=newTestJob(&scheduler,queue);
job->setStatus(status[i]);
queue->appendPub(job);
}
scheduler.stop();
QCOMPARE(scheduler.countRunningJobs(),0);
}
voidSchedulerTest::testStopScheduler_data()
{
QTest::addColumn<int>("limit");
QTest::addColumn<QList<Job::Status>>("status");
QTest::newRow("limit 2, two finished one stopped")<<2<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Stopped);
QTest::newRow("limit 2, two finished one running")<<2<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Stopped);
QTest::newRow("limit 2, three stopped")<<2<<(QList<Job::Status>()<<Job::Stopped<<Job::Stopped<<Job::Stopped);
QTest::newRow("limit 2, two stopped one running")<<2<<(QList<Job::Status>()<<Job::Stopped<<Job::Stopped<<Job::Running);
QTest::newRow("no limit, two finished one stopped")<<NO_LIMIT<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Stopped);
QTest::newRow("no limit, three stopped")<<NO_LIMIT<<(QList<Job::Status>()<<Job::Stopped<<Job::Stopped<<Job::Stopped);
QTest::newRow("no limit, one running, three stopped")<<NO_LIMIT<<(QList<Job::Status>()<<Job::Running<<Job::Stopped<<Job::Stopped<<Job::Stopped);
}
voidSchedulerTest::testSchedulerStopStart()
{
QFETCH(int,limit);
QFETCH(QList<Job::Status>,status);
QFETCH(QList<Job::Status>,finalStatus);
SettingsHelperhelper(limit);
Schedulerscheduler;
TestQueue*queue=newTestQueue(&scheduler);
scheduler.addQueue(queue);
//uses an own list instead of the iterators to make sure that the order stays the same
QTest::newRow("limit 2, two finished, will third be started?")<<2<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Stopped)<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Running);
QTest::newRow("limit 2, will first two start while last will stay stopped?")<<2<<(QList<Job::Status>()<<Job::Stopped<<Job::Stopped<<Job::Stopped)<<(QList<Job::Status>()<<Job::Running<<Job::Running<<Job::Stopped);
QTest::newRow("limit 2, will first two start while last will be stopped?")<<2<<(QList<Job::Status>()<<Job::Stopped<<Job::Stopped<<Job::Running)<<(QList<Job::Status>()<<Job::Running<<Job::Running<<Job::Stopped);
QTest::newRow("no limit, two finished, will third be started?")<<NO_LIMIT<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Stopped)<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Running);
QTest::newRow("no limit, will all three be started?")<<NO_LIMIT<<(QList<Job::Status>()<<Job::Stopped<<Job::Stopped<<Job::Stopped)<<(QList<Job::Status>()<<Job::Running<<Job::Running<<Job::Running);
QTest::newRow("limit 2, two finished, will third stay running?")<<2<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Running)<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Running);
}
voidSchedulerTest::testSuspendScheduler()
{
QFETCH(int,limit);
QFETCH(QList<Job::Status>,status);
QFETCH(QList<Job::Status>,finalStatus);
SettingsHelperhelper(limit);
Schedulerscheduler;
TestQueue*queue=newTestQueue(&scheduler);
scheduler.addQueue(queue);
scheduler.setIsSuspended(true);
//uses an own list instead of the iterators to make sure that the order stays the same
QList<TestJob*>jobs;
for(inti=0;i<status.size();++i){
TestJob*job=newTestJob(&scheduler,queue);
job->setStatus(status[i]);
queue->appendPub(job);
jobs<<job;
}
//scheduler is suspended thus the status has to be same as start status
//NOTE Scheduler does not stop jobs, it just prevents new ones from being started
QTest::newRow("limit 2, two finished, will third be started?")<<2<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Stopped)<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Running);
QTest::newRow("limit 2, will first two start while last will stay stopped?")<<2<<(QList<Job::Status>()<<Job::Stopped<<Job::Stopped<<Job::Stopped)<<(QList<Job::Status>()<<Job::Running<<Job::Running<<Job::Stopped);
QTest::newRow("limit 2, will first start and second not while last will stay running?")<<2<<(QList<Job::Status>()<<Job::Stopped<<Job::Stopped<<Job::Running)<<(QList<Job::Status>()<<Job::Running<<Job::Running<<Job::Stopped);
QTest::newRow("no limit, two finished, will third be started?")<<NO_LIMIT<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Stopped)<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Running);
QTest::newRow("no limit, will all three be started?")<<NO_LIMIT<<(QList<Job::Status>()<<Job::Stopped<<Job::Stopped<<Job::Stopped)<<(QList<Job::Status>()<<Job::Running<<Job::Running<<Job::Running);
QTest::newRow("limit 2, two finished, will third stay running?")<<2<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Running)<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Running);
}
voidSchedulerTest::testJobQueueStopPolicy()
{
QFETCH(int,limit);
QFETCH(QList<Job::Status>,status);
QFETCH(QList<Job::Status>,finalStatus);
QFETCH(QList<Job::Policy>,policy);
SettingsHelperhelper(limit);
Schedulerscheduler;
TestQueue*queue=newTestQueue(&scheduler);
queue->setStatus(JobQueue::Stopped);
scheduler.addQueue(queue);
//uses an own list instead of the iterators to make sure that the order stays the same
QTest::newRow("limit 2, two finished, will third not be started?")<<2<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Stopped)<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Stopped)<<(QList<Job::Policy>()<<Job::None<<Job::None<<Job::None);
QTest::newRow("limit 2, will first start while rest will stay stopped?")<<2<<(QList<Job::Status>()<<Job::Stopped<<Job::Stopped<<Job::Stopped)<<(QList<Job::Status>()<<Job::Running<<Job::Stopped<<Job::Stopped)<<(QList<Job::Policy>()<<Job::Start<<Job::Stop<<Job::None);
QTest::newRow("limit 2, will first and third start while rest will stay stopped?")<<2<<(QList<Job::Status>()<<Job::Stopped<<Job::Stopped<<Job::Stopped<<Job::Stopped)<<(QList<Job::Status>()<<Job::Running<<Job::Stopped<<Job::Running<<Job::Stopped)<<(QList<Job::Policy>()<<Job::Start<<Job::Stop<<Job::Start<<Job::None);
QTest::newRow("no limit, two finished, will third be started?")<<NO_LIMIT<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Stopped)<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Running)<<(QList<Job::Policy>()<<Job::Start<<Job::None<<Job::Start);
QTest::newRow("no limit, will all three be started?")<<NO_LIMIT<<(QList<Job::Status>()<<Job::Stopped<<Job::Stopped<<Job::Stopped)<<(QList<Job::Status>()<<Job::Running<<Job::Running<<Job::Running)<<(QList<Job::Policy>()<<Job::Start<<Job::Start<<Job::Start);
}
voidSchedulerTest::testJobQueueStopStartPolicy()
{
QFETCH(int,limit);
QFETCH(QList<Job::Status>,status);
QFETCH(QList<Job::Status>,intermediateStatus);
QFETCH(QList<Job::Policy>,policy);
QFETCH(QList<Job::Status>,finalStatus);
SettingsHelperhelper(limit);
Schedulerscheduler;
TestQueue*queue=newTestQueue(&scheduler);
queue->setStatus(JobQueue::Stopped);
scheduler.addQueue(queue);
//uses an own list instead of the iterators to make sure that the order stays the same
QTest::newRow("limit 2, two finished, will third be started?")<<2<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Stopped)<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Stopped)<<(QList<Job::Policy>()<<Job::None<<Job::None<<Job::None)<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Running);
QTest::newRow("limit 2, will first and last start while rest will stay stopped?")<<2<<(QList<Job::Status>()<<Job::Stopped<<Job::Stopped<<Job::Stopped)<<(QList<Job::Status>()<<Job::Running<<Job::Stopped<<Job::Stopped)<<(QList<Job::Policy>()<<Job::Start<<Job::Stop<<Job::None)<<(QList<Job::Status>()<<Job::Running<<Job::Stopped<<Job::Running);
QTest::newRow("limit 3, will first, third and last start while rest will stay stopped?")<<3<<(QList<Job::Status>()<<Job::Stopped<<Job::Stopped<<Job::Stopped<<Job::Stopped)<<(QList<Job::Status>()<<Job::Running<<Job::Stopped<<Job::Running<<Job::Stopped)<<(QList<Job::Policy>()<<Job::Start<<Job::Stop<<Job::Start<<Job::None)<<(QList<Job::Status>()<<Job::Running<<Job::Stopped<<Job::Running<<Job::Running);
QTest::newRow("no limit, two finished, will third be started?")<<NO_LIMIT<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Stopped)<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Running)<<(QList<Job::Policy>()<<Job::Start<<Job::Start<<Job::Start)<<(QList<Job::Status>()<<Job::Finished<<Job::Finished<<Job::Running);
QTest::newRow("no limit, will all three be started?")<<NO_LIMIT<<(QList<Job::Status>()<<Job::Stopped<<Job::Stopped<<Job::Stopped)<<(QList<Job::Status>()<<Job::Running<<Job::Running<<Job::Running)<<(QList<Job::Policy>()<<Job::Start<<Job::Start<<Job::Start)<<(QList<Job::Status>()<<Job::Running<<Job::Running<<Job::Running);