Ejemplo n.º 1
0
        public void RP_PFO_Failback_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   = "RecoveryToPrimary";
                    request.ReplicationProvider = "HyperVReplicaAzure";
                    AzureFailbackInput fbInput = new AzureFailbackInput();
                    fbInput.CreateRecoveryVmIfDoesntExist = true;
                    fbInput.SkipDataSync = true;
                    request.ReplicationProviderSettings = DataContractUtils.Serialize <AzureFailbackInput>
                                                              (fbInput);
                    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 planned failover operation");
                Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            }
        }
Ejemplo n.º 2
0
        public void RP_PFO_Failback_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 = "RecoveryToPrimary";
                    request.ReplicationProvider = "HyperVReplicaAzure";
                    AzureFailbackInput fbInput = new AzureFailbackInput();
                    fbInput.CreateRecoveryVmIfDoesntExist = true;
                    fbInput.SkipDataSync = true;
                    request.ReplicationProviderSettings = DataContractUtils.Serialize<AzureFailbackInput>
                        (fbInput);
                    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 planned failover operation");
                Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            }
        }
        public void E2AFailbackTest()
        {
            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.CanFailover == true)
                        {
                            PlannedFailoverRequest request = new PlannedFailoverRequest();
                            request.ReplicationProvider = pe.ReplicationProvider;
                            if (pe.ActiveLocation == "Primary")
                            {
                                request.FailoverDirection = "PrimaryToRecovery";
                            }
                            else
                            {
                                request.FailoverDirection = "RecoveryToPrimary";
                            }

                            AzureFailbackInput blob = new AzureFailbackInput();
                            blob.CreateRecoveryVmIfDoesntExist = false;
                            blob.SkipDataSync = true;
                            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 planned failover operation");
                Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            }
        }
Ejemplo n.º 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);
            }
        }