@@ -100,4 +100,208 @@ function Test-RecoveryServicesProtectionTests
100
100
}
101
101
}
102
102
}
103
- }
103
+ }
104
+
105
+ <#
106
+ . SYNOPSIS
107
+ Recovery Services Storage mapping tests and validation
108
+ #>
109
+ function Test-StorageMapping
110
+ {
111
+ param ([string ] $vaultSettingsFilePath )
112
+
113
+ # Import Azure Site Recovery Vault Settings
114
+ Import-AzureSiteRecoveryVaultSettingsFile $vaultSettingsFilePath
115
+
116
+ # Enumerate Servers
117
+ $servers = Get-AzureSiteRecoveryServer
118
+ Assert-True { $servers.Count -gt 0 }
119
+ Assert-NotNull ($servers )
120
+ foreach ($server in $servers )
121
+ {
122
+ Assert-NotNull ($server.Name )
123
+ Assert-NotNull ($server.ID )
124
+ }
125
+
126
+ # Enumerate Storages
127
+ $storages = Get-AzureSiteRecoveryStorage - Server $servers [0 ]
128
+ Assert-NotNull ($storages )
129
+ Assert-True { $storages.Count -gt 0 }
130
+ foreach ($storage in $storages )
131
+ {
132
+ Assert-NotNull ($storage.Name )
133
+ Assert-NotNull ($storage.ID )
134
+ }
135
+
136
+ # Enumerate StorageMappings
137
+ $storageMappings = Get-AzureSiteRecoveryStorageMapping - PrimaryServer $servers [0 ] - RecoveryServer $servers [0 ]
138
+ Assert-True { $storageMappings.Count -eq 0 }
139
+
140
+ # Create StorageMapping
141
+ $job = New-AzureSiteRecoveryStorageMapping - PrimaryStorage $storages [0 ] - RecoveryStorage $storages [1 ]
142
+ WaitForJobCompletion - JobId $job.ID
143
+
144
+ # Enumerate StorageMappings
145
+ $storageMappings = Get-AzureSiteRecoveryStorageMapping - PrimaryServer $servers [0 ] - RecoveryServer $servers [0 ]
146
+ Assert-NotNull ($storageMappings )
147
+ Assert-True { $storageMappings.Count -eq 1 }
148
+ Assert-NotNull ($storageMappings [0 ].PrimaryServerId)
149
+ Assert-NotNull ($storageMappings [0 ].PrimaryStorageId)
150
+ Assert-NotNull ($storageMappings [0 ].RecoveryServerId)
151
+ Assert-NotNull ($storageMappings [0 ].RecoveryStorageId)
152
+ }
153
+
154
+ <#
155
+ . SYNOPSIS
156
+ Recovery Services Storage unmapping tests and validation
157
+ #>
158
+ function Test-StorageUnMapping
159
+ {
160
+ param ([string ] $vaultSettingsFilePath )
161
+
162
+ # Import Azure Site Recovery Vault Settings
163
+ Import-AzureSiteRecoveryVaultSettingsFile $vaultSettingsFilePath
164
+
165
+ # Enumerate Servers
166
+ $servers = Get-AzureSiteRecoveryServer
167
+ Assert-True { $servers.Count -gt 0 }
168
+ Assert-NotNull ($servers )
169
+ foreach ($server in $servers )
170
+ {
171
+ Assert-NotNull ($server.Name )
172
+ Assert-NotNull ($server.ID )
173
+ }
174
+
175
+ # Enumerate StorageMappings
176
+ $storageMappings = Get-AzureSiteRecoveryStorageMapping - PrimaryServer $servers [0 ] - RecoveryServer $servers [0 ]
177
+ Assert-NotNull ($storageMappings )
178
+ Assert-True { $storageMappings.Count -eq 1 }
179
+ Assert-NotNull ($storageMappings [0 ].PrimaryServerId)
180
+ Assert-NotNull ($storageMappings [0 ].PrimaryStorageId)
181
+ Assert-NotNull ($storageMappings [0 ].RecoveryServerId)
182
+ Assert-NotNull ($storageMappings [0 ].RecoveryStorageId)
183
+
184
+ # Remove StorageMapping
185
+ $job = Remove-AzureSiteRecoveryStorageMapping - StorageMapping $storageMappings [0 ]
186
+ WaitForJobCompletion - JobId $job.ID
187
+
188
+ # Enumerate StorageMappings
189
+ $storageMappings = Get-AzureSiteRecoveryStorageMapping - PrimaryServer $servers [0 ] - RecoveryServer $servers [0 ]
190
+ Assert-True { $storageMappings.Count -eq 0 }
191
+ }
192
+
193
+ <#
194
+ . SYNOPSIS
195
+ Recovery Services Network mapping tests and validation
196
+ #>
197
+ function Test-NetworkMapping
198
+ {
199
+ param ([string ] $vaultSettingsFilePath )
200
+
201
+ # Import Azure Site Recovery Vault Settings
202
+ Import-AzureSiteRecoveryVaultSettingsFile $vaultSettingsFilePath
203
+
204
+ # Enumerate Servers
205
+ $servers = Get-AzureSiteRecoveryServer
206
+ Assert-True { $servers.Count -gt 0 }
207
+ Assert-NotNull ($servers )
208
+ foreach ($server in $servers )
209
+ {
210
+ Assert-NotNull ($server.Name )
211
+ Assert-NotNull ($server.ID )
212
+ }
213
+
214
+ # Enumerate Networks
215
+ $networks = Get-AzureSiteRecoveryNetwork - Server $servers [0 ]
216
+ Assert-NotNull ($networks )
217
+ Assert-True { $networks.Count -gt 0 }
218
+ foreach ($network in $networks )
219
+ {
220
+ Assert-NotNull ($network.Name )
221
+ Assert-NotNull ($network.ID )
222
+ }
223
+
224
+ # Enumerate NetworkMappings
225
+ $networkMappings = Get-AzureSiteRecoveryNetworkMapping - PrimaryServer $servers [0 ] - RecoveryServer $servers [0 ]
226
+ Assert-True { $networkMappings.Count -eq 0 }
227
+
228
+ # Create NetworkMapping
229
+ $job = New-AzureSiteRecoveryNetworkMapping - PrimaryNetwork $networks [0 ] - RecoveryNetwork $networks [1 ]
230
+ WaitForJobCompletion - JobId $job.ID
231
+
232
+ # Enumerate NetworkMappings
233
+ $networkMappings = Get-AzureSiteRecoveryNetworkMapping - PrimaryServer $servers [0 ] - RecoveryServer $servers [0 ]
234
+ Assert-NotNull ($networkMappings )
235
+ Assert-True { $networkMappings.Count -eq 1 }
236
+ Assert-NotNull ($networkMappings [0 ].PrimaryServerId)
237
+ Assert-NotNull ($networkMappings [0 ].PrimaryNetworkId)
238
+ Assert-NotNull ($networkMappings [0 ].PrimaryNetworkName)
239
+ Assert-NotNull ($networkMappings [0 ].RecoveryServerId)
240
+ Assert-NotNull ($networkMappings [0 ].RecoveryNetworkId)
241
+ Assert-NotNull ($networkMappings [0 ].RecoveryNetworkName)
242
+ }
243
+
244
+ <#
245
+ . SYNOPSIS
246
+ Recovery Services Network unmapping tests and validation
247
+ #>
248
+ function Test-NetworkUnMapping
249
+ {
250
+ param ([string ] $vaultSettingsFilePath )
251
+
252
+ # Import Azure Site Recovery Vault Settings
253
+ Import-AzureSiteRecoveryVaultSettingsFile $vaultSettingsFilePath
254
+
255
+ # Enumerate Servers
256
+ $servers = Get-AzureSiteRecoveryServer
257
+ Assert-True { $servers.Count -gt 0 }
258
+ Assert-NotNull ($servers )
259
+ foreach ($server in $servers )
260
+ {
261
+ Assert-NotNull ($server.Name )
262
+ Assert-NotNull ($server.ID )
263
+ }
264
+
265
+ # Enumerate NetworkMappings
266
+ $networkMappings = Get-AzureSiteRecoveryNetworkMapping - PrimaryServer $servers [0 ] - RecoveryServer $servers [0 ]
267
+ Assert-NotNull ($networkMappings )
268
+ Assert-True { $networkMappings.Count -eq 1 }
269
+ Assert-NotNull ($networkMappings [0 ].PrimaryServerId)
270
+ Assert-NotNull ($networkMappings [0 ].PrimaryNetworkId)
271
+ Assert-NotNull ($networkMappings [0 ].PrimaryNetworkName)
272
+ Assert-NotNull ($networkMappings [0 ].RecoveryServerId)
273
+ Assert-NotNull ($networkMappings [0 ].RecoveryNetworkId)
274
+ Assert-NotNull ($networkMappings [0 ].RecoveryNetworkName)
275
+
276
+ # Remove StorageMapping
277
+ $job = Remove-AzureSiteRecoveryNetworkMapping - NetworkMapping $networkMappings [0 ]
278
+ WaitForJobCompletion - JobId $job.ID
279
+
280
+ # Enumerate NetworkMappings
281
+ $networkMappings = Get-AzureSiteRecoveryNetworkMapping - PrimaryServer $servers [0 ] - RecoveryServer $servers [0 ]
282
+ Assert-True { $networkMappings.Count -eq 0 }
283
+ }
284
+
285
+ <#
286
+ . SYNOPSIS
287
+ Wait for job completion
288
+ Usage:
289
+ WaitForJobCompletion -JobId $job.ID
290
+ WaitForJobCompletion -JobId $job.ID -NumOfSecondsToWait 10
291
+ #>
292
+ function WaitForJobCompletion
293
+ {
294
+ param ([string ] $JobId , [Int ] $NumOfSecondsToWait = 30 )
295
+ $endStateDescription = @ (' Succeeded' , ' Failed' , ' Cancelled' , ' Suspended' )
296
+
297
+ $timeElapse = 0 ;
298
+ $interval = 5 ;
299
+ do
300
+ {
301
+ Start-Sleep $interval
302
+ $timeElapse = $timeElapse + $interval
303
+ $job = Get-AzureSiteRecoveryJob - Id $JobId ;
304
+ } while ((-not ($endStateDescription -ccontains $job.State )) -and ($timeElapse -lt $NumOfSecondsToWait ))
305
+
306
+ Assert-True { $endStateDescription -ccontains $job.State } " Job did not reached desired state within $NumOfSecondsToWait seconds."
307
+ }
0 commit comments