summaryrefslogtreecommitdiff
path: root/same/src/test/java
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-04-17 17:05:32 +0200
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-04-17 17:05:32 +0200
commit67e3b2d5a0092d41df629e950a38a80743717d81 (patch)
treed545a33ff9cc9109ed79adcc6b3e5ef13c569095 /same/src/test/java
parente2d00cd5fa29e1a5cada502248cd81358e4da491 (diff)
Master→Client communication uses protobuf services.
– This change causes inconsistency in the .participants list and as a result some Paxos related tests run infinitely.
Diffstat (limited to 'same/src/test/java')
-rw-r--r--same/src/test/java/com/orbekk/same/FunctionalTest.java7
-rw-r--r--same/src/test/java/com/orbekk/same/MasterTest.java69
2 files changed, 8 insertions, 68 deletions
diff --git a/same/src/test/java/com/orbekk/same/FunctionalTest.java b/same/src/test/java/com/orbekk/same/FunctionalTest.java
index 0a20fc1..79bd9b8 100644
--- a/same/src/test/java/com/orbekk/same/FunctionalTest.java
+++ b/same/src/test/java/com/orbekk/same/FunctionalTest.java
@@ -30,13 +30,10 @@ public class FunctionalTest {
List<Client> clients = new ArrayList<Client>();
TestConnectionManager connections = new TestConnectionManager();
TestBroadcaster broadcaster = new TestBroadcaster();
- MasterServiceProxy masterServiceProxy;
@Before public void setUp() {
master = Master.create(connections,
broadcaster, masterUrl, "TestMaster", masterLocation);
- masterServiceProxy = new MasterServiceProxy(master.getService());
- connections.masterMap.put(masterUrl, masterServiceProxy);
connections.masterMap0.put(masterLocation, master.getNewService());
client1 = newClient("TestClient1", "http://client1/ClientService.json",
"client1");
@@ -118,7 +115,6 @@ public class FunctionalTest {
String newMasterLocation = "newMaster:1";
final Master newMaster = Master.create(connections,
broadcaster, newMasterUrl, "TestMaster", newMasterLocation);
- connections.masterMap.put(newMasterUrl, newMaster.getService());
joinClients();
MasterController controller = new MasterController() {
@Override
@@ -143,7 +139,6 @@ public class FunctionalTest {
String newMasterLocation = "newMaster:1";
final Master newMaster = Master.create(connections,
broadcaster, newMasterUrl, "TestMaster", newMasterLocation);
- connections.masterMap.put(newMasterUrl, newMaster.getService());
joinClients();
MasterController controller = new MasterController() {
boolean firstMaster = true;
@@ -172,7 +167,6 @@ public class FunctionalTest {
String newMasterLocation = "newMaster:2";
final Master newMaster = Master.create(connections,
broadcaster, newMasterUrl, "TestMaster", newMasterLocation);
- connections.masterMap.put(newMasterUrl, newMaster.getService());
joinClients();
MasterController controller = new MasterController() {
@Override
@@ -188,7 +182,6 @@ public class FunctionalTest {
client2.setMasterController(controller);
client3.setMasterController(controller);
Variable<String> x1 = vf1.createString("TestMasterFailure");
- masterServiceProxy.setService(null);
connections.masterMap0.put(masterLocation, null);
assertThat(x1.set("Woop, woop").getStatus().getStatusCode(),
is(DelayedOperation.Status.ERROR));
diff --git a/same/src/test/java/com/orbekk/same/MasterTest.java b/same/src/test/java/com/orbekk/same/MasterTest.java
index 96f8670..f244d1b 100644
--- a/same/src/test/java/com/orbekk/same/MasterTest.java
+++ b/same/src/test/java/com/orbekk/same/MasterTest.java
@@ -15,7 +15,6 @@ public class MasterTest {
private TestConnectionManager connections = new TestConnectionManager();
private TestBroadcaster broadcaster = new TestBroadcaster();
private Master master;
- private MasterService masterS;
public static class UnreachableClient implements ClientService {
@Override
@@ -44,88 +43,36 @@ public class MasterTest {
state.update(".masterLocation", masterLocation, 1);
master = new Master(state, connections, broadcaster,
"http://master/MasterService.json", masterLocation);
- masterS = master.getService();
- connections.masterMap.put("http://master/MasterService.json",
- masterS);
connections.masterMap0.put("master:1000", master.getNewService());
}
@Test
- public void joinNetworkAddsClient() throws Exception {
- masterS.joinNetworkRequest("http://clientUrl");
- List<String> participants = state.getList(".participants");
- assertTrue(participants.contains("http://clientUrl"));
- }
-
- @Test
public void clientJoin() throws Exception {
Client client = new Client(
new State("ClientNetwork"), connections,
"http://client/ClientService.json", "clientLocation", null);
- ClientService clientS = client.getService();
- connections.clientMap.put("http://client/ClientService.json", clientS);
connections.clientMap0.put("clientLocation", client.getNewService());
client.joinNetwork(master.getMasterInfo());
master.performWork();
System.out.println(state);
System.out.println(master.state);
- assertTrue(state.getList(".participants").contains("http://client/ClientService.json"));
+ assertTrue(state.getList(State.PARTICIPANTS)
+ .contains("clientLocation"));
assertEquals(state, client.testGetState());
}
@Test
- @Ignore // Uses old services. Tested by functional test.
+ @Ignore
public void updateStateRequest() throws Exception {
- Client client1 = new Client(
- new State("ClientNetwork"), connections,
- "http://client/ClientService.json", "clientLocation2", null);
- ClientService client1S = client1.getService();
- connections.clientMap.put("http://client/ClientService.json", client1S);
- connections.clientMap0.put("clientLocation1", client1.getNewService());
- Client client2 = new Client(
- new State("ClientNetwork"), connections,
- "http://client2/ClientService.json", "clientLocation2", null);
- ClientService client2S = client2.getService();
- connections.clientMap.put("http://client2/ClientService.json", client2S);
- connections.clientMap0.put("clientLocation2", client2.getNewService());
-
- client1.joinNetwork(master.getMasterInfo());
- client2.joinNetwork(master.getMasterInfo());
-
- master.performWork();
- assertTrue(state.getList(".participants").contains("http://client/ClientService.json"));
- assertTrue(state.getList(".participants").contains("http://client2/ClientService.json"));
- assertEquals(state, client1.testGetState());
-
- assertTrue(masterS.updateStateRequest("A", "1", 0));
- master.performWork();
-
- assertEquals(state, client1.testGetState());
- assertEquals(state, client2.testGetState());
-
- assertFalse(masterS.updateStateRequest("A", "2", 0));
- assertTrue(masterS.updateStateRequest("A", "3", 1));
- master.performWork();
-
- assertEquals(state, client1.testGetState());
- assertEquals(state, client2.testGetState());
+ // TODO: Implement this test.
+ throw new IllegalStateException();
}
@Test
+ @Ignore
public void masterRemovesParticipant() throws Exception {
- Client client = new Client(
- new State("ClientNetwork"), connections,
- "http://client/ClientService.json", "clientLocation", null);
- connections.clientMap0.put("clientLocation", client.getNewService());
- client.joinNetwork(master.getMasterInfo());
- master.performWork();
- assertTrue(state.getList(".participants0").contains("clientLocation"));
-
- connections.clientMap0.put("clientLocation", null);
- masterS.updateStateRequest("NewState", "NewStateData", 0);
- master.performWork();
-
- assertEquals("[]", state.getDataOf(".participants0"));
+ // TODO: Implement this test.
+ throw new IllegalStateException();
}
}