Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void losingQuorumAbruptlyShouldMakeAllInstancesPendingAndReadOnly() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void LosingQuorumAbruptlyShouldMakeAllInstancesPendingAndReadOnly()
        {
            int clusterSize = 5;               // we need 5 to differentiate between all other instances gone and just quorum being gone

            assumeTrue(TestRunConditions.shouldRunAtClusterSize(clusterSize));

            ClusterManager manager = (new ClusterManager.Builder()).withRootDirectory(Dir.cleanDirectory("testcluster")).withCluster(ClusterManager.clusterOfSize(clusterSize)).withSharedConfig(Config()).build();

            try
            {
                manager.Start();
                ClusterManager.ManagedCluster cluster = manager.Cluster;

                cluster.Await(allSeesAllAsAvailable());
                cluster.Await(masterAvailable());

                HighlyAvailableGraphDatabase master = cluster.Master;
                AddSomeData(master);

                /*
                 * we need 3 failures. We'll end up with the old master and a slave connected. They should both be in
                 * PENDING state, allowing reads but not writes. Repairing just one of the removed instances should
                 * result in a master being elected and all instances being read and writable.
                 * The instances we remove do not need additional verification for their state. Their behaviour is already
                 * known by other tests.
                 */
                HighlyAvailableGraphDatabase failed1;
                ClusterManager.RepairKit     rk1;
                HighlyAvailableGraphDatabase failed2;
                HighlyAvailableGraphDatabase failed3;
                HighlyAvailableGraphDatabase remainingSlave;

                failed1        = cluster.AnySlave;
                failed2        = cluster.GetAnySlave(failed1);
                failed3        = cluster.GetAnySlave(failed1, failed2);
                remainingSlave = cluster.GetAnySlave(failed1, failed2, failed3);

                System.Threading.CountdownEvent masterTransitionLatch = new System.Threading.CountdownEvent(1);
                System.Threading.CountdownEvent slaveTransitionLatch  = new System.Threading.CountdownEvent(1);

                SetupForWaitOnSwitchToDetached(master, masterTransitionLatch);
                SetupForWaitOnSwitchToDetached(remainingSlave, slaveTransitionLatch);

                rk1 = KillAbruptly(cluster, failed1, failed2, failed3);

                cluster.Await(memberSeesOtherMemberAsFailed(remainingSlave, failed1));
                cluster.Await(memberSeesOtherMemberAsFailed(remainingSlave, failed2));
                cluster.Await(memberSeesOtherMemberAsFailed(remainingSlave, failed3));

                cluster.Await(memberSeesOtherMemberAsFailed(master, failed1));
                cluster.Await(memberSeesOtherMemberAsFailed(master, failed2));
                cluster.Await(memberSeesOtherMemberAsFailed(master, failed3));

                masterTransitionLatch.await();
                slaveTransitionLatch.await();

                EnsureInstanceIsReadOnlyInPendingState(master);
                EnsureInstanceIsReadOnlyInPendingState(remainingSlave);

                rk1.Repair();

                cluster.Await(masterAvailable(failed2, failed3));
                cluster.Await(masterSeesSlavesAsAvailable(2));

                EnsureInstanceIsWritable(master);
                EnsureInstanceIsWritable(remainingSlave);
                EnsureInstanceIsWritable(failed1);
            }
            finally
            {
                manager.Shutdown();
            }
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void shouldRun()
		 public virtual void ShouldRun()
		 {
			  assumeTrue( TestRunConditions.shouldRunAtClusterSize( _clusterSize ) );
		 }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testFailOver() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TestFailOver()
        {
            assumeTrue(TestRunConditions.shouldRunAtClusterSize(_clusterSize));
            TestFailOver(_clusterSize);
        }