From a4a0c66483fd763901c43513f8fbca65b0e7c5a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjetil=20=C3=98rbekk?= Date: Wed, 25 Apr 2012 10:59:52 +0200 Subject: Set timeouts for all RPCs. Implemented with an RpcFactory. --- .../java/com/orbekk/paxos/PaxosServiceFunctionalTest.java | 14 ++++++++------ same/src/test/java/com/orbekk/same/FunctionalTest.java | 11 ++++++----- same/src/test/java/com/orbekk/same/MasterTest.java | 5 +++-- 3 files changed, 17 insertions(+), 13 deletions(-) (limited to 'same/src/test') diff --git a/same/src/test/java/com/orbekk/paxos/PaxosServiceFunctionalTest.java b/same/src/test/java/com/orbekk/paxos/PaxosServiceFunctionalTest.java index 98631b0..2918f3e 100644 --- a/same/src/test/java/com/orbekk/paxos/PaxosServiceFunctionalTest.java +++ b/same/src/test/java/com/orbekk/paxos/PaxosServiceFunctionalTest.java @@ -15,12 +15,14 @@ import org.junit.Test; import com.orbekk.protobuf.SimpleProtobufServer; import com.orbekk.same.ConnectionManagerImpl; +import com.orbekk.same.RpcFactory; import com.orbekk.same.Services.ClientState; public class PaxosServiceFunctionalTest { ConnectionManagerImpl connections = new ConnectionManagerImpl(500, 500); List paxosUrls = new ArrayList(); List servers = new ArrayList(); + RpcFactory rpcf = new RpcFactory(5000); String myUrl; int successfulProposals = 0; ClientState client1 = ClientState.newBuilder() @@ -70,14 +72,14 @@ public class PaxosServiceFunctionalTest { @Test public void testMasterElection() throws InterruptedException { MasterProposer m1 = new MasterProposer(client1, paxosUrls, - connections); + connections, rpcf); assertTrue(m1.propose(1)); } @Test public void testMasterElectionTask() throws InterruptedException, ExecutionException { MasterProposer m1 = new MasterProposer(client1, paxosUrls, - connections); + connections, rpcf); Future result = m1.startProposalTask(1, null); assertEquals(new Integer(1), result.get()); } @@ -85,7 +87,7 @@ public class PaxosServiceFunctionalTest { @Test public void cancelledElection() throws InterruptedException { MasterProposer m1 = new MasterProposer(client1, paxosUrls, - connections); + connections, rpcf); assertTrue(m1.propose(1)); Future result = m1.startProposalTask(1, sleepForever); @@ -96,10 +98,10 @@ public class PaxosServiceFunctionalTest { @Test public void testOnlyOneCompletes() throws InterruptedException, ExecutionException { MasterProposer m1 = new MasterProposer(client1, paxosUrls, - connections); + connections, rpcf); ClientState client2 = ClientState.newBuilder().setLocation("client2").build(); MasterProposer m2 = new MasterProposer(client2, paxosUrls, - connections); + connections, rpcf); final Future result1 = m1.startProposalTask(1, sleepForever); final Future result2 = m2.startProposalTask(1, sleepForever); @@ -160,7 +162,7 @@ public class PaxosServiceFunctionalTest { .build(); MasterProposer proposer = new MasterProposer(client, paxosUrls, - connections); + connections, rpcf); try { if (proposer.proposeRetry(1)) { incrementSuccessfulProposals(); diff --git a/same/src/test/java/com/orbekk/same/FunctionalTest.java b/same/src/test/java/com/orbekk/same/FunctionalTest.java index c5d9a56..275eaac 100644 --- a/same/src/test/java/com/orbekk/same/FunctionalTest.java +++ b/same/src/test/java/com/orbekk/same/FunctionalTest.java @@ -29,10 +29,11 @@ public class FunctionalTest { VariableFactory vf3; List clients = new ArrayList(); TestConnectionManager connections = new TestConnectionManager(); + RpcFactory rpcf = new RpcFactory(5000); @Before public void setUp() { master = Master.create(connections, - masterUrl, "TestMaster", masterLocation); + masterUrl, "TestMaster", masterLocation, rpcf); connections.masterMap0.put(masterLocation, master.getNewService()); client1 = newClient("TestClient1", "http://client1/ClientService.json", "client1"); @@ -47,7 +48,7 @@ public class FunctionalTest { Client newClient(String clientName, String clientUrl, String location) { Client client = new Client(new State(clientName), connections, - clientUrl, location); + clientUrl, location, rpcf); connections.clientMap0.put(location, client.getNewService()); clients.add(client); String paxosUrl = clientUrl.replace("ClientService", "PaxosService"); @@ -112,7 +113,7 @@ public class FunctionalTest { String newMasterUrl = "http://newMaster/MasterService.json"; String newMasterLocation = "newMaster:1"; final Master newMaster = Master.create(connections, - newMasterUrl, "TestMaster", newMasterLocation); + newMasterUrl, "TestMaster", newMasterLocation, rpcf); joinClients(); MasterController controller = new MasterController() { @Override @@ -136,7 +137,7 @@ public class FunctionalTest { String newMasterUrl = "http://newMaster/MasterService.json"; String newMasterLocation = "newMaster:1"; final Master newMaster = Master.create(connections, - newMasterUrl, "TestMaster", newMasterLocation); + newMasterUrl, "TestMaster", newMasterLocation, rpcf); joinClients(); MasterController controller = new MasterController() { boolean firstMaster = true; @@ -164,7 +165,7 @@ public class FunctionalTest { String newMasterUrl = "http://newMaster/MasterService.json"; String newMasterLocation = "newMaster:2"; final Master newMaster = Master.create(connections, - newMasterUrl, "TestMaster", newMasterLocation); + newMasterUrl, "TestMaster", newMasterLocation, rpcf); joinClients(); MasterController controller = new MasterController() { @Override diff --git a/same/src/test/java/com/orbekk/same/MasterTest.java b/same/src/test/java/com/orbekk/same/MasterTest.java index 50b3302..f22e9e1 100644 --- a/same/src/test/java/com/orbekk/same/MasterTest.java +++ b/same/src/test/java/com/orbekk/same/MasterTest.java @@ -14,6 +14,7 @@ public class MasterTest { private State state = new State("TestNetwork"); private TestConnectionManager connections = new TestConnectionManager(); private Master master; + private RpcFactory rpcf = new RpcFactory(5000); @Before public void setUp() { @@ -21,7 +22,7 @@ public class MasterTest { state.update(".masterUrl", "http://master/MasterService.json", 1); state.update(".masterLocation", masterLocation, 1); master = new Master(state, connections, - "http://master/MasterService.json", masterLocation); + "http://master/MasterService.json", masterLocation, rpcf); connections.masterMap0.put("master:1000", master.getNewService()); } @@ -29,7 +30,7 @@ public class MasterTest { public void clientJoin() throws Exception { Client client = new Client( new State("ClientNetwork"), connections, - "http://client/ClientService.json", "clientLocation"); + "http://client/ClientService.json", "clientLocation", rpcf); connections.clientMap0.put("clientLocation", client.getNewService()); client.joinNetwork(master.getMasterInfo()); master.performWork(); -- cgit v1.2.3