Package net.kuujo.copycat.test

Examples of net.kuujo.copycat.test.TestCluster.stop()


    node3.instance().cluster().config().addRemoteMember(new Member("foobarbaz"));

    // First, the leader should have replicated a join configuration.
    node1.await().membershipChange();
    Assert.assertNotNull(node1.instance().clusterManager().cluster().remoteMember("foobarbaz"));
    cluster.stop();
  }

  /**
   * Tests that the leader's reduced cluster configuration is logged and replicated.
   */
 
View Full Code Here


      Assert.assertNull(node1.instance().clusterManager().cluster().remoteMember("foobarbaz"));
    } else {
      node1.await().membershipChange();
      Assert.assertNull(node1.instance().clusterManager().cluster().remoteMember("foobarbaz"));
    }
    cluster.stop();
  }

}
View Full Code Here

    TestNode node1 = new TestNode().withCluster("foo").withProtocol(protocol);
    cluster.addNode(node1);
    cluster.start();
    node1.await().electedLeader();
    Assert.assertTrue(node1.instance().isLeader());
    cluster.stop();
  }

  /**
   * Tests that a leader is elected in a double-node cluster.
   */
 
View Full Code Here

    TestNode node2 = new TestNode().withCluster("bar", "foo").withProtocol(protocol);
    cluster.addNode(node2);
    cluster.start();
    node1.await().leaderElected();
    Assert.assertTrue(node1.instance().isLeader() || node2.instance().isLeader());
    cluster.stop();
  }

  /**
   * Tests that a leader is elected in a triple-node cluster.
   */
 
View Full Code Here

    TestNode node3 = new TestNode().withCluster("baz", "foo", "bar").withProtocol(protocol);
    cluster.addNode(node3);
    cluster.start();
    node1.await().leaderElected();
    Assert.assertTrue(node1.instance().isLeader() || node2.instance().isLeader() || node3.instance().isLeader());
    cluster.stop();
  }

  /**
   * Tests that the candidate with the most up-to-date log is elected on startup.
   */
 
View Full Code Here

    cluster.start();

    node1.await().electedLeader();
    Assert.assertTrue(node1.instance().isLeader());
    cluster.stop();
  }

  /**
   * Test candidate with most up-to-date log elected after failure.
   */
 
View Full Code Here

    cluster.start();

    node2.await().electedLeader();
    Assert.assertTrue(node2.instance().isLeader());
    cluster.stop();
  }

  /**
   * Tests that candidates restart an election during a split vote.
   */
 
View Full Code Here

    cluster.start();

    node1.await().electedLeader();
    Assert.assertTrue(node1.instance().isLeader());
    Assert.assertTrue(node1.instance().currentTerm() > 3);
    cluster.stop();
  }

  /**
   * Tests that only a single leader is elected when more than one node is equal in terms of state.
   */
 
View Full Code Here

        leaderCount++;
      }
    }

    Assert.assertEquals(1, leaderCount);
    cluster.stop();
  }

}
View Full Code Here

    Entry firstEntry = node3.log().firstEntry();
    Assert.assertTrue(firstEntry instanceof SnapshotEntry);
    Assert.assertEquals("Hello world!", new String(((SnapshotEntry) firstEntry).data()));

    cluster.stop();
  }

  /**
   * Tests that a follower takes a snapshot of its state machine and compacts its log.
   */
 
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.