public void Follower_as_a_single_node_becomes_leader_automatically() { var hub = new InMemoryTransportHub(); var storageEnvironmentOptions = StorageEnvironmentOptions.CreateMemoryOnly(); storageEnvironmentOptions.OwnsPagers = false; var raftEngineOptions = new RaftEngineOptions( new NodeConnectionInfo { Name = "node1" }, storageEnvironmentOptions, hub.CreateTransportFor("node1"), new DictionaryStateMachine() ) { ElectionTimeout = 1000, HeartbeatTimeout = 1000 / 6 }; PersistentState.ClusterBootstrap(raftEngineOptions); storageEnvironmentOptions.OwnsPagers = true; using (var raftNode = new RaftEngine(raftEngineOptions)) { Assert.Equal(RaftEngineState.Leader, raftNode.State); } }
public void Follower_as_a_single_node_becomes_leader_automatically() { var hub = new InMemoryTransportHub(); var storageEnvironmentOptions = StorageEnvironmentOptions.CreateMemoryOnly(); storageEnvironmentOptions.OwnsPagers = false; var raftEngineOptions = new RaftEngineOptions( new NodeConnectionInfo { Name = "node1" }, storageEnvironmentOptions, hub.CreateTransportFor("node1"), new DictionaryStateMachine() ) { ElectionTimeout = 1000, HeartbeatTimeout = 1000/6 }; PersistentState.ClusterBootstrap(raftEngineOptions); storageEnvironmentOptions.OwnsPagers = true; using (var raftNode = new RaftEngine(raftEngineOptions)) { Assert.Equal(RaftEngineState.Leader, raftNode.State); } }
public RaftTestsBase() { _inMemoryTransportHub = new InMemoryTransportHub(); }