Skip to content

Commit

Permalink
using defined constants, incrementing variable in loop, and checking …
Browse files Browse the repository at this point in the history
…for it in the tests
  • Loading branch information
csegarragonz committed Nov 26, 2021
1 parent 6a0754a commit 348b483
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/scheduler/Scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@

#include <unordered_set>

#define GET_EXEC_GRAPH_SLEEP_MS 500
#define FLUSH_TIMEOUT_MS 10000
#define MAX_GET_EXEC_GRAPH_RETRIES 3

using namespace faabric::util;
using namespace faabric::snapshot;
Expand Down Expand Up @@ -1017,16 +1019,16 @@ ExecGraphNode Scheduler::getFunctionExecGraphNode(unsigned int messageId)
// we get them from Redis. For the time being, we retry a number of times
// and fail if we don't succeed.
std::vector<uint8_t> messageBytes = redis.get(statusKey);
int maxNumRetries = 3;
int numRetries = 0;
while (messageBytes.empty() && numRetries < maxNumRetries) {
while (messageBytes.empty() && numRetries < MAX_GET_EXEC_GRAPH_RETRIES) {
SPDLOG_WARN(
"Retry GET message for ExecGraph node with id {} (Retry {}/{})",
messageId,
numRetries + 1,
maxNumRetries);
SLEEP_MS(500);
MAX_GET_EXEC_GRAPH_RETRIES);
SLEEP_MS(GET_EXEC_GRAPH_SLEEP_MS);
messageBytes = redis.get(statusKey);
++numRetries;
}
if (messageBytes.empty()) {
SPDLOG_ERROR("Can't GET message from redis (id: {}, key: {})",
Expand Down
9 changes: 9 additions & 0 deletions tests/test/scheduler/test_exec_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ TEST_CASE("Test execution graph", "[scheduler][exec-graph]")
checkExecGraphEquality(expected, actual);
}

TEST_CASE("Test can't get exec graph if results are not published",
"[scheduler][exec-graph]")
{
faabric::Message msg = faabric::util::messageFactory("demo", "echo");

REQUIRE_THROWS(
faabric::scheduler::getScheduler().getFunctionExecGraph(msg.id()));
}

TEST_CASE("Test get unique hosts from exec graph", "[scheduler][exec-graph]")
{
faabric::Message msgA = faabric::util::messageFactory("demo", "echo");
Expand Down

0 comments on commit 348b483

Please sign in to comment.