SVN commit 1249935 by mfuchs: Adds more data to SchedulerTest and makes comments more clear. M +1 -0 core/scheduler.h M +13 -6 tests/schedulertest.cpp M +2 -2 tests/schedulertest.h --- trunk/KDE/kdenetwork/kget/core/scheduler.h #1249934:1249935 @@ -82,6 +82,7 @@ * Can be used to suspend the scheduler before doing lenghty operations * and activating it later again * + * NOTE does not stop running jobs, just prevents changes to jobs * HACK this is needed since the scheduler would constantly update the queue * when stopping starting multiple transfers, this slows down that operation a lot * and could result in transfers finishing before they are stopped etc. --- trunk/KDE/kdenetwork/kget/tests/schedulertest.cpp #1249934:1249935 @@ -127,6 +127,7 @@ QTest::newRow("limit 2, will first two start while last will be stopped?") << 2 << (QList() << Job::Stopped << Job::Stopped << Job::Running) << (QList() << Job::Running << Job::Running << Job::Stopped); QTest::newRow("no limit, two finished, will third be started?") << NO_LIMIT << (QList() << Job::Finished << Job::Finished << Job::Stopped) << (QList() << Job::Finished << Job::Finished << Job::Running); QTest::newRow("no limit, will all three be started?") << NO_LIMIT << (QList() << Job::Stopped << Job::Stopped << Job::Stopped) << (QList() << Job::Running << Job::Running << Job::Running); + QTest::newRow("no limit, will all three be started and one remain running?") << NO_LIMIT << (QList() << Job::Stopped << Job::Running << Job::Stopped << Job::Stopped) << (QList() << Job::Running << Job::Running << Job::Running << Job::Running); } void SchedulerTest::testCountRunningJobs() @@ -161,6 +162,7 @@ QTest::newRow("limit 2, will first two start while last will stay stopped?") << 2 << (QList() << Job::Stopped << Job::Stopped << Job::Stopped) << 2; QTest::newRow("limit 2, will first two start while last will be stopped?") << 2 << (QList() << Job::Stopped << Job::Stopped << Job::Running) << 2; QTest::newRow("no limit, two finished, will third be started?") << NO_LIMIT << (QList() << 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::Finished << Job::Finished << Job::Stopped << Job::Running) << 2; QTest::newRow("no limit, will all three be started?") << NO_LIMIT << (QList() << Job::Stopped << Job::Stopped << Job::Stopped) << 3; } @@ -193,11 +195,13 @@ QTest::addColumn("limit"); QTest::addColumn >("status"); - QTest::newRow("limit 2, two finished, will third be started?") << 2 << (QList() << Job::Finished << Job::Finished << Job::Stopped); - QTest::newRow("limit 2, will first two start while last will stay stopped?") << 2 << (QList() << Job::Stopped << Job::Stopped << Job::Stopped); - QTest::newRow("limit 2, will first two start while last will be stopped?") << 2 << (QList() << Job::Stopped << Job::Stopped << Job::Running); - QTest::newRow("no limit, two finished, will third be started?") << NO_LIMIT << (QList() << Job::Finished << Job::Finished << Job::Stopped); - QTest::newRow("no limit, will all three be started?") << NO_LIMIT << (QList() << Job::Stopped << Job::Stopped << Job::Stopped); + QTest::newRow("limit 2, two finished one stopped") << 2 << (QList() << Job::Finished << Job::Finished << Job::Stopped); + QTest::newRow("limit 2, two finished one running") << 2 << (QList() << Job::Finished << Job::Finished << Job::Stopped); + QTest::newRow("limit 2, three stopped") << 2 << (QList() << Job::Stopped << Job::Stopped << Job::Stopped); + QTest::newRow("limit 2, two stopped one running") << 2 << (QList() << Job::Stopped << Job::Stopped << Job::Running); + QTest::newRow("no limit, two finished one stopped") << NO_LIMIT << (QList() << Job::Finished << Job::Finished << Job::Stopped); + QTest::newRow("no limit, three stopped") << NO_LIMIT << (QList() << Job::Stopped << Job::Stopped << Job::Stopped); + QTest::newRow("no limit, one running, three stopped") << NO_LIMIT << (QList() << Job::Running << Job::Stopped << Job::Stopped << Job::Stopped); } void SchedulerTest::testSchedulerStopStart() @@ -240,6 +244,7 @@ QTest::newRow("limit 2, will first two start while last will be stopped?") << 2 << (QList() << Job::Stopped << Job::Stopped << Job::Running) << (QList() << Job::Running << Job::Running << Job::Stopped); QTest::newRow("no limit, two finished, will third be started?") << NO_LIMIT << (QList() << Job::Finished << Job::Finished << Job::Stopped) << (QList() << Job::Finished << Job::Finished << Job::Running); QTest::newRow("no limit, will all three be started?") << NO_LIMIT << (QList() << Job::Stopped << Job::Stopped << Job::Stopped) << (QList() << Job::Running << Job::Running << Job::Running); + QTest::newRow("limit 2, two finished, will third stay running?") << 2 << (QList() << Job::Finished << Job::Finished << Job::Running) << (QList() << Job::Finished << Job::Finished << Job::Running); } @@ -282,11 +287,13 @@ QTest::addColumn >("status"); QTest::addColumn >("finalStatus"); + //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::Finished << Job::Finished << Job::Stopped) << (QList() << Job::Finished << Job::Finished << Job::Running); QTest::newRow("limit 2, will first two start while last will stay stopped?") << 2 << (QList() << Job::Stopped << Job::Stopped << Job::Stopped) << (QList() << Job::Running << Job::Running << Job::Stopped); - QTest::newRow("limit 2, will first two start while last will be stopped?") << 2 << (QList() << Job::Stopped << Job::Stopped << Job::Running) << (QList() << Job::Running << Job::Running << Job::Stopped); + QTest::newRow("limit 2, will first start and second not while last will stay running?") << 2 << (QList() << Job::Stopped << Job::Stopped << Job::Running) << (QList() << Job::Running << Job::Running << Job::Stopped); QTest::newRow("no limit, two finished, will third be started?") << NO_LIMIT << (QList() << Job::Finished << Job::Finished << Job::Stopped) << (QList() << Job::Finished << Job::Finished << Job::Running); QTest::newRow("no limit, will all three be started?") << NO_LIMIT << (QList() << Job::Stopped << Job::Stopped << Job::Stopped) << (QList() << Job::Running << Job::Running << Job::Running); + QTest::newRow("limit 2, two finished, will third stay running?") << 2 << (QList() << Job::Finished << Job::Finished << Job::Running) << (QList() << Job::Finished << Job::Finished << Job::Running); } --- trunk/KDE/kdenetwork/kget/tests/schedulertest.h #1249934:1249935 @@ -104,8 +104,8 @@ void testSuspendScheduler_data(); /** - * Tests the case where the JobQueuePolicy is set to stop, - * by default it is set to start. + * Tests the case where the JobQueuePolicy is set to stop + * (this also happens on Scheduler::stop()) by default it is set to start. * Jobs with a Start policy might be started depending on their * other settings */