private void PrimaryToActiveSecondaryTestHelper(bool drainInParallel) { var inst = OperationFetcherTest.Create(drainInParallel); // go to active sec inst.DoStateChangeOperations(ReplicaRole.IdleSecondary, ReplicaRole.ActiveSecondary); // complete the copy queue if (!drainInParallel) { OperationQueueStub.CompleteTaskAndWait(inst.CopyQueue.DrainTasks[0]); } // now go to primary inst.DoStateChangeOperations(ReplicaRole.Primary); // both queues are being drained only once OperationFetcherTest.AssertQueueTaskCount(1, inst.CopyQueue); OperationFetcherTest.AssertQueueTaskCount(1, inst.ReplicationQueue); // now go to active secondary inst.Fetcher.ChangeRole(ReplicaRole.ActiveSecondary); // we have started draining again OperationFetcherTest.AssertQueueTaskCount(1, inst.CopyQueue); OperationFetcherTest.AssertQueueTaskCount(2, inst.ReplicationQueue); }
private void RoleChangeTest(ReplicaRole expectedRole, params object[] roleChangeArgs) { var inst = OperationFetcherTest.Create(); inst.DoStateChangeOperations(roleChangeArgs); Assert.AreEqual <ReplicaRole>(expectedRole, inst.Fetcher.Role); }
public void OperationFetcherTest_DrainInSequentialStartsOnlyCopyQueueOnChangeRole() { var inst = OperationFetcherTest.Create(); inst.Fetcher.ChangeRole(ReplicaRole.IdleSecondary); OperationFetcherTest.AssertQueueTaskCount(1, inst.CopyQueue); OperationFetcherTest.AssertQueueTaskCount(0, inst.ReplicationQueue); }
private void NoneToPrimaryDoesNotDrainAnyQueues(bool drainInParallel) { var inst = OperationFetcherTest.Create(drainInParallel); // primary inst.DoStateChangeOperations(ReplicaRole.Primary); // the count of drains should be = 0 OperationFetcherTest.AssertQueueTaskCount(0, inst.CopyQueue); OperationFetcherTest.AssertQueueTaskCount(0, inst.ReplicationQueue); }
public void OperationFetcherTest_DrainInParallelStartsDrainingBothQueues() { var inst = OperationFetcherTest.Create(true); // become idle sec -> start draining copy queue and replication queue inst.Fetcher.ChangeRole(ReplicaRole.IdleSecondary); // both queues are being drained OperationFetcherTest.AssertQueueTaskCount(1, inst.CopyQueue); OperationFetcherTest.AssertQueueTaskCount(1, inst.ReplicationQueue); }
public void OperationFetcherTest_DrainInParallelDoesNotStartDrainingReplicationQueueTwice() { var inst = OperationFetcherTest.Create(true); // become idle sec -> start draining copy queue // and then go from idle sec -> active sec inst.DoStateChangeOperations(ReplicaRole.IdleSecondary, ReplicaRole.ActiveSecondary); // both queues are being drained only once OperationFetcherTest.AssertQueueTaskCount(1, inst.CopyQueue); OperationFetcherTest.AssertQueueTaskCount(1, inst.ReplicationQueue); }
public void OperationFetcherTest_DrainInSequentialDrainsReplicationQueueAfterCopyQueueIsDone() { var inst = OperationFetcherTest.Create(); inst.Fetcher.ChangeRole(ReplicaRole.IdleSecondary); // complete the draining of the copy queue OperationQueueStub.CompleteTaskAndWait(inst.CopyQueue.DrainTasks[0]); // it should start draining the replicaiton queue now OperationFetcherTest.AssertQueueTaskCount(1, inst.ReplicationQueue); }
public void OperationFetcherTest_DrainInSequentialDoesNotDrainReplicationQueueIfCloseIsCalled() { var inst = OperationFetcherTest.Create(); // become idle sec -> start draining copy queue // call close inst.DoStateChangeOperations(ReplicaRole.IdleSecondary, true); // complete the draining of the copy queue OperationQueueStub.CompleteTaskAndWait(inst.CopyQueue.DrainTasks[0]); // the replication queue should not have been drained OperationFetcherTest.AssertQueueTaskCount(0, inst.ReplicationQueue); }
private void IdleSecondaryToCloseTestHelper(bool drainInParallel) { var inst = OperationFetcherTest.Create(drainInParallel); // change to idle sec inst.Fetcher.ChangeRole(ReplicaRole.IdleSecondary); int copyQueueCount = inst.CopyQueue.DrainTasks.Count; int replicationQueueCount = inst.ReplicationQueue.DrainTasks.Count; // close inst.Fetcher.Close(); // the counts should be the same OperationFetcherTest.AssertQueueTaskCount(copyQueueCount, inst.CopyQueue); OperationFetcherTest.AssertQueueTaskCount(replicationQueueCount, inst.ReplicationQueue); }
private void ActiveSecondaryToCloseTestHelper(bool drainInParallel) { var inst = OperationFetcherTest.Create(drainInParallel); // idle -> active -> close inst.DoStateChangeOperations(ReplicaRole.IdleSecondary, ReplicaRole.ActiveSecondary); if (!drainInParallel) { OperationQueueStub.CompleteTaskAndWait(inst.CopyQueue.DrainTasks[0]); } // the count of drains should be = 1 OperationFetcherTest.AssertQueueTaskCount(1, inst.CopyQueue); OperationFetcherTest.AssertQueueTaskCount(1, inst.ReplicationQueue); // close inst.DoStateChangeOperations(true); // the count of drains should be = 1 OperationFetcherTest.AssertQueueTaskCount(1, inst.CopyQueue); OperationFetcherTest.AssertQueueTaskCount(1, inst.ReplicationQueue); }