private List<AccessControlRecord> ParseACRs(XmlDocument document) { List<AccessControlRecord> acrList = new List<AccessControlRecord>(); XmlNodeList nodeList = document.SelectNodes(@"//ACR"); foreach (XmlNode node in nodeList) { AccessControlRecord acr = new AccessControlRecord(); acr.Name = node.Attributes["Name"].Value; acr.InstanceId = node.Attributes["Id"].Value; acr.InitiatorName = node.Attributes["InitiatorName"].Value; acrList.Add(acr); } return acrList; }
public void DeviceRestoreScenarioTest() { using (var context = UndoContext.Current) { context.Start(); var client = GetServiceClient<StorSimpleManagementClient>(); // Listing all Devices var devices = client.Devices.List(GetCustomRequestHeaders()); var onlineDeviceIds = from deviceInfo in devices.Devices where deviceInfo.Status == DeviceStatus.Online select deviceInfo.DeviceId; Assert.True(onlineDeviceIds.Count() >= 2); var sourceDeviceId = onlineDeviceIds.ElementAt(0); var targetDeviceId = onlineDeviceIds.ElementAt(1); CustomRequestHeaders hdrs = new CustomRequestHeaders(); hdrs.ClientRequestId = Guid.NewGuid().ToString(); hdrs.Language = "en-us"; //Get service configuration var serviceConfigList = client.ServiceConfig.Get(GetCustomRequestHeaders()); Assert.True(serviceConfigList != null); var existingSac = serviceConfigList.CredentialChangeList.Updated.FirstOrDefault(); Assert.True(existingSac != null); var dataContainerName = TestUtilities.GenerateName("DCName"); // new Data container request object var dc = new DataContainerRequest(); dc.IsDefault = false; dc.Name = dataContainerName; dc.BandwidthRate = 256; dc.VolumeCount = 0; dc.IsEncryptionEnabled = false; dc.PrimaryStorageAccountCredential = existingSac; //Create DataContainer call var taskStatus = client.DataContainer.Create(sourceDeviceId, dc, hdrs); //Assert the task status Assert.NotNull(taskStatus); Assert.True(taskStatus.Status == AsyncTaskStatus.Completed); Assert.True(taskStatus.Result == AsyncTaskResult.Succeeded); //Get Data Container call var Createddatacontainer = client.DataContainer.Get(sourceDeviceId, dataContainerName, hdrs); //Assert the returned data container object Assert.True(Createddatacontainer != null); Assert.True(Createddatacontainer.DataContainerInfo.Name.Equals(dataContainerName)); //ACR list for Virtual disk creation List<AccessControlRecord> acrList = new List<AccessControlRecord>(); for (var i = 0; i < 1; i++) { AccessControlRecord acr = new AccessControlRecord() { Name = TestUtilities.GenerateName("VDnewTestAcr"), InitiatorName = TestUtilities.GenerateName("VDinitiator") + i }; acrList.Add(acr); } //Virtual disk create request object var virtualDiskToCreate = new VirtualDiskRequest() { Name = TestUtilities.GenerateName("VD1Name"), AccessType = AccessType.ReadWrite, AcrList = acrList, AppType = AppType.PrimaryVolume, IsDefaultBackupEnabled = true, SizeInBytes = 10737418240, DataContainer = Createddatacontainer.DataContainerInfo, Online = true }; //Virtual disk create call taskStatus = client.VirtualDisk.Create(sourceDeviceId, virtualDiskToCreate, hdrs); //Asserting the task status Assert.NotNull(taskStatus); Assert.True(taskStatus.Status == AsyncTaskStatus.Completed); Assert.True(taskStatus.Result == AsyncTaskResult.Succeeded); //Virtual disk get call var createdVirtualDisk = client.VirtualDisk.GetByName(sourceDeviceId, virtualDiskToCreate.Name, hdrs); Assert.True(createdVirtualDisk != null); Assert.True(createdVirtualDisk.VirtualDiskInfo.Name.Equals(virtualDiskToCreate.Name)); var volumeIds = new List<string>(); volumeIds.Add(createdVirtualDisk.VirtualDiskInfo.InstanceId); var dailySchedule = new BackupScheduleBase(); dailySchedule.BackupType = BackupType.CloudSnapshot; dailySchedule.Status = ScheduleStatus.Enabled; dailySchedule.RetentionCount = 5; dailySchedule.StartTime = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzz"); dailySchedule.Recurrence = new ScheduleRecurrence(); dailySchedule.Recurrence.RecurrenceType = RecurrenceType.Daily; dailySchedule.Recurrence.RecurrenceValue = 5; var backupPolicyToCreate = new NewBackupPolicyConfig(); backupPolicyToCreate.Name = TestUtilities.GenerateName("PolicyName"); backupPolicyToCreate.VolumeIds = volumeIds; backupPolicyToCreate.BackupSchedules = new List<BackupScheduleBase>(); backupPolicyToCreate.BackupSchedules.Add(dailySchedule); //BackupPolicy create call taskStatus = client.BackupPolicy.Create(sourceDeviceId, backupPolicyToCreate, hdrs); //Asserting the task status Assert.NotNull(taskStatus); Assert.True(taskStatus.Status == AsyncTaskStatus.Completed); Assert.True(taskStatus.Result == AsyncTaskResult.Succeeded); //BackupPolicy get by name call var createdBackupPolicy = client.BackupPolicy.GetBackupPolicyDetailsByName(sourceDeviceId, backupPolicyToCreate.Name, hdrs); //Assert the returned BackupPolicy object Assert.True(createdBackupPolicy != null); Assert.True(createdBackupPolicy.BackupPolicyDetails.Name.Equals(backupPolicyToCreate.Name)); BackupNowRequest backupNowRequest = new BackupNowRequest(); backupNowRequest.Type = BackupType.CloudSnapshot; //BackupSets Create call taskStatus = client.Backup.Create(sourceDeviceId, createdBackupPolicy.BackupPolicyDetails.InstanceId, backupNowRequest, hdrs); //Asserting the task status Assert.NotNull(taskStatus); Assert.True(taskStatus.Status == AsyncTaskStatus.Completed); Assert.True(taskStatus.Result == AsyncTaskResult.Succeeded); GetBackupResponse backupSetResult; do { //BackupSets Get call backupSetResult = client.Backup.Get(sourceDeviceId, "BackupPolicy", Boolean.FalseString, createdBackupPolicy.BackupPolicyDetails.InstanceId, null, null, null, null, hdrs); TestUtilities.Wait(1000); } while (!backupSetResult.BackupSetsList.Any()); var dcGroupsGetResponse = client.DeviceFailover.ListDCGroups(sourceDeviceId, hdrs); var dcIdList = from drDc in dcGroupsGetResponse.DataContainerGroupResponse.DCGroups[0].DCGroup select drDc.InstanceId; var drRequest = new DeviceFailoverRequest(); drRequest.CleanupPrimary = false; drRequest.DataContainerIds = dcIdList.ToList(); drRequest.ReturnWorkflowId = true; drRequest.TargetDeviceId = targetDeviceId; //trigger failover call var jobResponse = client.DeviceFailover.Trigger(sourceDeviceId, drRequest, hdrs); //Asserting the task status Assert.NotNull(jobResponse); //track device job for its completion var deviceJobResponse = new GetDeviceJobResponse(); int retryLimit = 30; int pollInterval = 60 * 1000; int retryCount = 0; bool found = false; do { TestUtilities.Wait(pollInterval); deviceJobResponse = client.DeviceJob.Get(null, null, null, jobResponse.JobId, null, null, 0, 1, hdrs); if(deviceJobResponse != null) { found = true; } retryCount++; } while ((!found || deviceJobResponse.DeviceJobList[0].Status == "Running") && (retryCount < retryLimit)); Assert.NotNull(deviceJobResponse); Assert.Equal(deviceJobResponse.DeviceJobList[0].Status, "Completed"); } }
public void BackupScenarioTest() { using (var context = UndoContext.Current) { context.Start(); var client = GetServiceClient<StorSimpleManagementClient>(); // Listing all Devices var devices = client.Devices.List(GetCustomRequestHeaders()); // Asserting that atleast One Device is returned. Assert.True(devices != null); Assert.True(devices.Any()); var actualdeviceId = devices.FirstOrDefault().DeviceId; actualdeviceId = actualdeviceId.Trim(); CustomRequestHeaders hdrs = new CustomRequestHeaders(); hdrs.ClientRequestId = Guid.NewGuid().ToString(); hdrs.Language = "en-us"; //Get service configuration var serviceConfigList = client.ServiceConfig.Get(GetCustomRequestHeaders()); Assert.True(serviceConfigList != null); var existingSac = serviceConfigList.CredentialChangeList.Updated.FirstOrDefault(); Assert.True(existingSac != null); var dataContainerName = TestUtilities.GenerateName("DCName"); // new Data container request object var dc = new DataContainerRequest(); dc.IsDefault = false; dc.Name = dataContainerName; dc.BandwidthRate = 256; dc.VolumeCount = 0; dc.IsEncryptionEnabled = false; dc.PrimaryStorageAccountCredential = existingSac; //Create DataContainer call var taskStatus = client.DataContainer.Create(actualdeviceId, dc, hdrs); //Assert the job status Assert.NotNull(taskStatus); Assert.True(taskStatus.Status == AsyncTaskStatus.Completed); Assert.True(taskStatus.Result == AsyncTaskResult.Succeeded); //Get Data Container call var Createddatacontainer = client.DataContainer.Get(actualdeviceId, dataContainerName, hdrs); //Assert the returned data container object Assert.True(Createddatacontainer != null); Assert.True(Createddatacontainer.DataContainerInfo.Name.Equals(dataContainerName)); //ACR list for Virtual disk creation List<AccessControlRecord> acrList = new List<AccessControlRecord>(); for (var i = 0; i < 1; i++) { AccessControlRecord acr = new AccessControlRecord() { Name = TestUtilities.GenerateName("VDnewTestAcr"), InitiatorName = TestUtilities.GenerateName("VDinitiator") + i }; acrList.Add(acr); } //Virtual disk create request object var virtualDiskToCreate = new VirtualDiskRequest() { Name = TestUtilities.GenerateName("VD1Name"), AccessType = AccessType.ReadWrite, AcrList = acrList, AppType = AppType.PrimaryVolume, IsDefaultBackupEnabled = true, SizeInBytes = 10737418240, DataContainer = Createddatacontainer.DataContainerInfo, Online = true }; //Virtual disk create call taskStatus = client.VirtualDisk.Create(actualdeviceId, virtualDiskToCreate, hdrs); //Asserting the job status Assert.NotNull(taskStatus); Assert.True(taskStatus.Status == AsyncTaskStatus.Completed); Assert.True(taskStatus.Result == AsyncTaskResult.Succeeded); //Virtual disk get call var createdVirtualDisk = client.VirtualDisk.GetByName(actualdeviceId, virtualDiskToCreate.Name, hdrs); Assert.True(createdVirtualDisk != null); Assert.True(createdVirtualDisk.VirtualDiskInfo.Name.Equals(virtualDiskToCreate.Name)); var volumeIds = new List<string>(); volumeIds.Add(createdVirtualDisk.VirtualDiskInfo.InstanceId); var dailySchedule = new BackupScheduleBase(); dailySchedule.BackupType = BackupType.CloudSnapshot; dailySchedule.Status = ScheduleStatus.Enabled; dailySchedule.RetentionCount = 5; dailySchedule.StartTime = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzz"); dailySchedule.Recurrence = new ScheduleRecurrence(); dailySchedule.Recurrence.RecurrenceType = RecurrenceType.Daily; dailySchedule.Recurrence.RecurrenceValue = 5; var backupPolicyToCreate = new NewBackupPolicyConfig(); backupPolicyToCreate.Name = TestUtilities.GenerateName("PolicyName"); backupPolicyToCreate.VolumeIds = volumeIds; backupPolicyToCreate.BackupSchedules = new List<BackupScheduleBase>(); backupPolicyToCreate.BackupSchedules.Add(dailySchedule); //BackupPolicy create call taskStatus = client.BackupPolicy.Create(actualdeviceId, backupPolicyToCreate, hdrs); //Asserting the job status Assert.NotNull(taskStatus); Assert.True(taskStatus.Status == AsyncTaskStatus.Completed); Assert.True(taskStatus.Result == AsyncTaskResult.Succeeded); //BackupPolicy list call var allBackupPolicies = client.BackupPolicy.List(actualdeviceId, hdrs); //Assert the returned BackupPolicy object Assert.True(allBackupPolicies != null); Assert.True(allBackupPolicies.Any()); //BackupPolicy get by name call var createdBackupPolicy = client.BackupPolicy.GetBackupPolicyDetailsByName(actualdeviceId, backupPolicyToCreate.Name, hdrs); //Assert the returned BackupPolicy object Assert.True(createdBackupPolicy != null); Assert.True(createdBackupPolicy.BackupPolicyDetails.Name.Equals(backupPolicyToCreate.Name)); BackupNowRequest backupNowRequest = new BackupNowRequest(); backupNowRequest.Type = BackupType.CloudSnapshot; //BackupSets Create call taskStatus = client.Backup.Create(actualdeviceId, createdBackupPolicy.BackupPolicyDetails.InstanceId, backupNowRequest, hdrs); //Asserting the job status Assert.NotNull(taskStatus); Assert.True(taskStatus.Status == AsyncTaskStatus.Completed); Assert.True(taskStatus.Result == AsyncTaskResult.Succeeded); BackupScheduleBase hourlySchedule = new BackupScheduleBase(); hourlySchedule.BackupType = BackupType.LocalSnapshot; hourlySchedule.Status = ScheduleStatus.Enabled; hourlySchedule.RetentionCount = 10; hourlySchedule.StartTime = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzz"); hourlySchedule.Recurrence = new ScheduleRecurrence(); hourlySchedule.Recurrence.RecurrenceType = RecurrenceType.Hourly; hourlySchedule.Recurrence.RecurrenceValue = 12; List<BackupScheduleBase> backupSchedulesToBeAdded = new List<BackupScheduleBase>(); backupSchedulesToBeAdded.Add(hourlySchedule); var updatePolicyRequest = new UpdateBackupPolicyConfig(); updatePolicyRequest.InstanceId = createdBackupPolicy.BackupPolicyDetails.InstanceId; updatePolicyRequest.Name = createdBackupPolicy.BackupPolicyDetails.Name; updatePolicyRequest.BackupSchedulesToBeAdded = backupSchedulesToBeAdded; updatePolicyRequest.BackupSchedulesToBeUpdated = new List<BackupScheduleUpdateRequest>(); updatePolicyRequest.BackupSchedulesToBeDeleted = new List<string>(); updatePolicyRequest.VolumeIds = volumeIds; //Backup policy update call taskStatus = client.BackupPolicy.Update(actualdeviceId, createdBackupPolicy.BackupPolicyDetails.InstanceId, updatePolicyRequest, hdrs); //Asserting the job status Assert.NotNull(taskStatus); Assert.True(taskStatus.Status == AsyncTaskStatus.Completed); Assert.True(taskStatus.Result == AsyncTaskResult.Succeeded); GetBackupResponse backupSetResult; do { //BackupSets Get call backupSetResult = client.Backup.Get(actualdeviceId, "BackupPolicy", Boolean.TrueString, null, null, null, null, null, hdrs); Assert.True(backupSetResult != null); Assert.True(backupSetResult.BackupSetsList != null); TestUtilities.Wait(1000); } while (!backupSetResult.BackupSetsList.Any()); var backupSetId = backupSetResult.BackupSetsList.First().InstanceId; var restoreBackupRequest = new RestoreBackupRequest() { BackupSetId = backupSetId, SnapshotId = null }; //Restore call taskStatus = client.Backup.Restore(actualdeviceId, restoreBackupRequest, hdrs); //Asserting the job status Assert.NotNull(taskStatus); Assert.True(taskStatus.Status == AsyncTaskStatus.Completed); Assert.True(taskStatus.Result == AsyncTaskResult.Succeeded); //BackupSets Delete call taskStatus = client.Backup.Delete(actualdeviceId, backupSetId, hdrs); //Asserting the job status Assert.NotNull(taskStatus); Assert.True(taskStatus.Status == AsyncTaskStatus.Completed); Assert.True(taskStatus.Result == AsyncTaskResult.Succeeded); TestUtilities.Wait(60*1000); //wait for 1min for the backup to be deleted //Backup Policy delete call taskStatus = client.BackupPolicy.Delete(actualdeviceId, createdBackupPolicy.BackupPolicyDetails.InstanceId, hdrs); //Asserting the job status Assert.NotNull(taskStatus); Assert.True(taskStatus.Status == AsyncTaskStatus.Completed); Assert.True(taskStatus.Result == AsyncTaskResult.Succeeded); } }
/// <summary> /// Parse the access control records /// </summary> private void ParseAccessControlRecords() { this.acrList = new List<AccessControlRecord>(); var acrXmlList = this.GetSubElements(doc.Root, "AccessControlGroup"); foreach (var acrElementList in acrXmlList) { foreach (var acrElement in acrElementList.Elements()) { AccessControlRecord acr = new AccessControlRecord(); foreach (var acrProperty in acrElement.Elements()) { switch (acrProperty.Name.LocalName) { case "Id": { acr.InstanceId = acrProperty.Value; break; } case "Members": { var acrPropertyDetails = acrProperty.Elements().First().Elements().ToList(); foreach (var acrEle in acrPropertyDetails) { switch (acrEle.Name.LocalName) { case "InitiatorName": { acr.InitiatorName = acrEle.Value; break; } case "GroupId": { acr.GlobalId = acrEle.Value; break; } } } break; } case "Name": { acr.Name = acrProperty.Value; break; } default: { break; } } } this.acrList.Add(acr); } } }
public void CloneScenarioMultipleDeviceTest() { using (var context = UndoContext.Current) { context.Start(); var client = GetServiceClient<StorSimpleManagementClient>(); // Listing all Devices var devices = client.Devices.List(GetCustomRequestHeaders()); // Asserting that atleast One Device is returned. Assert.True(devices != null); Assert.True(devices.Any()); var actualdeviceId = devices.FirstOrDefault().DeviceId; actualdeviceId = actualdeviceId.Trim(); CustomRequestHeaders hdrs = new CustomRequestHeaders(); hdrs.ClientRequestId = Guid.NewGuid().ToString(); hdrs.Language = "en-us"; //Get service configuration var serviceConfigList = client.ServiceConfig.Get(GetCustomRequestHeaders()); Assert.True(serviceConfigList != null); var existingSac = serviceConfigList.CredentialChangeList.Updated.FirstOrDefault(); Assert.True(existingSac != null); var dataContainerName = TestUtilities.GenerateName("DCName"); // new Data container request object var dc = new DataContainerRequest(); dc.IsDefault = false; dc.Name = dataContainerName; dc.BandwidthRate = 256; dc.VolumeCount = 0; dc.IsEncryptionEnabled = false; dc.PrimaryStorageAccountCredential = existingSac; //Create DataContainer call var taskStatus = client.DataContainer.Create(actualdeviceId, dc, hdrs); //Assert the job status Assert.NotNull(taskStatus); Assert.True(taskStatus.Status == AsyncTaskStatus.Completed); Assert.True(taskStatus.Result == AsyncTaskResult.Succeeded); //Get Data Container call var Createddatacontainer = client.DataContainer.Get(actualdeviceId, dataContainerName, hdrs); //Assert the returned data container object Assert.True(Createddatacontainer != null); Assert.True(Createddatacontainer.DataContainerInfo.Name.Equals(dataContainerName)); //ACR list for Virtual disk creation List<AccessControlRecord> acrList = new List<AccessControlRecord>(); for (var i = 0; i < 1; i++) { AccessControlRecord acr = new AccessControlRecord() { Name = TestUtilities.GenerateName("VDnewTestAcr"), InitiatorName = TestUtilities.GenerateName("VDinitiator") + i }; acrList.Add(acr); } //Virtual disk create request object var virtualDiskToCreate = new VirtualDiskRequest() { Name = TestUtilities.GenerateName("VD1Name"), AccessType = AccessType.ReadWrite, AcrList = acrList, AppType = AppType.PrimaryVolume, IsDefaultBackupEnabled = true, SizeInBytes = 10737418240, DataContainer = Createddatacontainer.DataContainerInfo, Online = true }; //Virtual disk create call taskStatus = client.VirtualDisk.Create(actualdeviceId, virtualDiskToCreate, hdrs); //Asserting the job status Assert.NotNull(taskStatus); Assert.True(taskStatus.Status == AsyncTaskStatus.Completed); Assert.True(taskStatus.Result == AsyncTaskResult.Succeeded); //Virtual disk get call var createdVirtualDisk = client.VirtualDisk.GetByName(actualdeviceId, virtualDiskToCreate.Name, hdrs); Assert.True(createdVirtualDisk != null); Assert.True(createdVirtualDisk.VirtualDiskInfo.Name.Equals(virtualDiskToCreate.Name)); var volumeIds = new List<string>(); volumeIds.Add(createdVirtualDisk.VirtualDiskInfo.InstanceId); var dailySchedule = new BackupScheduleBase(); dailySchedule.BackupType = BackupType.CloudSnapshot; dailySchedule.Status = ScheduleStatus.Enabled; dailySchedule.RetentionCount = 5; dailySchedule.StartTime = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzz"); dailySchedule.Recurrence = new ScheduleRecurrence(); dailySchedule.Recurrence.RecurrenceType = RecurrenceType.Daily; dailySchedule.Recurrence.RecurrenceValue = 5; var backupPolicyToCreate = new NewBackupPolicyConfig(); backupPolicyToCreate.Name = TestUtilities.GenerateName("PolicyName"); backupPolicyToCreate.VolumeIds = volumeIds; backupPolicyToCreate.BackupSchedules = new List<BackupScheduleBase>(); backupPolicyToCreate.BackupSchedules.Add(dailySchedule); //BackupPolicy create call taskStatus = client.BackupPolicy.Create(actualdeviceId, backupPolicyToCreate, hdrs); //Asserting the job status Assert.NotNull(taskStatus); Assert.True(taskStatus.Status == AsyncTaskStatus.Completed); Assert.True(taskStatus.Result == AsyncTaskResult.Succeeded); //BackupPolicy list call var allBackupPolicies = client.BackupPolicy.List(actualdeviceId, hdrs); //Assert the returned BackupPolicy object Assert.True(allBackupPolicies != null); Assert.True(allBackupPolicies.Any()); //BackupPolicy get by name call var createdBackupPolicy = client.BackupPolicy.GetBackupPolicyDetailsByName(actualdeviceId, backupPolicyToCreate.Name, hdrs); //Assert the returned BackupPolicy object Assert.True(createdBackupPolicy != null); Assert.True(createdBackupPolicy.BackupPolicyDetails.Name.Equals(backupPolicyToCreate.Name)); BackupNowRequest backupNowRequest = new BackupNowRequest(); backupNowRequest.Type = BackupType.CloudSnapshot; //BackupSets Create call taskStatus = client.Backup.Create(actualdeviceId, createdBackupPolicy.BackupPolicyDetails.InstanceId, backupNowRequest, hdrs); //Asserting the job status Assert.NotNull(taskStatus); Assert.True(taskStatus.Status == AsyncTaskStatus.Completed); Assert.True(taskStatus.Result == AsyncTaskResult.Succeeded); GetBackupResponse backupSetResult; do { //BackupSets Get call backupSetResult = client.Backup.Get(actualdeviceId, "BackupPolicy", Boolean.TrueString, null, null, null, null, null, hdrs); Assert.True(backupSetResult != null); Assert.True(backupSetResult.BackupSetsList != null); TestUtilities.Wait(1000); } while (!backupSetResult.BackupSetsList.Any()); var backupSet = backupSetResult.BackupSetsList.First(); var clonedVolName = createdVirtualDisk.VirtualDiskInfo.Name + "_Cloned"; var secondDeviceId = devices.Devices[1].DeviceId; var triggerCloneRequest = new TriggerCloneRequest() { BackupSetId = backupSet.InstanceId, SourceSnapshot = backupSet.Snapshots.First(), TargetVolName = clonedVolName, TargetDeviceId = secondDeviceId, ReturnWorkflowId = true, TargetACRList = createdVirtualDisk.VirtualDiskInfo.AcrList }; var jobResponse = client.CloneVolume.Trigger(actualdeviceId, triggerCloneRequest, hdrs); //Asserting the job id. Assert.NotNull(jobResponse); Assert.True(jobResponse.JobId != Guid.Empty.ToString()); GetDeviceJobResponse deviceJobResponse; do { //DeviceJob Get call deviceJobResponse = client.DeviceJob.Get(secondDeviceId, null, null, jobResponse.JobId, null, null, 0, 10, hdrs); TestUtilities.Wait(1000); Assert.True(deviceJobResponse.DeviceJobList != null); Assert.True(deviceJobResponse.DeviceJobList.Count == 1); } while (deviceJobResponse.DeviceJobList.First().Status == "Running"); Assert.True(deviceJobResponse.DeviceJobList != null); Assert.True(deviceJobResponse.DeviceJobList.First().Status.Equals("Completed", StringComparison.InvariantCultureIgnoreCase)); VirtualDiskGetResponse virtualDiskGetResponse = client.VirtualDisk.GetByName(secondDeviceId, clonedVolName, GetCustomRequestHeaders()); Assert.True(virtualDiskGetResponse != null); Assert.True(virtualDiskGetResponse.VirtualDiskInfo != null); Assert.True(virtualDiskGetResponse.VirtualDiskInfo.Name.Equals(clonedVolName, StringComparison.InvariantCultureIgnoreCase)); } }
public void VirtualDiskScenarioTest() { using (var context = UndoContext.Current) { context.Start(); var client = GetServiceClient<StorSimpleManagementClient>(); // Listing all Devices var devices = client.Devices.List(GetCustomRequestHeaders()); // Asserting that atleast One Device is returned. Assert.True(devices != null); Assert.True(devices.Any()); var actualdeviceId = devices.FirstOrDefault().DeviceId; actualdeviceId = actualdeviceId.Trim(); CustomRequestHeaders hdrs = new CustomRequestHeaders(); hdrs.ClientRequestId = Guid.NewGuid().ToString(); hdrs.Language = "en-us"; //Get service configuration var serviceConfigList = client.ServiceConfig.Get(GetCustomRequestHeaders()); Assert.True(serviceConfigList != null); var existingSac = serviceConfigList.CredentialChangeList.Updated.FirstOrDefault(); Assert.True(existingSac != null); var dataContainerName = TestUtilities.GenerateName("DCName"); // new Data container request object var dc = new DataContainerRequest(); dc.IsDefault = false; dc.Name = dataContainerName; dc.BandwidthRate = 256; dc.VolumeCount = 0; dc.IsEncryptionEnabled = false; dc.PrimaryStorageAccountCredential = existingSac; //Create DataContainer call var taskStatus = client.DataContainer.Create(actualdeviceId, dc, hdrs); //Assert the job status Assert.NotNull(taskStatus); Assert.True(taskStatus.Status == AsyncTaskStatus.Completed); Assert.True(taskStatus.Result == AsyncTaskResult.Succeeded); //Get Data Container call var Createddatacontainer = client.DataContainer.Get(actualdeviceId, dataContainerName, hdrs); //Assert the returned data container object Assert.True(Createddatacontainer != null); Assert.True(Createddatacontainer.DataContainerInfo.Name.Equals(dataContainerName)); //ACR list for Virtual disk creation List<AccessControlRecord> acrList = new List<AccessControlRecord>(); for (var i = 0; i < 1; i++) { AccessControlRecord acr = new AccessControlRecord() { Name = TestUtilities.GenerateName("VDnewTestAcr"), InitiatorName = TestUtilities.GenerateName("VDinitiator") + i }; acrList.Add(acr); } //Virtual disk create request object var virtualDiskToCreate = new VirtualDiskRequest() { Name = TestUtilities.GenerateName("VDName"), AccessType = AccessType.ReadWrite, AcrList = acrList, AppType = AppType.ArchiveVolume, IsDefaultBackupEnabled = true, SizeInBytes = 10737418240, DataContainer = Createddatacontainer.DataContainerInfo, Online = true }; //Virtual disk create call taskStatus = client.VirtualDisk.Create(actualdeviceId, virtualDiskToCreate, hdrs); //Asserting the job status Assert.NotNull(taskStatus); Assert.True(taskStatus.Status == AsyncTaskStatus.Completed); Assert.True(taskStatus.Result == AsyncTaskResult.Succeeded); //virtual disk list call var vdlist = client.VirtualDisk.List(actualdeviceId, Createddatacontainer.DataContainerInfo.InstanceId, hdrs); Assert.True(vdlist != null); Assert.True(vdlist.Any()); var vdbbyname = client.VirtualDisk.GetByName(actualdeviceId, vdlist.ListofVirtualDisks[0].Name, hdrs); Assert.True(vdbbyname != null); var virtualDiskToUpdate = vdbbyname.VirtualDiskInfo; virtualDiskToUpdate.SizeInBytes = 21474836480; virtualDiskToUpdate.Online = false; taskStatus = client.VirtualDisk.Update(actualdeviceId, virtualDiskToUpdate.InstanceId, virtualDiskToUpdate, hdrs); //Asserting the job status Assert.NotNull(taskStatus); Assert.True(taskStatus.Status == AsyncTaskStatus.Completed); Assert.True(taskStatus.Result == AsyncTaskResult.Succeeded); taskStatus = client.VirtualDisk.Delete(actualdeviceId, virtualDiskToUpdate.InstanceId, hdrs); //Asserting the job status Assert.NotNull(taskStatus); Assert.True(taskStatus.Status == AsyncTaskStatus.Completed); Assert.True(taskStatus.Result == AsyncTaskResult.Succeeded); } }
/// <summary> /// In order to stop a job we need to first schedule a job that is going to run long /// enough for it to be stopped. /// </summary> /// <param name="deviceInfo">Device details.</param> private void CreateSupportingVolumeAndBackupPolicy(DeviceInfo deviceInfo) { var client = GetServiceClient<StorSimpleManagementClient>(); var actualdeviceId = deviceInfo.DeviceId; actualdeviceId = actualdeviceId.Trim(); CustomRequestHeaders hdrs = new CustomRequestHeaders(); hdrs.ClientRequestId = Guid.NewGuid().ToString(); hdrs.Language = "en-us"; //Get service configuration var serviceConfigList = client.ServiceConfig.Get(GetCustomRequestHeaders()); Assert.True(serviceConfigList != null); var existingSac = serviceConfigList.CredentialChangeList.Updated.FirstOrDefault(); Assert.True(existingSac != null); var dataContainerName = TestUtilities.GenerateName("DCName"); // new Data container request object var dc = new DataContainerRequest(); dc.IsDefault = false; dc.Name = dataContainerName; dc.BandwidthRate = 256; dc.VolumeCount = 0; dc.IsEncryptionEnabled = false; dc.PrimaryStorageAccountCredential = existingSac; //Create DataContainer call var taskStatus = client.DataContainer.Create(actualdeviceId, dc, hdrs); //Assert the job status Assert.NotNull(taskStatus); Assert.True(taskStatus.Status == AsyncTaskStatus.Completed); Assert.True(taskStatus.Result == AsyncTaskResult.Succeeded); //Get Data Container call var Createddatacontainer = client.DataContainer.Get(actualdeviceId, dataContainerName, hdrs); //Assert the returned data container object Assert.True(Createddatacontainer != null); Assert.True(Createddatacontainer.DataContainerInfo.Name.Equals(dataContainerName)); //ACR list for Virtual disk creation List<AccessControlRecord> acrList = new List<AccessControlRecord>(); for (var i = 0; i < 1; i++) { AccessControlRecord acr = new AccessControlRecord() { Name = TestUtilities.GenerateName("VDnewTestAcr"), InitiatorName = TestUtilities.GenerateName("VDinitiator") + i }; acrList.Add(acr); } //Virtual disk create request object var virtualDiskToCreate = new VirtualDiskRequest() { Name = TestUtilities.GenerateName("VD1Name"), AccessType = AccessType.ReadWrite, AcrList = acrList, AppType = AppType.PrimaryVolume, IsDefaultBackupEnabled = true, SizeInBytes = 107374182400, DataContainer = Createddatacontainer.DataContainerInfo, Online = true }; //Virtual disk create call taskStatus = client.VirtualDisk.Create(actualdeviceId, virtualDiskToCreate, hdrs); //Asserting the job status Assert.NotNull(taskStatus); Assert.True(taskStatus.Status == AsyncTaskStatus.Completed); Assert.True(taskStatus.Result == AsyncTaskResult.Succeeded); //Virtual disk get call var createdVirtualDisk = client.VirtualDisk.GetByName(actualdeviceId, virtualDiskToCreate.Name, hdrs); Assert.True(createdVirtualDisk != null); Assert.True(createdVirtualDisk.VirtualDiskInfo.Name.Equals(virtualDiskToCreate.Name)); var volumeIds = new List<string>(); volumeIds.Add(createdVirtualDisk.VirtualDiskInfo.InstanceId); var dailySchedule = new BackupScheduleBase(); dailySchedule.BackupType = BackupType.CloudSnapshot; dailySchedule.Status = ScheduleStatus.Enabled; dailySchedule.RetentionCount = 5; dailySchedule.StartTime = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzz"); dailySchedule.Recurrence = new ScheduleRecurrence(); dailySchedule.Recurrence.RecurrenceType = RecurrenceType.Daily; dailySchedule.Recurrence.RecurrenceValue = 5; var backupPolicyToCreate = new NewBackupPolicyConfig(); backupPolicyToCreate.Name = TestUtilities.GenerateName("PolicyName"); backupPolicyToCreate.VolumeIds = volumeIds; backupPolicyToCreate.BackupSchedules = new List<BackupScheduleBase>(); backupPolicyToCreate.BackupSchedules.Add(dailySchedule); //BackupPolicy create call taskStatus = client.BackupPolicy.Create(actualdeviceId, backupPolicyToCreate, hdrs); //Asserting the job status Assert.NotNull(taskStatus); Assert.True(taskStatus.Status == AsyncTaskStatus.Completed); Assert.True(taskStatus.Result == AsyncTaskResult.Succeeded); //BackupPolicy list call var allBackupPolicies = client.BackupPolicy.List(actualdeviceId, hdrs); //Assert the returned BackupPolicy object Assert.True(allBackupPolicies != null); Assert.True(allBackupPolicies.Any()); }