53c405c699
Summary: This diff changes the RPC layer to directly return `TResponse` to the user when issuing a `Call<...>` RPC call. The call throws an exception on failure (instead of the previous return `nullopt`). All servers (network, RPC and distributed) are set to have explicit `Shutdown` methods so that a controlled shutdown can always be performed. The object destructors now have `CHECK`s to enforce that the `AwaitShutdown` methods were called. The distributed memgraph is changed that none of the binaries (master/workers) crash when there is a communication failure. Instead, the whole cluster starts a graceful shutdown when a persistent communication error is detected. Transient errors are allowed during execution. The transaction that errored out will be aborted on the whole cluster. The cluster state is managed using a new Heartbeat RPC call. Reviewers: buda, teon.banek, msantl Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1604
55 lines
1.7 KiB
C++
55 lines
1.7 KiB
C++
#include <experimental/optional>
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
#include "communication/rpc/server.hpp"
|
|
#include "storage/concurrent_id_mapper_master.hpp"
|
|
#include "storage/concurrent_id_mapper_worker.hpp"
|
|
#include "storage/types.hpp"
|
|
|
|
template <typename TId>
|
|
class DistributedConcurrentIdMapperTest : public ::testing::Test {
|
|
const std::string kLocal{"127.0.0.1"};
|
|
|
|
protected:
|
|
communication::rpc::Server master_server_{{kLocal, 0}};
|
|
std::experimental::optional<communication::rpc::ClientPool>
|
|
master_client_pool_;
|
|
std::experimental::optional<storage::MasterConcurrentIdMapper<TId>>
|
|
master_mapper_;
|
|
std::experimental::optional<storage::WorkerConcurrentIdMapper<TId>>
|
|
worker_mapper_;
|
|
|
|
void SetUp() override {
|
|
master_client_pool_.emplace(master_server_.endpoint());
|
|
master_mapper_.emplace(master_server_);
|
|
worker_mapper_.emplace(master_client_pool_.value());
|
|
}
|
|
void TearDown() override {
|
|
master_server_.Shutdown();
|
|
master_server_.AwaitShutdown();
|
|
worker_mapper_ = std::experimental::nullopt;
|
|
master_mapper_ = std::experimental::nullopt;
|
|
master_client_pool_ = std::experimental::nullopt;
|
|
}
|
|
};
|
|
|
|
typedef ::testing::Types<storage::Label, storage::EdgeType, storage::Property>
|
|
GraphDbTestTypes;
|
|
TYPED_TEST_CASE(DistributedConcurrentIdMapperTest, GraphDbTestTypes);
|
|
|
|
TYPED_TEST(DistributedConcurrentIdMapperTest, Basic) {
|
|
auto &master = this->master_mapper_.value();
|
|
auto &worker = this->worker_mapper_.value();
|
|
|
|
auto id1 = master.value_to_id("v1");
|
|
EXPECT_EQ(worker.id_to_value(id1), "v1");
|
|
EXPECT_EQ(worker.value_to_id("v1"), id1);
|
|
|
|
auto id2 = worker.value_to_id("v2");
|
|
EXPECT_EQ(master.id_to_value(id2), "v2");
|
|
EXPECT_EQ(master.value_to_id("v2"), id2);
|
|
|
|
EXPECT_NE(id1, id2);
|
|
}
|