Skip to content

Commit

Permalink
adding more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
csegarragonz committed Jun 16, 2021
1 parent 88bcb7d commit bee0ef8
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
run: inv dev.cc faabric_tests
# --- Tests ---
- name: "Run tests"
run: ./bin/faabric_tests
run: LOG_LEVEL=trace ./bin/faabric_tests
working-directory: /build/faabric/static

dist-tests:
Expand Down
77 changes: 77 additions & 0 deletions tests/test/scheduler/test_remote_mpi_worlds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ TEST_CASE_METHOD(RemoteMpiTestFixture, "Test send across hosts", "[mpi]")
// Send a message that should get sent to this host
remoteWorld.send(
rankB, rankA, BYTES(messageData.data()), MPI_INT, messageData.size());

usleep(1000 * 500);

remoteWorld.destroy();
});

Expand All @@ -94,6 +97,65 @@ TEST_CASE_METHOD(RemoteMpiTestFixture, "Test send across hosts", "[mpi]")
localWorld.destroy();
}

TEST_CASE_METHOD(RemoteMpiTestFixture,
"Test send and recv across hosts",
"[mpi]")
{
// Register two ranks (one on each host)
this->setWorldsSizes(2, 1, 1);
int rankA = 0;
int rankB = 1;
std::vector<int> messageData = { 0, 1, 2 };
std::vector<int> messageData2 = { 3, 4, 5 };

// Init worlds
MpiWorld& localWorld = getMpiWorldRegistry().createWorld(msg, worldId);
faabric::util::setMockMode(false);

std::thread senderThread([this, rankA, rankB, &messageData, &messageData2] {
remoteWorld.initialiseFromMsg(msg);

// Send a message that should get sent to this host
remoteWorld.send(
rankB, rankA, BYTES(messageData.data()), MPI_INT, messageData.size());

// Now recv
auto buffer = new int[messageData2.size()];
remoteWorld.recv(rankA,
rankB,
BYTES(buffer),
MPI_INT,
messageData2.size(),
MPI_STATUS_IGNORE);
std::vector<int> actual(buffer, buffer + messageData2.size());
REQUIRE(actual == messageData2);

usleep(1000 * 500);

remoteWorld.destroy();
});

// Receive the message for the given rank
MPI_Status status{};
auto buffer = new int[messageData.size()];
localWorld.recv(
rankB, rankA, BYTES(buffer), MPI_INT, messageData.size(), &status);
std::vector<int> actual(buffer, buffer + messageData.size());
REQUIRE(actual == messageData);

// Now send a message
localWorld.send(
rankA, rankB, BYTES(messageData2.data()), MPI_INT, messageData2.size());

REQUIRE(status.MPI_SOURCE == rankB);
REQUIRE(status.MPI_ERROR == MPI_SUCCESS);
REQUIRE(status.bytesSize == messageData.size() * sizeof(int));

// Destroy worlds
senderThread.join();
localWorld.destroy();
}

TEST_CASE_METHOD(RemoteMpiTestFixture,
"Test sending many messages across host",
"[mpi]")
Expand All @@ -114,6 +176,9 @@ TEST_CASE_METHOD(RemoteMpiTestFixture,
for (int i = 0; i < numMessages; i++) {
remoteWorld.send(rankB, rankA, BYTES(&i), MPI_INT, 1);
}

usleep(1000 * 500);

remoteWorld.destroy();
});

Expand Down Expand Up @@ -165,6 +230,8 @@ TEST_CASE_METHOD(RemoteCollectiveTestFixture,
assert(actual == messageData);
}

usleep(1000 * 500);

remoteWorld.destroy();
});

Expand Down Expand Up @@ -237,6 +304,8 @@ TEST_CASE_METHOD(RemoteCollectiveTestFixture,
nPerRank);
assert(actual == std::vector<int>({ 12, 13, 14, 15 }));

usleep(1000 * 500);

remoteWorld.destroy();
});

Expand Down Expand Up @@ -324,6 +393,8 @@ TEST_CASE_METHOD(RemoteCollectiveTestFixture,
nPerRank);
}

usleep(1000 * 500);

remoteWorld.destroy();
});

Expand Down Expand Up @@ -387,6 +458,8 @@ TEST_CASE_METHOD(RemoteMpiTestFixture,
MPI_INT,
messageData.size());

usleep(1000 * 500);

remoteWorld.destroy();
});

Expand Down Expand Up @@ -440,6 +513,8 @@ TEST_CASE_METHOD(RemoteMpiTestFixture,
remoteWorld.send(sendRank, recvRank, BYTES(&i), MPI_INT, 1);
}

usleep(1000 * 500);

remoteWorld.destroy();
});

Expand Down Expand Up @@ -512,6 +587,8 @@ TEST_CASE_METHOD(RemoteMpiTestFixture,
MPI_STATUS_IGNORE);
}

usleep(1000 * 500);

remoteWorld.destroy();
});

Expand Down

0 comments on commit bee0ef8

Please sign in to comment.