Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method to get unique hosts from scheduling decision #346

Merged
merged 1 commit into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/faabric/batch-scheduler/SchedulingDecision.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class SchedulingDecision

SchedulingDecision(uint32_t appIdIn, int32_t groupIdIn);

bool operator==(const SchedulingDecision& rhs) const = default;

uint32_t appId = 0;

int32_t groupId = 0;
Expand Down Expand Up @@ -96,6 +98,8 @@ class SchedulingDecision
int32_t messageId,
int32_t appIdx,
int32_t groupIdx);

std::set<std::string> uniqueHosts();
};

}
5 changes: 5 additions & 0 deletions src/batch-scheduler/SchedulingDecision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,9 @@ SchedulingDecision SchedulingDecision::fromPointToPointMappings(

return decision;
}

std::set<std::string> SchedulingDecision::uniqueHosts()
{
return std::set<std::string>(hosts.begin(), hosts.end());
}
}
13 changes: 12 additions & 1 deletion tests/test/batch-scheduler/test_scheduling_decisions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,18 @@ TEST_CASE_METHOD(ConfFixture, "Test building scheduling decisions", "[util]")
std::string hostC = "hostC";

std::string thisHost = conf.endpointHost;
std::set<std::string> expectedUniqueHosts;

bool expectSingleHost = false;
SECTION("Multi-host") {}
SECTION("Multi-host") { expectedUniqueHosts = { hostA, hostB, hostC }; }

SECTION("Only remote hosts")
{
hostB = "hostA";
hostC = "hostA";

expectSingleHost = false;
expectedUniqueHosts = { "hostA" };
}

SECTION("All this host")
Expand All @@ -39,6 +41,7 @@ TEST_CASE_METHOD(ConfFixture, "Test building scheduling decisions", "[util]")
hostC = thisHost;

expectSingleHost = true;
expectedUniqueHosts = { thisHost };
}

SECTION("All this host single host optimisations off")
Expand All @@ -50,6 +53,7 @@ TEST_CASE_METHOD(ConfFixture, "Test building scheduling decisions", "[util]")
hostC = thisHost;

expectSingleHost = false;
expectedUniqueHosts = { thisHost };
}

auto req = faabric::util::batchExecFactory("foo", "bar", 3);
Expand All @@ -75,8 +79,15 @@ TEST_CASE_METHOD(ConfFixture, "Test building scheduling decisions", "[util]")
REQUIRE(decision.nFunctions == 3);
REQUIRE(decision.messageIds == expectedMsgIds);
REQUIRE(decision.hosts == expectedHosts);
REQUIRE(decision.uniqueHosts() == expectedUniqueHosts);
REQUIRE(decision.appIdxs == expectedAppIdxs);
REQUIRE(decision.isSingleHost() == expectSingleHost);

// We can compare decisions with the == operator
auto newDecision = decision;
REQUIRE(newDecision == decision);
newDecision.groupId = 1338;
REQUIRE(newDecision != decision);
}

TEST_CASE("Test converting point-to-point mappings to scheduling decisions",
Expand Down