Add database master test
Summary: Seperate rpc server names Reviewers: florijan, teon.banek Reviewed By: florijan Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1118
This commit is contained in:
parent
9361d79c6d
commit
68a75eeca2
@ -32,7 +32,10 @@ ID_VALUE_RPC_CALLS(Property)
|
||||
template <typename TId>
|
||||
MasterConcurrentIdMapper<TId>::MasterConcurrentIdMapper(
|
||||
communication::messaging::System &system)
|
||||
: rpc_server_(system, kConcurrentIdMapperRpc) {
|
||||
// We have to make sure our rpc server name is unique with regards to type.
|
||||
// Otherwise we will try to reuse the same rpc server name for different
|
||||
// types (Label/EdgeType/Property)
|
||||
: rpc_server_(system, impl::RpcServerNameFromType<TId>()) {
|
||||
RegisterRpc(*this, rpc_server_);
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,16 @@ namespace storage {
|
||||
const std::string kConcurrentIdMapperRpc = "ConcurrentIdMapper";
|
||||
const auto kConcurrentIdMapperRpcTimeout = 300ms;
|
||||
|
||||
namespace impl {
|
||||
|
||||
/// Returns rpc server name by template type
|
||||
template <typename TType>
|
||||
std::string RpcServerNameFromType() {
|
||||
return kConcurrentIdMapperRpc + "_" + typeid(TType).name();
|
||||
}
|
||||
|
||||
}; // namespace impl
|
||||
|
||||
#define ID_VALUE_RPC(type) \
|
||||
RPC_SINGLE_MEMBER_MESSAGE(type##IdReq, std::string); \
|
||||
RPC_SINGLE_MEMBER_MESSAGE(type##IdRes, storage::type); \
|
||||
|
@ -35,7 +35,8 @@ template <typename TId>
|
||||
WorkerConcurrentIdMapper<TId>::WorkerConcurrentIdMapper(
|
||||
communication::messaging::System &system,
|
||||
const io::network::Endpoint &master_endpoint)
|
||||
: rpc_client_(system, master_endpoint, kConcurrentIdMapperRpc) {}
|
||||
: rpc_client_(system, master_endpoint, impl::RpcServerNameFromType<TId>()) {
|
||||
}
|
||||
|
||||
template <typename TId>
|
||||
TId WorkerConcurrentIdMapper<TId>::value_to_id(const std::string &value) {
|
||||
|
11
tests/unit/database_master.cpp
Normal file
11
tests/unit/database_master.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "config.hpp"
|
||||
#include "database/graph_db.hpp"
|
||||
|
||||
TEST(DatabaseMaster, Instantiate) {
|
||||
database::Config config;
|
||||
config.master_endpoint = io::network::Endpoint("127.0.0.1", 0);
|
||||
config.worker_id = 0;
|
||||
database::Master master(config);
|
||||
}
|
Loading…
Reference in New Issue
Block a user