summaryrefslogtreecommitdiff
path: root/Testing/include/simulation/workloads/SimpleSchedulerTest.h
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2017-07-09 23:48:06 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2017-07-09 23:48:06 +0200
commitc94d0c347fdbd8acc774df4ac17617a3f63e4507 (patch)
tree4b825dc642cb6eb9a060e54bf8d69288fbee4904 /Testing/include/simulation/workloads/SimpleSchedulerTest.h
parentbc4c41e21a64b444bdbab3b6d1d407fd5d919419 (diff)
Delete old codebase
This change removes version 1 of the OpenDC simulator codebase as it will be replaced by a complete rewrite in the Kotlin language.
Diffstat (limited to 'Testing/include/simulation/workloads/SimpleSchedulerTest.h')
-rw-r--r--Testing/include/simulation/workloads/SimpleSchedulerTest.h106
1 files changed, 0 insertions, 106 deletions
diff --git a/Testing/include/simulation/workloads/SimpleSchedulerTest.h b/Testing/include/simulation/workloads/SimpleSchedulerTest.h
deleted file mode 100644
index 07b4416f..00000000
--- a/Testing/include/simulation/workloads/SimpleSchedulerTest.h
+++ /dev/null
@@ -1,106 +0,0 @@
-#pragma once
-#include "simulation\workloads\SimpleScheduler.h"
-#include "simulation\workloads\Workload.h"
-#include "modeling\Machine.h"
-
-#include <vector>
-#include <gtest\gtest.h>
-
-TEST(SimpleSchedulerTest, ScheduleSingleMachine)
-{
- // Initialization
- Simulation::SimpleScheduler scheduler;
- Simulation::Workload workload1(100, 0, 1, 1, 0);
- Simulation::Workload workload2(150, 0, 1, 1, 0);
- Modeling::Machine machine(10);
-
- std::vector<std::reference_wrapper<Modeling::Machine>> machines;
- machines.push_back(std::reference_wrapper<Modeling::Machine>(machine));
- scheduler.addWorkload(workload1);
- scheduler.addWorkload(workload2);
-
- // Distribute tasks across machines
- scheduler.schedule(machines);
-
- // Do work
- for (auto machine : machines)
- machine.get().tick();
-
- // Assert work done
- auto workloads = scheduler.getWorkloads();
- auto workload1Remaining = workloads.at(0).lock()->getRemainingOperations();
- auto workload2Remaining = workloads.at(1).lock()->getRemainingOperations();
- ASSERT_EQ(workload1Remaining, 90);
- ASSERT_EQ(workload2Remaining, 150);
-}
-
-TEST(SimpleSchedulerTest, ScheduleMultipleMachine)
-{
- // Initialization
- Simulation::SimpleScheduler scheduler;
- Simulation::Workload workload1(100, 0, 1, 1, 0);
- Simulation::Workload workload2(150, 0, 1, 1, 0);
- Modeling::Machine machine1(10);
- Modeling::Machine machine2(30);
-
- std::vector<std::reference_wrapper<Modeling::Machine>> machines;
- machines.push_back(std::reference_wrapper<Modeling::Machine>(machine1));
- machines.push_back(std::reference_wrapper<Modeling::Machine>(machine2));
- scheduler.addWorkload(workload1);
- scheduler.addWorkload(workload2);
-
- // Distribute tasks across machines
- scheduler.schedule(machines);
-
- // Do work
- for (auto machine : machines)
- machine.get().tick();
-
- // Assert work done
- auto workloads = scheduler.getWorkloads();
- auto workload1Remaining = workloads.at(0).lock()->getRemainingOperations();
- auto workload2Remaining = workloads.at(1).lock()->getRemainingOperations();
- ASSERT_EQ(workload1Remaining, 60);
- ASSERT_EQ(workload2Remaining, 150);
-}
-
-TEST(SimpleSchedulerTest, ScheduleFinishTask)
-{
- // Initialization
- Simulation::SimpleScheduler scheduler;
- Simulation::Workload workload1(100, 0, 1, 1, 0);
- Modeling::Machine machine1(100);
-
- std::vector<std::reference_wrapper<Modeling::Machine>> machines;
- machines.push_back(std::reference_wrapper<Modeling::Machine>(machine1));
- scheduler.addWorkload(workload1);
- ASSERT_TRUE(scheduler.hasWorkloads());
-
- // Distribute tasks across machines
- scheduler.schedule(machines);
-
- // Do work
- for (auto machine : machines)
- machine.get().tick();
-
- // Distribute tasks across machines again, this is when finished workloads get cleared
- scheduler.schedule(machines);
-
- // Assert work done
- auto workloads = scheduler.getWorkloads();
- ASSERT_EQ(workloads.size(), 0);
- ASSERT_FALSE(scheduler.hasWorkloads());
-}
-
-TEST(SimpleSchedulerTest, AddMultipleWorkloads)
-{
- Simulation::SimpleScheduler ss;
- std::vector<Simulation::Workload> workloads{
- Simulation::Workload(100, 0, 1, 1, 0),
- Simulation::Workload(100, 0, 1, 1, 0)
- };
- ss.addWorkloads(workloads);
-
- ASSERT_TRUE(ss.hasWorkloads());
- ASSERT_EQ(ss.getWorkloads().size(), 2);
-} \ No newline at end of file