public void RP_PFO_E2A_Test()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();
                var client = GetSiteRecoveryClient(CustomHttpHandler);

                var requestHeaders = RequestHeaders;
                requestHeaders.AgentAuthenticationHeader = GenerateAgentAuthenticationHeader(requestHeaders.ClientRequestId);

                var responseRP = client.RecoveryPlan.List(RequestHeaders);

                JobResponse response = new JobResponse();
                foreach (var rp in responseRP.RecoveryPlans)
                {
                    RpPlannedFailoverRequest request = new RpPlannedFailoverRequest();
                    request.FailoverDirection   = "PrimaryToRecovery";
                    request.ReplicationProvider = "HyperVReplicaAzure";
                    AzureFailoverInput foInput = new AzureFailoverInput();
                    foInput.VaultLocation = VaultLocation;
                    request.ReplicationProviderSettings = DataContractUtils.Serialize <AzureFailoverInput>
                                                              (foInput);
                    response = client.RecoveryPlan.RecoveryPlanPlannedFailover(
                        rp.ID,
                        request,
                        requestHeaders);
                }

                Assert.NotNull(response.Job);
                Assert.NotNull(response.Job.ID);
                Assert.True(response.Job.Errors.Count < 1, "Errors found while doing unplanned failover operation");
                Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            }
        }
        public void TestFailoverTest()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();
                var client = GetSiteRecoveryClient(CustomHttpHandler);

                var requestHeaders = RequestHeaders;
                requestHeaders.AgentAuthenticationHeader = GenerateAgentAuthenticationHeader(requestHeaders.ClientRequestId);

                var responsePC = client.ProtectionContainer.List(RequestHeaders);

                JobResponse response       = new JobResponse();
                bool        desiredPEFound = false;
                foreach (var pc in responsePC.ProtectionContainers)
                {
                    var responsePEs = client.ProtectionEntity.List(pc.ID, RequestHeaders);
                    response = null;
                    foreach (var pe in responsePEs.ProtectionEntities)
                    {
                        if (pe.Protected == true)
                        {
                            TestFailoverRequest request = new TestFailoverRequest();
                            request.FailoverDirection   = "PrimaryToRecovery";
                            request.ReplicationProvider = pe.ReplicationProvider;
                            if (pe.ReplicationProvider == "HyperVReplicaAzure")
                            {
                                AzureFailoverInput blob = new AzureFailoverInput();
                                blob.VaultLocation = VaultLocation;
                                request.ReplicationProviderSettings = DataContractUtils.Serialize <AzureFailoverInput>(blob);
                            }
                            else
                            {
                                request.ReplicationProviderSettings = "";
                            }

                            request.NetworkID   = "ID";
                            request.NetworkType = "Type";
                            response            = client.ProtectionEntity.TestFailover(
                                pe.ProtectionContainerId,
                                pe.ID,
                                request,
                                requestHeaders);
                            desiredPEFound = true;
                            break;
                        }
                    }

                    if (desiredPEFound)
                    {
                        break;
                    }
                }

                Assert.NotNull(response.Job);
                Assert.NotNull(response.Job.ID);
                Assert.True(response.Job.Errors.Count < 1, "Errors found while doing planned failover operation");
                Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            }
        }
Пример #3
0
        public void RP_PFO_E2A_Test()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();
                var client = GetSiteRecoveryClient(CustomHttpHandler);

                var requestHeaders = RequestHeaders;
                requestHeaders.AgentAuthenticationHeader = GenerateAgentAuthenticationHeader(requestHeaders.ClientRequestId);

                var responseRP = client.RecoveryPlan.List(RequestHeaders);

                JobResponse response = new JobResponse();
                foreach (var rp in responseRP.RecoveryPlans)
                {
                    RpPlannedFailoverRequest request = new RpPlannedFailoverRequest();
                    request.FailoverDirection = "PrimaryToRecovery";
                    request.ReplicationProvider = "HyperVReplicaAzure";
                    AzureFailoverInput foInput = new AzureFailoverInput();
                    foInput.VaultLocation = VaultLocation;
                    request.ReplicationProviderSettings = DataContractUtils.Serialize<AzureFailoverInput>
                        (foInput);
                    response = client.RecoveryPlan.RecoveryPlanPlannedFailover(
                        rp.ID,
                        request,
                        requestHeaders);
                }

                Assert.NotNull(response.Job);
                Assert.NotNull(response.Job.ID);
                Assert.True(response.Job.Errors.Count < 1, "Errors found while doing unplanned failover operation");
                Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            }
        }
Пример #4
0
        public void E2A_PlannedFailoverTest()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();
                var client = GetSiteRecoveryClient(CustomHttpHandler);

                var requestHeaders = RequestHeaders;
                requestHeaders.AgentAuthenticationHeader = GenerateAgentAuthenticationHeader(requestHeaders.ClientRequestId);

                var responsePC = client.ProtectionContainer.List(RequestHeaders);

                
                JobResponse response = new JobResponse();
                bool desiredPEFound = false;
                foreach (var pc in responsePC.ProtectionContainers)
                {
                    if (pc.Role != "Primary")
                    {
                        continue;
                    }

                    var responsePEs = client.ProtectionEntity.List(pc.ID, RequestHeaders);
                    response = null;
                    foreach (var pe in responsePEs.ProtectionEntities)
                    {
                        if (pe.CanFailover == true && pe.ActiveLocation == "Recovery" && pe.ReplicationProvider == "HyperVReplicaAzure")
                        {
                            PlannedFailoverRequest request = new PlannedFailoverRequest();
                            request.ReplicationProvider = pe.ReplicationProvider;
                            if (pe.ActiveLocation == "Primary")
                            {
                                request.FailoverDirection = "PrimaryToRecovery";
                                AzureFailoverInput blob = new AzureFailoverInput();
                                blob.VaultLocation = VaultLocation;
                                request.ReplicationProviderSettings = DataContractUtils.Serialize<AzureFailoverInput>(blob);
                            }
                            else
                            {
                                request.FailoverDirection = "RecoveryToPrimary";
                                var blob = new AzureFailbackInput();
                                blob.CreateRecoveryVmIfDoesntExist = false;
                                blob.SkipDataSync = false;
                                request.ReplicationProviderSettings = DataContractUtils.Serialize<AzureFailbackInput>(blob);
                            }

                            response = client.ProtectionEntity.PlannedFailover(
                                pe.ProtectionContainerId,
                                pe.ID,
                                request,
                                requestHeaders);
                            desiredPEFound = true;
                            break;
                        }
                    }

                    if (desiredPEFound)
                    {
                        break;
                    }
                }

                Assert.NotNull(response.Job);
                Assert.NotNull(response.Job.ID);
                Assert.True(response.Job.Errors.Count < 1, "Errors found while doing failback operation");
                Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            }
        }
Пример #5
0
        public void TestFailoverTest()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();
                var client = GetSiteRecoveryClient(CustomHttpHandler);

                var requestHeaders = RequestHeaders;
                requestHeaders.AgentAuthenticationHeader = GenerateAgentAuthenticationHeader(requestHeaders.ClientRequestId);

                var responsePC = client.ProtectionContainer.List(RequestHeaders);

                JobResponse response = new JobResponse();
                bool desiredPEFound = false;
                foreach (var pc in responsePC.ProtectionContainers)
                {
                    var responsePEs = client.ProtectionEntity.List(pc.ID, RequestHeaders);
                    response = null;
                    foreach (var pe in responsePEs.ProtectionEntities)
                    {
                        if (pe.Protected == true)
                        {
                            TestFailoverRequest request = new TestFailoverRequest();
                            request.FailoverDirection = "PrimaryToRecovery";
                            request.ReplicationProvider = pe.ReplicationProvider;
                            if (pe.ReplicationProvider == "HyperVReplicaAzure")
                            {
                                AzureFailoverInput blob = new AzureFailoverInput();
                                blob.VaultLocation = VaultLocation;
                                request.ReplicationProviderSettings = DataContractUtils.Serialize<AzureFailoverInput>(blob);
                            }
                            else
                            {
                                request.ReplicationProviderSettings = "";
                            }

                            request.NetworkID = "ID";
                            request.NetworkType = "Type";
                            response = client.ProtectionEntity.TestFailover(
                                pe.ProtectionContainerId,
                                pe.ID,
                                request,
                                requestHeaders);
                            desiredPEFound = true;
                            break;
                        }
                    }

                    if (desiredPEFound)
                    {
                        break;
                    }
                }

                Assert.NotNull(response.Job);
                Assert.NotNull(response.Job.ID);
                Assert.True(response.Job.Errors.Count < 1, "Errors found while doing planned failover operation");
                Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            }
        }
        public void E2A_PlannedFailoverTest()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();
                var client = GetSiteRecoveryClient(CustomHttpHandler);

                var requestHeaders = RequestHeaders;
                requestHeaders.AgentAuthenticationHeader = GenerateAgentAuthenticationHeader(requestHeaders.ClientRequestId);

                var responsePC = client.ProtectionContainer.List(RequestHeaders);


                JobResponse response       = new JobResponse();
                bool        desiredPEFound = false;
                foreach (var pc in responsePC.ProtectionContainers)
                {
                    if (pc.Role != "Primary")
                    {
                        continue;
                    }

                    var responsePEs = client.ProtectionEntity.List(pc.ID, RequestHeaders);
                    response = null;
                    foreach (var pe in responsePEs.ProtectionEntities)
                    {
                        if (pe.CanFailover == true && pe.ActiveLocation == "Recovery" && pe.ReplicationProvider == "HyperVReplicaAzure")
                        {
                            PlannedFailoverRequest request = new PlannedFailoverRequest();
                            request.ReplicationProvider = pe.ReplicationProvider;
                            if (pe.ActiveLocation == "Primary")
                            {
                                request.FailoverDirection = "PrimaryToRecovery";
                                AzureFailoverInput blob = new AzureFailoverInput();
                                blob.VaultLocation = VaultLocation;
                                request.ReplicationProviderSettings = DataContractUtils.Serialize <AzureFailoverInput>(blob);
                            }
                            else
                            {
                                request.FailoverDirection = "RecoveryToPrimary";
                                var blob = new AzureFailbackInput();
                                blob.CreateRecoveryVmIfDoesntExist = false;
                                blob.SkipDataSync = false;
                                request.ReplicationProviderSettings = DataContractUtils.Serialize <AzureFailbackInput>(blob);
                            }

                            response = client.ProtectionEntity.PlannedFailover(
                                pe.ProtectionContainerId,
                                pe.ID,
                                request,
                                requestHeaders);
                            desiredPEFound = true;
                            break;
                        }
                    }

                    if (desiredPEFound)
                    {
                        break;
                    }
                }

                Assert.NotNull(response.Job);
                Assert.NotNull(response.Job.ID);
                Assert.True(response.Job.Errors.Count < 1, "Errors found while doing failback operation");
                Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            }
        }