memgraph/tests/unit/counters.cpp
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

33 lines
837 B
C++

#include <gtest/gtest.h>
#include "communication/rpc/client_pool.hpp"
#include "communication/rpc/server.hpp"
#include "database/distributed/distributed_counters.hpp"
#include "test_coordination.hpp"
TEST(CountersDistributed, All) {
TestMasterCoordination coordination;
database::MasterCounters master(&coordination);
coordination.Start();
communication::rpc::ClientPool master_client_pool(
coordination.GetServerEndpoint());
database::WorkerCounters w1(&master_client_pool);
database::WorkerCounters w2(&master_client_pool);
EXPECT_EQ(w1.Get("a"), 0);
EXPECT_EQ(w1.Get("a"), 1);
EXPECT_EQ(w2.Get("a"), 2);
EXPECT_EQ(w1.Get("a"), 3);
EXPECT_EQ(master.Get("a"), 4);
EXPECT_EQ(master.Get("b"), 0);
EXPECT_EQ(w2.Get("b"), 1);
w1.Set("b", 42);
EXPECT_EQ(w2.Get("b"), 42);
coordination.Stop();
}