/* * This assumes an instance leaves the cluster normally and then rejoins, without any elections in between. The * expected result is that it will succeed in sending election results. */ //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void electorLeavingAndRejoiningWithNoElectionsInBetweenMustStillHaveElectionsGoThrough() public virtual void ElectorLeavingAndRejoiningWithNoElectionsInBetweenMustStillHaveElectionsGoThrough() { // Given const string role1 = "coordinator1"; InstanceId me = new InstanceId(1); InstanceId leavingInstance = new InstanceId(2); InstanceId forQuorum = new InstanceId(3); Config config = mock(typeof(Config)); when(config.Get(ClusterSettings.max_acceptors)).thenReturn(10); ClusterConfiguration clusterConfiguration = mock(typeof(ClusterConfiguration)); IList <InstanceId> clusterMemberIds = new LinkedList <InstanceId>(); clusterMemberIds.Add(leavingInstance); clusterMemberIds.Add(me); clusterMemberIds.Add(forQuorum); when(clusterConfiguration.MemberIds).thenReturn(clusterMemberIds); MultiPaxosContext context = new MultiPaxosContext(me, Iterables.iterable(new ElectionRole(role1)), clusterConfiguration, ThreadStart.run, NullLogProvider.Instance, mock(typeof(ObjectInputStreamFactory)), mock(typeof(ObjectOutputStreamFactory)), mock(typeof(AcceptorInstanceStore)), mock(typeof(Timeouts)), mock(typeof(ElectionCredentialsProvider)), config); ClusterContext clusterContext = context.ClusterContext; clusterContext.LastElector = leavingInstance; clusterContext.LastElectorVersion = 8; // When the elector leaves the cluster clusterContext.Left(leavingInstance); // Then the elector is reset to defaults assertEquals(clusterContext.LastElector, InstanceId.NONE); assertEquals(clusterContext.LastElectorVersion, Org.Neo4j.cluster.protocol.cluster.ClusterContext_Fields.NO_ELECTOR_VERSION); // When the elector comes back with an election result // We don't need to join, election results do not check for elector membership clusterContext.Elected(role1, forQuorum, leavingInstance, 9); // Then the result is actually respected assertEquals(clusterContext.LastElector, leavingInstance); assertEquals(clusterContext.LastElectorVersion, 9); }