コード例 #1
0
        public void ListProtectionPolicyTest()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();

                string resourceNamespace = ConfigurationManager.AppSettings["ResourceNamespace"];
                string resourceGroupName = ConfigurationManager.AppSettings["RsVaultRgNameRP"];
                string resourceName = ConfigurationManager.AppSettings["RsVaultNameRP"];
                string location = ConfigurationManager.AppSettings["vaultLocationRP"];

                var client = GetServiceClient<RecoveryServicesBackupManagementClient>(resourceNamespace);

                // 1. Create vault
                VaultTestHelpers vaultTestHelper = new VaultTestHelpers(client);
                vaultTestHelper.CreateVault(resourceGroupName, resourceName, location);

                // ACTION: List policies
                PolicyTestHelpers policyTestHelper = new PolicyTestHelpers(client);
                ProtectionPolicyQueryParameters queryParams = new ProtectionPolicyQueryParameters();
                ProtectionPolicyListResponse response = policyTestHelper.ListProtectionPolicy(resourceGroupName, resourceName, queryParams);

                // VALIDATION: At least default policy is expected
                Assert.NotNull(response.ItemList);
                Assert.NotNull(response.ItemList.Value);
                Assert.NotEmpty(response.ItemList.Value);
                foreach (ProtectionPolicyResource resource in response.ItemList.Value)
                {
                    Assert.NotNull(resource.Id);
                    Assert.NotNull(resource.Name);
                    Assert.NotNull(resource.Type);
                    Assert.NotNull(resource.Properties);
                }
            }
        }
コード例 #2
0
        public void EnableProtectionTest()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();

                string resourceNamespace = ConfigurationManager.AppSettings["ResourceNamespace"];
                string resourceGroupName = ConfigurationManager.AppSettings["RsVaultRgNameRP"];
                string resourceName = ConfigurationManager.AppSettings["RsVaultNameRP"];
                string location = ConfigurationManager.AppSettings["vaultLocationRP"];
                // TODO: Create VM instead of taking these parameters from config
                string containerUniqueName = ConfigurationManager.AppSettings["RsVaultIaasVMContainerUniqueNameRP"];
                string itemUniqueName = ConfigurationManager.AppSettings["RsVaultIaasVMItemUniqueNameRP"];
                string containeType = ConfigurationManager.AppSettings["IaaSVMContainerType"];
                string itemType = ConfigurationManager.AppSettings["IaaSVMItemType"];
                string containerUri = containeType + ";" + containerUniqueName;
                string itemUri = itemType + ";" + itemUniqueName;

                var client = GetServiceClient<RecoveryServicesBackupManagementClient>(resourceNamespace);

                // 1. Create vault
                VaultTestHelpers vaultTestHelper = new VaultTestHelpers(client);
                vaultTestHelper.CreateVault(resourceGroupName, resourceName, location);

                // 2. Get default policy
                PolicyTestHelpers policyTestHelper = new PolicyTestHelpers(client);
                string policyId = policyTestHelper.GetDefaultPolicyId(resourceGroupName, resourceName);

                // ACTION: Enable protection and wait for completion
                ProtectedItemTestHelpers protectedItemTestHelper = new ProtectedItemTestHelpers(client);
                protectedItemTestHelper.EnableProtection(resourceGroupName, resourceName, policyId, containerUri, itemUri);
            }
        }
コード例 #3
0
        public void RestoreDiskTest()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();

                string resourceNamespace = ConfigurationManager.AppSettings["ResourceNamespace"];
                string resourceGroupName = ConfigurationManager.AppSettings["RsVaultRgNameRP"];
                string resourceName = ConfigurationManager.AppSettings["RsVaultNameRP"];
                string location = ConfigurationManager.AppSettings["vaultLocationRP"];
                // TODO: Create VM instead of taking these parameters from config
                string containerUniqueName = ConfigurationManager.AppSettings["RsVaultIaasVMContainerUniqueNameRP"];
                string itemUniqueName = ConfigurationManager.AppSettings["RsVaultIaasVMItemUniqueNameRP"];
                string containeType = ConfigurationManager.AppSettings["IaaSVMContainerType"];
                string itemType = ConfigurationManager.AppSettings["IaaSVMItemType"];
                string containerUri = containeType + ";" + containerUniqueName;
                string itemUri = itemType + ";" + itemUniqueName;
                string storageAccountId = ConfigurationManager.AppSettings["StorageAccountId"];

                var client = GetServiceClient<RecoveryServicesBackupManagementClient>(resourceNamespace);

                // 1. Create vault
                VaultTestHelpers vaultTestHelper = new VaultTestHelpers(client);
                vaultTestHelper.CreateVault(resourceGroupName, resourceName, location);

                // 2. Get default policy
                PolicyTestHelpers policyTestHelper = new PolicyTestHelpers(client);
                string policyId = policyTestHelper.GetDefaultPolicyId(resourceGroupName, resourceName);

                // 3. Enable protection
                ProtectedItemTestHelpers protectedItemTestHelper = new ProtectedItemTestHelpers(client);
                protectedItemTestHelper.EnableProtection(resourceGroupName, resourceName, policyId, containerUri, itemUri);

                // 4. Get protected item's source resource ID
                var protectedItemResponse = protectedItemTestHelper.GetProtectedItem(resourceGroupName, resourceName, containerUri, itemUri);
                string sourceResourceId = ((AzureIaaSVMProtectedItem)protectedItemResponse.Item.Properties).VirtualMachineId;

                // 5. Trigger backup and wait for completion
                BackupTestHelpers backupTestHelper = new BackupTestHelpers(client);
                DateTime backupStartTime = DateTime.UtcNow;
                string backupJobId = backupTestHelper.BackupProtectedItem(resourceGroupName, resourceName, containerUri, itemUri);
                JobTestHelpers jobTestHelper = new JobTestHelpers(client);
                jobTestHelper.WaitForJob(resourceGroupName, resourceName, backupJobId);
                DateTime backupEndTime = DateTime.UtcNow;

                // 6. Get latest RP
                RecoveryPointTestHelpers recoveryPointTestHelper = new RecoveryPointTestHelpers(client);
                var recoveryPoints = recoveryPointTestHelper.ListRecoveryPoints(
                    resourceGroupName, resourceName, containerUri, itemUri, backupStartTime, backupEndTime);
                var recoveryPointResource = recoveryPointTestHelper.GetRecoveryPointDetails(
                    resourceGroupName, resourceName, containerUri, itemUri, recoveryPoints[0].Name);

                // ACTION: Trigger disk restore on the latest RP and wait for completion
                RestoreTestHelpers restoreTestHelper = new RestoreTestHelpers(client);
                string restoreJobId = restoreTestHelper.RestoreProtectedItem(
                    resourceGroupName, resourceName, containerUri, itemUri, sourceResourceId, storageAccountId, recoveryPointResource);
                jobTestHelper.WaitForJob(resourceGroupName, resourceName, restoreJobId);
            }
        }
コード例 #4
0
        public void ListJobsAndGetJobTest()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();

                string resourceNamespace = ConfigurationManager.AppSettings["ResourceNamespace"];
                string resourceGroupName = ConfigurationManager.AppSettings["RsVaultRgNameRP"];
                string resourceName = ConfigurationManager.AppSettings["RsVaultNameRP"];
                string location = ConfigurationManager.AppSettings["vaultLocationRP"];
                // TODO: Create VM instead of taking these parameters from config
                string containerUniqueName = ConfigurationManager.AppSettings["RsVaultIaasVMContainerUniqueNameRP"];
                string itemUniqueName = ConfigurationManager.AppSettings["RsVaultIaasVMItemUniqueNameRP"];
                string containeType = ConfigurationManager.AppSettings["IaaSVMContainerType"];
                string itemType = ConfigurationManager.AppSettings["IaaSVMItemType"];
                string containerUri = containeType + ";" + containerUniqueName;
                string itemUri = itemType + ";" + itemUniqueName;
                string utcDateTimeFormat = ConfigurationManager.AppSettings["UTCDateTimeFormat"];

                var client = GetServiceClient<RecoveryServicesBackupManagementClient>(resourceNamespace);

                // 1. Create vault
                VaultTestHelpers vaultTestHelper = new VaultTestHelpers(client);
                vaultTestHelper.CreateVault(resourceGroupName, resourceName, location);

                // 2. Get default policy
                PolicyTestHelpers policyTestHelper = new PolicyTestHelpers(client);
                string policyId = policyTestHelper.GetDefaultPolicyId(resourceGroupName, resourceName);

                // 3. Enable protection
                ProtectedItemTestHelpers protectedItemTestHelper = new ProtectedItemTestHelpers(client);
                DateTime protectionStartTime = DateTime.UtcNow;
                protectedItemTestHelper.EnableProtection(resourceGroupName, resourceName, policyId, containerUri, itemUri);
                DateTime protectionEndTime = DateTime.UtcNow;

                // ACTION: List jobs
                CommonJobQueryFilters commonFilters = new CommonJobQueryFilters();
                commonFilters.BackupManagementType = BackupManagementType.AzureIaasVM.ToString();
                commonFilters.StartTime = protectionStartTime.ToString(utcDateTimeFormat);
                commonFilters.EndTime = protectionEndTime.ToString(utcDateTimeFormat);
                JobTestHelpers helper = new JobTestHelpers(client);
                var jobList = helper.ListJobs(resourceGroupName, resourceName, commonFilters, null);

                // VALIDATION
                foreach (var job in jobList.ItemList.Value)
                {
                    Assert.NotNull(job.Id);
                    Assert.NotNull(job.Name);
                    helper.ValidateJobResponse(job.Properties, commonFilters);

                    // validating getjob
                    var jobDetails = helper.GetJob(resourceGroupName, resourceName, job.Name);
                    Assert.NotNull(jobDetails);
                    Assert.NotNull(jobDetails.Item);
                    helper.ValidateJobResponse(jobDetails.Item.Properties, null);
                }
            }
        }
コード例 #5
0
        public void ListRecoveryPointTest()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();

                string resourceNamespace = ConfigurationManager.AppSettings["ResourceNamespace"];
                string resourceGroupName = ConfigurationManager.AppSettings["RsVaultRgNameRP"];
                string resourceName = ConfigurationManager.AppSettings["RsVaultNameRP"];
                string location = ConfigurationManager.AppSettings["vaultLocationRP"];
                // TODO: Create VM instead of taking these parameters from config
                string containerUniqueName = ConfigurationManager.AppSettings["RsVaultIaasVMContainerUniqueNameRP"];
                string itemUniqueName = ConfigurationManager.AppSettings["RsVaultIaasVMItemUniqueNameRP"];
                string containeType = ConfigurationManager.AppSettings["IaaSVMContainerType"];
                string itemType = ConfigurationManager.AppSettings["IaaSVMItemType"];
                string containerUri = containeType + ";" + containerUniqueName;
                string itemUri = itemType + ";" + itemUniqueName;
                string fabricName = ConfigurationManager.AppSettings["AzureBackupFabricName"];
                string utcDateTimeFormat = ConfigurationManager.AppSettings["UTCDateTimeFormat"];
                
                var client = GetServiceClient<RecoveryServicesBackupManagementClient>(resourceNamespace);

                // 1. Create vault
                VaultTestHelpers vaultTestHelper = new VaultTestHelpers(client);
                vaultTestHelper.CreateVault(resourceGroupName, resourceName, location);

                // 2. Get default policy
                PolicyTestHelpers policyTestHelper = new PolicyTestHelpers(client);
                string policyId = policyTestHelper.GetDefaultPolicyId(resourceGroupName, resourceName);

                // 3. Enable protection
                ProtectedItemTestHelpers protectedItemTestHelper = new ProtectedItemTestHelpers(client);
                protectedItemTestHelper.EnableProtection(resourceGroupName, resourceName, policyId, containerUri, itemUri);

                // 4. Trigger backup and wait for completion
                BackupTestHelpers backupTestHelper = new BackupTestHelpers(client);
                DateTime backupStartTime = DateTime.UtcNow;
                string jobId = backupTestHelper.BackupProtectedItem(resourceGroupName, resourceName, containerUri, itemUri);
                JobTestHelpers jobTestHelper = new JobTestHelpers(client);
                jobTestHelper.WaitForJob(resourceGroupName, resourceName, jobId);
                DateTime backupEndTime = DateTime.UtcNow;

                // ACTION: Fetch RP
                RecoveryPointQueryParameters queryFilter = new RecoveryPointQueryParameters();
                queryFilter.StartDate = backupStartTime.ToString(utcDateTimeFormat);
                queryFilter.EndDate = backupEndTime.ToString(utcDateTimeFormat);
                var response = client.RecoveryPoints.List(
                    resourceGroupName, resourceName, CommonTestHelper.GetCustomRequestHeaders(), fabricName, containerUri, itemUri, queryFilter);

                // VALIDATION: Should be only one RP
                Assert.NotNull(response.RecoveryPointList);
                Assert.NotNull(response.RecoveryPointList.RecoveryPoints);
                Assert.Equal(1, response.RecoveryPointList.RecoveryPoints.Count);
            }
        }
コード例 #6
0
        public void PolicyCrudTest()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();

                string resourceNamespace = ConfigurationManager.AppSettings["ResourceNamespace"];
                string resourceGroupName = ConfigurationManager.AppSettings["RsVaultRgNameRP"];
                string resourceName = ConfigurationManager.AppSettings["RsVaultNameRP"];
                string location = ConfigurationManager.AppSettings["vaultLocationRP"];
                string defaultPolicyName = ConfigurationManager.AppSettings["DefaultPolicyName"];

                var client = GetServiceClient<RecoveryServicesBackupManagementClient>(resourceNamespace);

                // 1. Create vault
                VaultTestHelpers vaultTestHelper = new VaultTestHelpers(client);
                vaultTestHelper.CreateVault(resourceGroupName, resourceName, location);

                PolicyTestHelpers policyTestHelper = new PolicyTestHelpers(client);

                // ACTION: Get default policy
                ProtectionPolicyResponse response = policyTestHelper.GetProtectionPolicy(resourceGroupName, resourceName, defaultPolicyName);

                // VALIDATION: Name should match
                Assert.NotNull(response.Item.Name);
                Assert.Equal(response.Item.Name, defaultPolicyName);
                Assert.NotNull(response.Item.Id);
                Assert.NotNull(response.Item.Type);
                Assert.NotNull(response.Item.Properties);

                // ACTION: Add new policy
                ProtectionPolicyRequest request = new ProtectionPolicyRequest();
                request.Item = new ProtectionPolicyResource();
                request.Item.Properties = response.Item.Properties;
                string newPolicyName = defaultPolicyName + "_updated";
                response = policyTestHelper.AddOrUpdateProtectionPolicy(resourceGroupName, resourceName, newPolicyName, request);

                // ACTION: Update the policy
                response = policyTestHelper.AddOrUpdateProtectionPolicy(resourceGroupName, resourceName, newPolicyName, request);

                // VALIDATION: Name should match
                Assert.NotNull(response.Item.Name);
                Assert.Equal(response.Item.Name, newPolicyName);
                Assert.NotNull(response.Item.Id);
                Assert.NotNull(response.Item.Type);
                Assert.NotNull(response.Item.Properties);

                // ACTION: Delete the policy
                AzureOperationResponse deleteResponse = policyTestHelper.DeleteProtectionPolicy(resourceGroupName, resourceName, newPolicyName);
                Assert.Equal(deleteResponse.StatusCode, HttpStatusCode.OK);
            }
        }
コード例 #7
0
        public void ListProtectableObjectTest()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();

                string resourceNamespace = ConfigurationManager.AppSettings["ResourceNamespace"];
                string resourceGroupName = ConfigurationManager.AppSettings["RsVaultRgNameRP"];
                string resourceName = ConfigurationManager.AppSettings["RsVaultNameRP"];
                string location = ConfigurationManager.AppSettings["vaultLocationRP"];
                // TODO: Create VM instead of taking these parameters from config
                string containerUniqueName = ConfigurationManager.AppSettings["RsVaultIaasVMContainerUniqueNameRP"];
                string itemUniqueName = ConfigurationManager.AppSettings["RsVaultIaasVMItemUniqueNameRP"];
                string containeType = ConfigurationManager.AppSettings["IaaSVMContainerType"];
                string itemType = ConfigurationManager.AppSettings["IaaSVMItemType"];
                string containerUri = containeType + ";" + containerUniqueName;
                string itemUri = itemType + ";" + itemUniqueName;

                var client = GetServiceClient<RecoveryServicesBackupManagementClient>(resourceNamespace);

                // 1. Create vault
                VaultTestHelpers vaultTestHelper = new VaultTestHelpers(client);
                vaultTestHelper.CreateVault(resourceGroupName, resourceName, location);

                // 2. Get default policy
                PolicyTestHelpers policyTestHelper = new PolicyTestHelpers(client);
                string policyId = policyTestHelper.GetDefaultPolicyId(resourceGroupName, resourceName);

                // 3. Enable protection
                ProtectedItemTestHelpers protectedItemTestHelper = new ProtectedItemTestHelpers(client);
                protectedItemTestHelper.EnableProtection(resourceGroupName, resourceName, policyId, containerUri, itemUri);

                // ACTION: List protectable objects
                ProtectableObjectListQueryParameters queryParams = new ProtectableObjectListQueryParameters();
                queryParams.BackupManagementType = BackupManagementType.AzureIaasVM.ToString();
                ProtectableObjectTestHelper poTestHelper = new ProtectableObjectTestHelper(client);
                ProtectableObjectListResponse response = poTestHelper.ListProtectableObjects(
                    resourceGroupName, resourceName, queryParams, new PaginationRequest());

                // VALIDATION: VM should not be found in the list
                Assert.False(response.ItemList.ProtectableObjects.Any(
                    protectableObject =>
                    {
                        return protectableObject.Properties.GetType().IsSubclassOf(typeof(AzureIaaSVMProtectableItem)) &&
                            protectableObject.Name.Contains(containerUniqueName);
                    }),
                    "Retrieved list of containers doesn't contain AzureIaaSVMProtectableItem Item");
            }
        }
コード例 #8
0
        public void CancelJobTest()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();

                string resourceNamespace = ConfigurationManager.AppSettings["ResourceNamespace"];
                string resourceGroupName = ConfigurationManager.AppSettings["RsVaultRgNameRP"];
                string resourceName = ConfigurationManager.AppSettings["RsVaultNameRP"];
                string location = ConfigurationManager.AppSettings["vaultLocationRP"];
                // TODO: Create VM instead of taking these parameters from config
                string containerUniqueName = ConfigurationManager.AppSettings["RsVaultIaasVMContainerUniqueNameRP"];
                string itemUniqueName = ConfigurationManager.AppSettings["RsVaultIaasVMItemUniqueNameRP"];
                string containeType = ConfigurationManager.AppSettings["IaaSVMContainerType"];
                string itemType = ConfigurationManager.AppSettings["IaaSVMItemType"];
                string containerUri = containeType + ";" + containerUniqueName;
                string itemUri = itemType + ";" + itemUniqueName;

                var client = GetServiceClient<RecoveryServicesBackupManagementClient>(resourceNamespace);

                // 1. Create vault
                VaultTestHelpers vaultTestHelper = new VaultTestHelpers(client);
                vaultTestHelper.CreateVault(resourceGroupName, resourceName, location);

                // 2. Get default policy
                PolicyTestHelpers policyTestHelper = new PolicyTestHelpers(client);
                string policyId = policyTestHelper.GetDefaultPolicyId(resourceGroupName, resourceName);

                // 3. Enable protection
                ProtectedItemTestHelpers protectedItemTestHelper = new ProtectedItemTestHelpers(client);
                DateTime protectionStartTime = DateTime.UtcNow;
                protectedItemTestHelper.EnableProtection(resourceGroupName, resourceName, policyId, containerUri, itemUri);
                DateTime protectionEndTime = DateTime.UtcNow;

                // 4. Trigger backup and get the job
                BackupTestHelpers backupTestHelper = new BackupTestHelpers(client);
                string jobId = backupTestHelper.BackupProtectedItem(resourceGroupName, resourceName, containerUri, itemUri);
                CommonJobQueryFilters commonFilters = new CommonJobQueryFilters();
                commonFilters.Status = JobStatus.InProgress.ToString();
                commonFilters.Operation = JobOperation.Backup.ToString();
                JobTestHelpers helper = new JobTestHelpers(client);
                var job = helper.GetJob(resourceGroupName, resourceName, jobId);

                // ACTION: Cancel the job
                var cancelResponse = helper.CancelJob(resourceGroupName, resourceName, jobId);
                var opId = helper.GetOpId(cancelResponse.Location);
                var opStatus = helper.GetJobOperationStatus(resourceGroupName, resourceName, jobId, opId);
                TestUtilities.RetryActionWithTimeout(
                    () => opStatus = helper.GetJobOperationStatus(resourceGroupName, resourceName, jobId, opId),
                    () => opStatus.StatusCode != HttpStatusCode.Accepted,
                    TimeSpan.FromMinutes(30),
                    statusCode =>
                    {
                        if (HttpMockServer.Mode == HttpRecorderMode.Record)
                        {
                            Thread.Sleep(15 * 1000);
                        }
                        return true;
                    });
            }
        }
コード例 #9
0
        public void GetRecoveryPointDetailTest()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();

                string resourceNamespace = ConfigurationManager.AppSettings["ResourceNamespace"];
                var client = GetServiceClient<RecoveryServicesBackupManagementClient>(resourceNamespace);

                // 1. Create vault
                string resourceGroupName = ConfigurationManager.AppSettings["RsVaultRgNameRP"];
                string resourceName = ConfigurationManager.AppSettings["RsVaultNameRP"];
                string location = ConfigurationManager.AppSettings["vaultLocationRP"];
                VaultTestHelpers vaultTestHelper = new VaultTestHelpers(client);
                vaultTestHelper.CreateVault(resourceGroupName, resourceName, location);

                // 2. Get default policy
                PolicyTestHelpers policyTestHelper = new PolicyTestHelpers(client);
                string policyId = policyTestHelper.GetDefaultPolicyId(resourceGroupName, resourceName);

                // 3. Enable protection
                // TODO: Create VM instead of taking these parameters from config
                string containerUniqueName = ConfigurationManager.AppSettings["RsVaultIaasVMContainerUniqueNameRP"];
                string itemUniqueName = ConfigurationManager.AppSettings["RsVaultIaasVMItemUniqueNameRP"];
                string containeType = ConfigurationManager.AppSettings["IaaSVMContainerType"];
                string itemType = ConfigurationManager.AppSettings["IaaSVMItemType"];
                string containerUri = containeType + ";" + containerUniqueName;
                string itemUri = itemType + ";" + itemUniqueName;
                ProtectedItemTestHelpers protectedItemTestHelper = new ProtectedItemTestHelpers(client);
                protectedItemTestHelper.EnableProtection(resourceGroupName, resourceName, policyId, containerUri, itemUri);

                // 4. Trigger backup and wait for completion
                BackupTestHelpers backupTestHelper = new BackupTestHelpers(client);
                DateTime backupStartTime = DateTime.UtcNow;
                string jobId = backupTestHelper.BackupProtectedItem(resourceGroupName, resourceName, containerUri, itemUri);
                JobTestHelpers jobTestHelper = new JobTestHelpers(client);
                jobTestHelper.WaitForJob(resourceGroupName, resourceName, jobId);
                DateTime backupEndTime = DateTime.UtcNow;

                // 5. Get latest RP
                RecoveryPointTestHelpers recoveryPointTestHelper = new RecoveryPointTestHelpers(client);
                var recoveryPoints = recoveryPointTestHelper.ListRecoveryPoints(
                    resourceGroupName, resourceName, containerUri, itemUri, backupStartTime, backupEndTime);
                var recoveryPointResource = recoveryPoints[0];
                var recoveryPoint = (RecoveryPoint)recoveryPointResource.Properties;

                // ACTION: Get RP details
                string fabricName = ConfigurationManager.AppSettings["AzureBackupFabricName"];
                var response = client.RecoveryPoints.Get(
                    resourceGroupName, resourceName, CommonTestHelper.GetCustomRequestHeaders(),
                    fabricName, containerUri, itemUri, recoveryPointResource.Name);

                // VALIDATION: Should be valid RP
                Assert.NotNull(response);
                Assert.NotNull(response.RecPoint);
                Assert.True(!string.IsNullOrEmpty(response.RecPoint.Name), "RP Id cant be null");
                Assert.True(!string.IsNullOrEmpty(((RecoveryPoint)response.RecPoint.Properties).RecoveryPointTime),
                    "RecoveryPointTime can't be null or empty");
                Assert.True(!string.IsNullOrEmpty(((RecoveryPoint)response.RecPoint.Properties).SourceVMStorageType),
                    "SourceVMStorageType can't be null or empty");
            }
        }
コード例 #10
0
        public void ListProtectedItemsTest()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();

                string resourceNamespace = ConfigurationManager.AppSettings["ResourceNamespace"];
                string resourceGroupName = ConfigurationManager.AppSettings["RsVaultRgNameRP"];
                string resourceName = ConfigurationManager.AppSettings["RsVaultNameRP"];
                string location = ConfigurationManager.AppSettings["vaultLocationRP"];
                // TODO: Create VM instead of taking these parameters from config
                string containerUniqueName = ConfigurationManager.AppSettings["RsVaultIaasVMContainerUniqueNameRP"];
                string itemUniqueName = ConfigurationManager.AppSettings["RsVaultIaasVMItemUniqueNameRP"];
                string containeType = ConfigurationManager.AppSettings["IaaSVMContainerType"];
                string itemType = ConfigurationManager.AppSettings["IaaSVMItemType"];
                string containerUri = containeType + ";" + containerUniqueName;
                string itemUri = itemType + ";" + itemUniqueName;

                var client = GetServiceClient<RecoveryServicesBackupManagementClient>(resourceNamespace);

                // 1. Create vault
                VaultTestHelpers vaultTestHelper = new VaultTestHelpers(client);
                vaultTestHelper.CreateVault(resourceGroupName, resourceName, location);

                // 2. Get default policy
                PolicyTestHelpers policyTestHelper = new PolicyTestHelpers(client);
                string policyId = policyTestHelper.GetDefaultPolicyId(resourceGroupName, resourceName);

                // 3. Enable protection
                ProtectedItemTestHelpers protectedItemTestHelper = new ProtectedItemTestHelpers(client);
                protectedItemTestHelper.EnableProtection(resourceGroupName, resourceName, policyId, containerUri, itemUri);

                // ACTION: List protected items
                ProtectedItemListQueryParam queryParams = new ProtectedItemListQueryParam();
                queryParams.BackupManagementType = CommonTestHelper.GetSetting(TestConstants.ProviderTypeAzureIaasVM);
                queryParams.DatasourceType = CommonTestHelper.GetSetting(TestConstants.WorkloadTypeVM);
                var response = protectedItemTestHelper.ListProtectedItems(resourceGroupName, resourceName, queryParams);

                // VALIDATION: VM should be found in the list
                Assert.True(response.ItemList.Value.Any(item =>
                    {
                        return item.Properties.GetType().IsSubclassOf(typeof(AzureIaaSVMProtectedItem)) &&
                               item.Name.Contains(itemUniqueName);
                    }),
                    "Retrieved list of items doesn't contain AzureIaaSVMProtectedItem test item");
            }
        }
コード例 #11
0
        public void RefreshContainerTest()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();

                string resourceNamespace = ConfigurationManager.AppSettings["ResourceNamespace"];
                string resourceGroupName = ConfigurationManager.AppSettings["RsVaultRgNameRP"];
                string resourceName = ConfigurationManager.AppSettings["RsVaultNameRP"];
                string location = ConfigurationManager.AppSettings["vaultLocationRP"];
                string fabricName = ConfigurationManager.AppSettings["AzureBackupFabricName"];

                var client = GetServiceClient<RecoveryServicesBackupManagementClient>(resourceNamespace);

                // 1. Create vault
                VaultTestHelpers vaultTestHelper = new VaultTestHelpers(client);
                vaultTestHelper.CreateVault(resourceGroupName, resourceName, location);

                // ACTION: Trigger refresh containers
                ContainerTestHelper containerTestHelper = new ContainerTestHelper(client);
                var response = containerTestHelper.RefreshContainer(resourceGroupName, resourceName, fabricName);
            }
        }