コード例 #1
0
  @Test(groups = "Integration") // because one second wait in succeedsContinually
  public void testDoesNotPromoteIfMasterTimeoutNotExpired() throws Exception {
    persister.delta(
        ManagementPlaneSyncRecordDeltaImpl.builder()
            .node(newManagerMemento(ownNodeId, ManagementNodeState.STANDBY, tickerCurrentMillis()))
            .node(newManagerMemento("node1", ManagementNodeState.MASTER, tickerCurrentMillis()))
            .setMaster("node1")
            .build());

    manager.start(HighAvailabilityMode.AUTO);

    tickerAdvance(Duration.seconds(29));

    // Expect not to be notified, as 29s < 30s timeout (it's a fake clock so won't hit 30, even
    // waiting 1s below)
    Asserts.succeedsContinually(
        new Runnable() {
          @Override
          public void run() {
            assertTrue(
                promotionListener.callTimestamps.isEmpty(),
                "calls=" + promotionListener.callTimestamps);
          }
        });
  }
コード例 #2
0
 private void assertNoEventsContinually() {
   Asserts.succeedsContinually(
       new Runnable() {
         @Override
         public void run() {
           assertTrue(events.isEmpty(), "events=" + events);
         }
       });
 }
コード例 #3
0
 private void assertNoEventsContinually(Duration duration) {
   Asserts.succeedsContinually(
       ImmutableMap.of("timeout", duration),
       new Runnable() {
         @Override
         public void run() {
           assertTrue(events.isEmpty(), "events=" + events);
         }
       });
 }