Skip to content

Commit

Permalink
add regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
csegarragonz committed Nov 25, 2021
1 parent fa46856 commit 6a0754a
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/dist/scheduler/test_exec_graph.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include <catch2/catch.hpp>

#include "fixtures.h"

#include <faabric/scheduler/Scheduler.h>

namespace tests {

TEST_CASE_METHOD(DistTestsFixture,
"Test generating the execution graph",
"[funcs]")
{
// Set up this host's resources
int nLocalSlots = 2;
int nFuncs = 4;
faabric::HostResources res;
res.set_slots(nLocalSlots);
sch.setThisHostResources(res);

// Retry the test a number of times to catch the race-condition where
// we get the execution graph before all results have been published
int numRetries = 10;
for (int r = 0; r < numRetries; r++) {
// Set up the messages
std::shared_ptr<faabric::BatchExecuteRequest> req =
faabric::util::batchExecFactory("funcs", "simple", nFuncs);

// Add a fictional chaining dependency between functions
for (int i = 1; i < nFuncs; i++) {
sch.logChainedFunction(req->mutable_messages()->at(0).id(),
req->mutable_messages()->at(i).id());
}

// Call the functions
sch.callFunctions(req);

faabric::Message& m = req->mutable_messages()->at(0);

// Wait for the result, and immediately after query for the execution
// graph
faabric::Message result = sch.getFunctionResult(m.id(), 1000);
auto execGraph = sch.getFunctionExecGraph(m.id());
REQUIRE(countExecGraphNodes(execGraph) == nFuncs);

REQUIRE(execGraph.rootNode.msg.id() == m.id());
for (int i = 1; i < nFuncs; i++) {
auto node = execGraph.rootNode.children.at(i - 1);
REQUIRE(node.msg.id() == req->mutable_messages()->at(i).id());
}
}
}
}

0 comments on commit 6a0754a

Please sign in to comment.