memgraph/tests/unit/test_coordination.hpp
Matej Ferencevic cdaf7581bf Add explicit start to servers
Reviewers: teon.banek

Reviewed By: teon.banek

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D1661
2018-10-16 11:39:42 +02:00

42 lines
974 B
C++

#pragma once
#include <gtest/gtest.h>
#include "distributed/coordination.hpp"
const std::string kLocal = "127.0.0.1";
// TODO (mferencevic): These test classes should be replaced with the real
// coordination once `ClusterDiscoveryXYZ` is merged with `CoordinationXYZ`.
class TestMasterCoordination : public distributed::Coordination {
public:
TestMasterCoordination()
: distributed::Coordination({kLocal, 0}, 0, {kLocal, 0}) {}
void Start() {
ASSERT_TRUE(server_.Start());
}
void Stop() {
server_.Shutdown();
server_.AwaitShutdown();
}
};
class TestWorkerCoordination : public distributed::Coordination {
public:
TestWorkerCoordination(const io::network::Endpoint &master_endpoint,
int worker_id)
: distributed::Coordination({kLocal, 0}, worker_id, master_endpoint) {}
void Start() {
ASSERT_TRUE(server_.Start());
}
void Stop() {
server_.Shutdown();
server_.AwaitShutdown();
}
};