Skip to content

Commit

Permalink
tests: add further testing
Browse files Browse the repository at this point in the history
  • Loading branch information
csegarragonz committed Jan 9, 2022
1 parent 13560b3 commit 0b02aba
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
1 change: 0 additions & 1 deletion tests/test/scheduler/test_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
25 changes: 23 additions & 2 deletions tests/test/scheduler/test_function_migration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,10 @@ TEST_CASE_METHOD(

std::shared_ptr<faabric::PendingMigrations> 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
Expand Down Expand Up @@ -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<std::string> hosts = { masterHost, "hostA" };
std::vector<std::pair<int, int>> 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);
}
}

0 comments on commit 0b02aba

Please sign in to comment.