From eeaba44643fa9658589f6ce15f9df2d31c74d40f Mon Sep 17 00:00:00 2001 From: Irene Zhang <iyzhang@myst.cs.washington.edu> Date: Tue, 23 Jun 2015 10:31:56 -0700 Subject: [PATCH] updating tests for VR --- lib/tests/simtransport-test.cc | 19 +++++++++++-------- replication/common/replica.cc | 2 ++ replication/vr/tests/vr-test.cc | 4 ++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/tests/simtransport-test.cc b/lib/tests/simtransport-test.cc index 83d852d..f40826a 100644 --- a/lib/tests/simtransport-test.cc +++ b/lib/tests/simtransport-test.cc @@ -67,11 +67,9 @@ TestReceiver::ReceiveMessage(const TransportAddress &src, class SimTransportTest : public testing::Test { protected: - std::vector<transport::ReplicaAddress> replicaAddrs = - { { "localhost", "12345" }, - { "localhost", "12346" }, - { "localhost", "12347" }}; - transport::Configuration config{3, 1, replicaAddrs}; + std::vector<transport::ReplicaAddress> replicaAddrs; + + transport::Configuration *config; TestReceiver *receiver0; TestReceiver *receiver1; @@ -80,14 +78,19 @@ protected: SimulatedTransport *transport; virtual void SetUp() { + replicaAddrs.push_back(*(new transport::ReplicaAddress("localhost", "12345"))); + replicaAddrs.push_back(*(new transport::ReplicaAddress("localhost", "12346"))); + replicaAddrs.push_back(*(new transport::ReplicaAddress("localhost", "12347"))); + receiver0 = new TestReceiver(); receiver1 = new TestReceiver(); receiver2 = new TestReceiver(); + config = new transport::Configuration(3, 1, replicaAddrs); transport = new SimulatedTransport(); - transport->Register(receiver0, config, 0); - transport->Register(receiver1, config, 1); - transport->Register(receiver2, config, 2); + transport->Register(receiver0, *config, 0); + transport->Register(receiver1, *config, 1); + transport->Register(receiver2, *config, 2); } virtual void TearDown() { diff --git a/replication/common/replica.cc b/replication/common/replica.cc index 92777bb..5a6ad7e 100644 --- a/replication/common/replica.cc +++ b/replication/common/replica.cc @@ -56,7 +56,9 @@ Replica::~Replica() void Replica::LeaderUpcall(opnum_t opnum, const string &op, bool &replicate, string &res) { + Debug("Making leader upcall for operation %s", op.c_str()); app->LeaderUpcall(opnum, op, replicate, res); + Debug("Upcall result: %s %s", replicate ? "yes":"no", res.c_str()); } void diff --git a/replication/vr/tests/vr-test.cc b/replication/vr/tests/vr-test.cc index aec96b5..c3009fe 100644 --- a/replication/vr/tests/vr-test.cc +++ b/replication/vr/tests/vr-test.cc @@ -61,12 +61,12 @@ class VRApp : public AppReplica { public: VRApp(std::vector<string> *o, std::vector<string> *u) : ops(o), unloggedOps(u) { } - void ReplicaUpcall(Replica *r, opnum_t opnum, const string &req, string &reply) { + void ReplicaUpcall(opnum_t opnum, const string &req, string &reply) { ops->push_back(req); reply = "reply: " + req; } - void UnloggedUpcall(Replica *r, const string &req, string &reply) { + void UnloggedUpcall(const string &req, string &reply) { unloggedOps->push_back(req); reply = "unlreply: " + req; } -- GitLab