diff --git a/tests/test/scheduler/test_executor.cpp b/tests/test/scheduler/test_executor.cpp index c456ef282..1c0e812c9 100644 --- a/tests/test/scheduler/test_executor.cpp +++ b/tests/test/scheduler/test_executor.cpp @@ -202,7 +202,6 @@ int32_t TestExecutor::executeTask( } if (msg.function() == "sleep") { - // Sleep for sufficiently more than the check period int timeToSleepMs = SHORT_TEST_TIMEOUT_MS; if (!msg.inputdata().empty()) { timeToSleepMs = std::stoi(msg.inputdata()); diff --git a/tests/test/scheduler/test_function_migration.cpp b/tests/test/scheduler/test_function_migration.cpp index 5f612e379..6c1c4f62d 100644 --- a/tests/test/scheduler/test_function_migration.cpp +++ b/tests/test/scheduler/test_function_migration.cpp @@ -328,10 +328,10 @@ TEST_CASE_METHOD( std::shared_ptr expectedMigrations; - SECTION("Can not migrate") { expectedMigrations = nullptr; } - // As we don't update the available resources, no migration opportunities // will appear, even though we are checking for them + SECTION("Can not migrate") { expectedMigrations = nullptr; } + SECTION("Can migrate") { // Update host resources so that a migration opportunity appears @@ -360,4 +360,25 @@ TEST_CASE_METHOD( sch.checkForMigrationOpportunities(); REQUIRE(sch.canAppBeMigrated(appId) == nullptr); } + +TEST_CASE_METHOD(FunctionMigrationTestFixture, + "Test adding and removing pending migrations manually", + "[scheduler]") +{ + auto req = faabric::util::batchExecFactory("foo", "sleep", 2); + uint32_t appId = req->messages().at(0).appid(); + std::vector hosts = { masterHost, "hostA" }; + std::vector> migrations = { { 1, 0 } }; + auto expectedMigrations = + buildPendingMigrationsExpectation(req, hosts, migrations); + + // Add migration manually + REQUIRE(sch.canAppBeMigrated(appId) == nullptr); + sch.addPendingMigration(expectedMigrations); + REQUIRE(sch.canAppBeMigrated(appId) == expectedMigrations); + + // Remove migration manually + sch.removePendingMigration(appId); + REQUIRE(sch.canAppBeMigrated(appId) == nullptr); +} }