Skip to content

Commit 73f54d0

Browse files
author
Samuel Anudeep
committed
Merge pull request #249 from MabOneSdk/anudeeb-dev1
Added Backup Test Record
2 parents bbec770 + 5321d77 commit 73f54d0

File tree

4 files changed

+98
-165285
lines changed

4 files changed

+98
-165285
lines changed

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Helpers/Conversions/ConversionHelpers.cs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,24 +93,24 @@ public static AzureRmRecoveryServicesBackupPolicyBase GetPolicyModel(ProtectionP
9393
{
9494
AzureRmRecoveryServicesBackupPolicyBase policyModel = null;
9595

96-
if(hydraResponse == null || hydraResponse.Properties == null)
96+
if (hydraResponse == null || hydraResponse.Properties == null)
9797
{
9898
Logger.Instance.WriteDebug("Policy Hydra response is Null/Empty");
9999
throw new ArgumentException(Resources.EmptyHydraResponseException);
100100
}
101101

102102
if (hydraResponse.Properties.GetType() == typeof(AzureIaaSVMProtectionPolicy))
103103
{
104-
if(((AzureIaaSVMProtectionPolicy)hydraResponse.Properties).RetentionPolicy.GetType() !=
104+
if (((AzureIaaSVMProtectionPolicy)hydraResponse.Properties).RetentionPolicy.GetType() !=
105105
typeof(LongTermRetentionPolicy))
106106
{
107107
Logger.Instance.WriteDebug("Unknown RetentionPolicy object received: " +
108-
((AzureIaaSVMProtectionPolicy)hydraResponse.Properties).RetentionPolicy.GetType());
108+
((AzureIaaSVMProtectionPolicy)hydraResponse.Properties).RetentionPolicy.GetType());
109109
Logger.Instance.WriteWarning(Resources.UpdateToNewAzurePowershellWarning);
110110
return null;
111111
}
112112

113-
if (((AzureIaaSVMProtectionPolicy)hydraResponse.Properties).SchedulePolicy.GetType() !=
113+
if (((AzureIaaSVMProtectionPolicy)hydraResponse.Properties).SchedulePolicy.GetType() !=
114114
typeof(SimpleSchedulePolicy))
115115
{
116116
Logger.Instance.WriteDebug("Unknown SchedulePolicy object received: " +
@@ -129,7 +129,7 @@ public static AzureRmRecoveryServicesBackupPolicyBase GetPolicyModel(ProtectionP
129129
((AzureIaaSVMProtectionPolicy)hydraResponse.Properties).SchedulePolicy);
130130
}
131131
else
132-
{
132+
{
133133
// we will enter this case when service supports new workload and customer
134134
// still using old version of azure powershell. Trace warning message, ignore and return
135135
Logger.Instance.WriteDebug("Unknown Policy object received: " +
@@ -147,7 +147,7 @@ public static AzureRmRecoveryServicesBackupPolicyBase GetPolicyModel(ProtectionP
147147
public static List<AzureRmRecoveryServicesBackupPolicyBase> GetPolicyModelList(
148148
ProtectionPolicyListResponse hydraListResponse)
149149
{
150-
if(hydraListResponse == null || hydraListResponse.ItemList == null ||
150+
if (hydraListResponse == null || hydraListResponse.ItemList == null ||
151151
hydraListResponse.ItemList.Value == null || hydraListResponse.ItemList.Value.Count == 0)
152152
{
153153
Logger.Instance.WriteDebug("Received empty list of policies from service");
@@ -157,10 +157,10 @@ public static List<AzureRmRecoveryServicesBackupPolicyBase> GetPolicyModelList(
157157
List<AzureRmRecoveryServicesBackupPolicyBase> policyModels = new List<AzureRmRecoveryServicesBackupPolicyBase>();
158158
AzureRmRecoveryServicesBackupPolicyBase policyModel = null;
159159

160-
foreach(ProtectionPolicyResource resource in hydraListResponse.ItemList.Value)
160+
foreach (ProtectionPolicyResource resource in hydraListResponse.ItemList.Value)
161161
{
162162
policyModel = GetPolicyModel(resource);
163-
if(policyModel != null)
163+
if (policyModel != null)
164164
{
165165
policyModels.Add(policyModel);
166166
}
@@ -183,10 +183,14 @@ public static AzureRmRecoveryServicesItemBase GetItemModel(ProtectedItemResource
183183
{
184184
if (protectedItem.Properties.GetType().IsSubclassOf(typeof(AzureIaaSVMProtectedItem)))
185185
{
186+
string policyName = null;
186187
string policyId = ((AzureIaaSVMProtectedItem)protectedItem.Properties).PolicyId;
187-
Dictionary<UriEnums, string> keyVauleDict =
188+
if (policyId != null)
189+
{
190+
Dictionary<UriEnums, string> keyVauleDict =
188191
HelperUtils.ParseUri(policyId);
189-
string policyName = HelperUtils.GetPolicyNameFromPolicyId(keyVauleDict, policyId);
192+
policyName = HelperUtils.GetPolicyNameFromPolicyId(keyVauleDict, policyId);
193+
}
190194
itemModel = new AzureRmRecoveryServicesIaasVmItem(protectedItem, container, policyName);
191195
}
192196
}

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Test/ScenarioTests/IaasVm/ItemTests.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,6 @@ function Test-BackupItemScenario
9696
$item = Get-AzureRmRecoveryServicesBackupItem -Container $namedContainer -WorkloadType "AzureVM";
9797
echo $item.Name;
9898

99-
Backup-AzureRmRecoveryServicesItem -Item $item | Wait-AzureRmBackupJob;
99+
$job = Backup-AzureRmRecoveryServicesItem -Item $item;
100+
Assert-NotNull $job;
100101
}

0 commit comments

Comments
 (0)