@Test(timeout = 1000) public void testCommit() throws Exception { log.trace("PaxosTest::testCommit()"); serverL.run(); serverA.run(); serverB.run(); serverC.run(); long id = leader.addProposal(new NullOperation("one")); while (isProposalPending(id)) { Thread.sleep(100); } }
@Override public <T> T collectData(Moderator<T> moderator) { setupSerialPortParameters(this); // open the input stream try { this.out = serialPort.getOutputStream(); this.in = serialPort.getInputStream(); return moderator.conductConversation(this); } catch (IOException e) { throw new RuntimeException(e); } finally { log.trace("Cleaning up port {}...", serialPort); if (this.in != null) { try { this.in.close(); } catch (IOException e) { // ignore this one } } if (this.out != null) { try { this.out.close(); } catch (IOException e) { // ignore this one } } serialPort.removeEventListener(); log.trace("Clean up port {} complete.", serialPort); } }
// TODO fix test // @Test(timeout = 1000) public void testCommitWithFailure() throws Exception { log.trace("PaxosTest::testCommit()"); serverL.run(); serverA.run(); serverB.run(); // C missing long id = leader.addProposal(new NullOperation("one")); while (followA.getProposal(id) == null || followA.getProposal(id).getState() != ProposalState.ACCEPTED || followB.getProposal(id) == null || followB.getProposal(id).getState() != ProposalState.ACCEPTED) { Thread.sleep(100); } }
@Test(timeout = 1000) public void testOperationHanddown() throws Exception { log.trace("PaxosTest::testCommit()"); serverL.run(); serverA.run(); serverB.run(); serverC.run(); long id = leader.addProposal(new NullOperation("one")); while (isProposalPending(id)) { Thread.sleep(100); } assertNotNull(followA.getProposal(id).getOperation()); assertNotNull(followB.getProposal(id).getOperation()); assertNotNull(followC.getProposal(id).getOperation()); }