Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotAchieveGoalIfBeyondRoundTimeout()
        public virtual void ShouldNotAchieveGoalIfBeyondRoundTimeout()
        {
            FakeClock clock = Clocks.fakeClock();
            StubLog   log   = new StubLog(this);

            log.AppendIndex = 10;
            CatchupGoalTracker catchupGoalTracker = new CatchupGoalTracker(log, clock, ROUND_TIMEOUT, CATCHUP_TIMEOUT);

            clock.Forward(ROUND_TIMEOUT + 5, TimeUnit.MILLISECONDS);
            catchupGoalTracker.UpdateProgress((new FollowerState()).onSuccessResponse(10));

            assertFalse(catchupGoalTracker.GoalAchieved);
            assertFalse(catchupGoalTracker.Finished);
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFailToAchieveGoalDueToCatchupTimeoutExpiringEvenThoughWeDoEventuallyAchieveTarget()
        public virtual void ShouldFailToAchieveGoalDueToCatchupTimeoutExpiringEvenThoughWeDoEventuallyAchieveTarget()
        {
            FakeClock clock = Clocks.fakeClock();
            StubLog   log   = new StubLog(this);

            log.AppendIndex = 10;
            CatchupGoalTracker catchupGoalTracker = new CatchupGoalTracker(log, clock, ROUND_TIMEOUT, CATCHUP_TIMEOUT);

            // when
            clock.Forward(CATCHUP_TIMEOUT + 10, TimeUnit.MILLISECONDS);
            catchupGoalTracker.UpdateProgress((new FollowerState()).onSuccessResponse(10));

            // then
            assertFalse(catchupGoalTracker.GoalAchieved);
            assertTrue(catchupGoalTracker.Finished);
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void goalAchievedWhenCatchupRoundDurationLessThanTarget()
        public virtual void GoalAchievedWhenCatchupRoundDurationLessThanTarget()
        {
            FakeClock clock           = Clocks.fakeClock();
            long      electionTimeout = 15;
            StubLog   log             = new StubLog(this);

            log.AppendIndex = 10;
            CatchupGoal goal = new CatchupGoal(log, clock, electionTimeout);

            log.AppendIndex = 20;
            clock.Forward(10, MILLISECONDS);
            assertFalse(goal.Achieved(new FollowerState()));

            log.AppendIndex = 30;
            clock.Forward(10, MILLISECONDS);
            assertFalse(goal.Achieved((new FollowerState()).onSuccessResponse(10)));

            log.AppendIndex = 40;
            clock.Forward(10, MILLISECONDS);
            assertTrue(goal.Achieved((new FollowerState()).onSuccessResponse(30)));
        }
Ejemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotFinishIfRoundsNotExhausted()
        public virtual void ShouldNotFinishIfRoundsNotExhausted()
        {
            FakeClock clock = Clocks.fakeClock();
            StubLog   log   = new StubLog(this);

            long appendIndex = 10;

            log.AppendIndex = appendIndex;
            CatchupGoalTracker catchupGoalTracker = new CatchupGoalTracker(log, clock, ROUND_TIMEOUT, CATCHUP_TIMEOUT);

            for (int i = 0; i < CatchupGoalTracker.MAX_ROUNDS - 5; i++)
            {
                appendIndex    += 10;
                log.AppendIndex = appendIndex;
                clock.Forward(ROUND_TIMEOUT + 1, TimeUnit.MILLISECONDS);
                catchupGoalTracker.UpdateProgress((new FollowerState()).onSuccessResponse(appendIndex));
            }

            // then
            assertFalse(catchupGoalTracker.GoalAchieved);
            assertFalse(catchupGoalTracker.Finished);
        }