public override void When()
        {
            _followers = new [] { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() };
            BecomeLeader();
            // All of the nodes have acked the first write
            WriterCheckpoint.Write(_firstLogPosition);
            WriterCheckpoint.Flush();
            Service.Handle(new ReplicationTrackingMessage.WriterCheckpointFlushed());
            foreach (var follower in _followers)
            {
                Service.Handle(new ReplicationTrackingMessage.ReplicaWriteAck(follower, _firstLogPosition));
            }
            AssertEx.IsOrBecomesTrue(() => Service.IsCurrent());

            ReplicatedTos.Clear();

            // Followers 3 and 4 are lagging behind, they ack the previous positions
            WriterCheckpoint.Write(_secondLogPosition);
            WriterCheckpoint.Flush();
            Service.Handle(new ReplicationTrackingMessage.WriterCheckpointFlushed());
            Service.Handle(new ReplicationTrackingMessage.ReplicaWriteAck(_followers[0], _secondLogPosition));
            Service.Handle(new ReplicationTrackingMessage.ReplicaWriteAck(_followers[1], _secondLogPosition));
            Service.Handle(new ReplicationTrackingMessage.ReplicaWriteAck(_followers[2], _firstLogPosition));
            Service.Handle(new ReplicationTrackingMessage.ReplicaWriteAck(_followers[3], _firstLogPosition));
            AssertEx.IsOrBecomesTrue(() => Service.IsCurrent());
        }
Esempio n. 2
0
 public override void When()
 {
     BecomeLeader();
     WriterCheckpoint.Write(_logPosition);
     WriterCheckpoint.Flush();
     Service.Handle(new ReplicationTrackingMessage.WriterCheckpointFlushed());
     AssertEx.IsOrBecomesTrue(() => Service.IsCurrent());
 }
 public override void When()
 {
     BecomeMaster();
     WriterCheckpoint.Write(_logPosition);
     WriterCheckpoint.Flush();
     Service.Handle(new ReplicationTrackingMessage.WriterCheckpointFlushed());
     Service.Handle(new ReplicationTrackingMessage.ReplicaWriteAck(Guid.NewGuid(), _logPosition));
     AssertEx.IsOrBecomesTrue(() => Service.IsIdle());
 }
 public override void When()
 {
     BecomeMaster();
     // All of the nodes have acked the first write
     WriterCheckpoint.Write(_firstLogPosition);
     WriterCheckpoint.Flush();
     Service.Handle(new ReplicationTrackingMessage.WriterCheckpointFlushed());
     Service.Handle(new ReplicationTrackingMessage.ReplicaWriteAck(_replica1, _firstLogPosition));
     Service.Handle(new ReplicationTrackingMessage.ReplicaWriteAck(_replica2, _firstLogPosition - 100));
     Service.Handle(new ReplicationTrackingMessage.ReplicaWriteAck(Guid.NewGuid(), _firstLogPosition - 100));
     Service.Handle(new ReplicationTrackingMessage.ReplicaWriteAck(Guid.NewGuid(), _firstLogPosition - 100));
     AssertEx.IsOrBecomesTrue(() => Service.IsCurrent());
 }
Esempio n. 5
0
 public override void When()
 {
     BecomeMaster();
     WriterCheckpoint.Write(_logPosition);
     WriterCheckpoint.Flush();
     Service.Handle(new ReplicationTrackingMessage.WriterCheckpointFlushed());
     Service.Handle(new ReplicationTrackingMessage.ReplicaWriteAck(_replicaId1, _logPosition));
     Service.Handle(new SystemMessage.VNodeConnectionLost(
                        PortsHelper.GetLoopback(),
                        Guid.NewGuid(),
                        _replicaId1));
     Service.Handle(new ReplicationTrackingMessage.ReplicaWriteAck(_replicaId2, _logPosition));
     AssertEx.IsOrBecomesTrue(() => Service.IsCurrent());
 }
        public override void When()
        {
            BecomeLeader();
            // All of the nodes have acked the first write
            WriterCheckpoint.Write(_firstLogPosition);
            WriterCheckpoint.Flush();
            Service.Handle(new ReplicationTrackingMessage.WriterCheckpointFlushed());
            Service.Handle(new ReplicationTrackingMessage.ReplicaWriteAck(_follower1, _firstLogPosition));
            Service.Handle(new ReplicationTrackingMessage.ReplicaWriteAck(_follower2, _firstLogPosition));
            AssertEx.IsOrBecomesTrue(() => Service.IsCurrent());

            ReplicatedTos.Clear();

            // Follower 2 has lost connection and does not ack the write
            WriterCheckpoint.Write(_secondLogPosition);
            WriterCheckpoint.Flush();
            Service.Handle(new ReplicationTrackingMessage.WriterCheckpointFlushed());
            Service.Handle(new ReplicationTrackingMessage.ReplicaWriteAck(_follower1, _secondLogPosition));
            AssertEx.IsOrBecomesTrue(() => Service.IsCurrent());
        }
Esempio n. 7
0
        public override void When()
        {
            BecomeMaster();
            WriterCheckpoint.Write(_logPosition);
            WriterCheckpoint.Flush();
            Service.Handle(new ReplicationTrackingMessage.WriterCheckpointFlushed());
            Service.Handle(new ReplicationTrackingMessage.ReplicaWriteAck(_replicaId1, _logPosition));
            Service.Handle(new SystemMessage.VNodeConnectionLost(
                               PortsHelper.GetLoopback(),
                               Guid.NewGuid(),
                               _replicaId1));
            AssertEx.IsOrBecomesTrue(() => Service.IsCurrent());             //n.b. we still don't have quorum here

            //moving directly to log position 2 after rejoin
            WriterCheckpoint.Write(_logPosition2);
            WriterCheckpoint.Flush();
            Service.Handle(new ReplicationTrackingMessage.ReplicaWriteAck(_replicaId1, _logPosition2));
            Service.Handle(new ReplicationTrackingMessage.ReplicaWriteAck(_replicaId2, _logPosition2));
            AssertEx.IsOrBecomesTrue(() => Service.IsCurrent());
        }