Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }