18
18
19
19
$Validate_EnableProtection_JobSucceeded = $true ;
20
20
$Validate_DisableProtection_JobSucceeded = $true ;
21
+
21
22
$Validate_PFO_JobSucceeded = $true ;
22
23
$Validate_Commit_PFO_JobSucceeded = $true ;
23
24
$Validate_Commit_Failback_JobSucceeded = $true ;
@@ -33,6 +34,7 @@ $Validate_PFOFailbackRP_JobSucceeded = $true;
33
34
$Validate_ProfileDissociation_JobSucceeded = $true ;
34
35
$Validate_ProfileAssociation_JobSucceeded = $true ;
35
36
37
+ # Test-EnableProtection 'E:\d\E2E_SKVault_Wednesday,January28,2015.VaultCredentials'
36
38
37
39
<#
38
40
. SYNOPSIS
@@ -79,6 +81,7 @@ function Test-E2E_DeleteAndDissociate
79
81
if ($Validate_ProfileDissociation_JobSucceeded -eq $true )
80
82
{
81
83
WaitForJobCompletion - JobId $job.ID
84
+ $job = Get-AzureSiteRecoveryJob - Id $job.ID
82
85
Assert-True { $job.State -eq " Succeeded" }
83
86
}
84
87
@@ -90,8 +93,7 @@ function Test-E2E_DeleteAndDissociate
90
93
}
91
94
}
92
95
93
- throw (" No PC found for E2E_DeleteAndDissociate" );
94
-
96
+ Assert-NotNull ($job ) " No PC found for E2E_DeleteAndDissociate"
95
97
}
96
98
97
99
@@ -133,14 +135,15 @@ function Test-E2E_CreateAndAssociate
133
135
if ($Validate_ProfileAssociation_JobSucceeded -eq $true )
134
136
{
135
137
WaitForJobCompletion - JobId $job.ID
138
+ $job = Get-AzureSiteRecoveryJob - Id $job.ID
136
139
Assert-True { $job.State -eq " Succeeded" }
137
140
}
138
141
139
142
return ;
140
143
}
141
144
}
142
145
143
- throw ( " No PC found for E2E_CreateAndAssociate" );
146
+ Assert-NotNull ( $job ) " No PC found for E2E_CreateAndAssociate"
144
147
}
145
148
146
149
<#
@@ -565,7 +568,7 @@ function Test-Failback
565
568
}
566
569
}
567
570
568
- throw ( " No VM found for failback" );
571
+ Assert-NotNull ( $job ) " No VM found for failback"
569
572
}
570
573
571
574
@@ -614,7 +617,7 @@ function Test-RRAfterFailback
614
617
}
615
618
}
616
619
617
- throw ( " No VM found for RRAfterFailback" ) ;
620
+ Assert-NotNull ( $job ) " No VM found for RRAfterFailback" ;
618
621
}
619
622
620
623
@@ -658,6 +661,12 @@ function Test-RRAfterFailover
658
661
Assert-True { $job.State -eq " Succeeded" }
659
662
}
660
663
664
+ # Validate_EnableProtection_WaitForCanFailover
665
+ if ($Validate_EnableProtection_WaitForCanFailover -eq $true )
666
+ {
667
+ WaitForCanFailover $protectionEntity.ProtectionContainerId $protectionEntity.ID
668
+ }
669
+
661
670
return ;
662
671
}
663
672
}
@@ -712,7 +721,7 @@ function Test-CommitPFO
712
721
}
713
722
}
714
723
715
- throw ( " No VM found for Commit_PFO" );
724
+ Assert-NotNull ( $job ) " No VM found for Commit_PFO"
716
725
}
717
726
718
727
@@ -761,7 +770,7 @@ function Test-PFO
761
770
}
762
771
}
763
772
764
- throw ( " No VM found for PFO" );
773
+ Assert-NotNull ( $job ) " No VM found for PFO"
765
774
}
766
775
767
776
<#
@@ -1033,7 +1042,7 @@ function Test-UFO
1033
1042
}
1034
1043
}
1035
1044
1036
- throw ( " No VM found for UFO" );
1045
+ Assert-NotNull ( $job ) " No VM found for UFO"
1037
1046
}
1038
1047
1039
1048
@@ -1090,7 +1099,7 @@ function Test-TFO
1090
1099
}
1091
1100
}
1092
1101
1093
- throw ( " No VM found for TFO" );
1102
+ Assert-NotNull ( $job ) " No VM found for TFO"
1094
1103
}
1095
1104
1096
1105
<#
@@ -1124,18 +1133,20 @@ function Test-EnableProtection
1124
1133
if ($protectionEntity.Protected -eq $false )
1125
1134
{
1126
1135
$job = Set-AzureSiteRecoveryProtectionEntity - ProtectionEntity $protectionEntity - Protection " Enable" - Force - ProtectionProfile $protectionContainer.AvailableProtectionProfiles [0 ] - WaitForCompletion
1136
+ Assert-NotNull ($job.State )
1137
+ Assert-NotNull ($job.ID )
1127
1138
1128
1139
# Validate_EnableProtection_JobSucceeded
1129
1140
if ($Validate_EnableProtection_JobSucceeded -eq $true )
1130
1141
{
1131
1142
$job = Get-AzureSiteRecoveryJob - Id $job.ID
1132
- Assert-True { $job.State -eq " Succeeded" }
1143
+ Assert-True { $job.State -eq " Succeeded" } " Job state is not not Succeeded. $job .State "
1133
1144
}
1134
1145
1135
1146
# Validate_EnableProtection_WaitForCanFailover
1136
1147
if ($Validate_EnableProtection_WaitForCanFailover -eq $true )
1137
1148
{
1138
- WaitForCanFailover $protectionEntity.Id
1149
+ WaitForCanFailover $protectionEntity.ProtectionContainerId $protectionEntity .ID
1139
1150
}
1140
1151
1141
1152
return ;
@@ -1144,7 +1155,7 @@ function Test-EnableProtection
1144
1155
}
1145
1156
}
1146
1157
1147
- throw ( " No VM found for Enable Protection" );
1158
+ Assert-NotNull ( $job ) " No VM found for Enable Protection"
1148
1159
}
1149
1160
1150
1161
<#
@@ -1175,16 +1186,18 @@ function Test-DisableProtection
1175
1186
{
1176
1187
Assert-NotNull ($protectionEntity.Name )
1177
1188
Assert-NotNull ($protectionEntity.ID )
1178
- Write-Host " Checking PE"
1189
+ Write-Output " Checking PE"
1179
1190
$protectionEntity
1180
1191
if ($protectionEntity.Protected -eq $true )
1181
1192
{
1182
- Write-Host " Disabling protection for PE: " + $protectionEntity.Name + " (" + $protectionEntity.ID + " )"
1193
+ Write-Output " Disabling protection for PE: " + $protectionEntity.Name + " (" + $protectionEntity.ID + " )"
1183
1194
$job = Set-AzureSiteRecoveryProtectionEntity - ProtectionEntity $protectionEntity - Protection " Disable" - Force - WaitForCompletion
1184
-
1195
+ Assert-NotNull ($job );
1196
+
1185
1197
# Validate_DisableProtection_JobSucceeded
1186
1198
if ($Validate_DisableProtection_JobSucceeded -eq $true )
1187
1199
{
1200
+ $job = Get-AzureSiteRecoveryJob - Id $job.ID
1188
1201
Assert-True { $job.State -eq " Succeeded" }
1189
1202
}
1190
1203
@@ -1194,7 +1207,7 @@ function Test-DisableProtection
1194
1207
}
1195
1208
}
1196
1209
1197
- throw ( " No VM found for Disable Protection" );
1210
+ Assert-NotNull ( $job ) " No VM found for Disable Protection"
1198
1211
}
1199
1212
1200
1213
<#
@@ -1203,23 +1216,18 @@ Recovery Services Enable Protection Tests
1203
1216
#>
1204
1217
function WaitForCanFailover
1205
1218
{
1206
- param ([string ] $peId )
1219
+ param ([string ] $pcId , [ string ] $ peId )
1207
1220
$count = 20
1208
1221
do
1209
1222
{
1210
1223
Start-Sleep 5
1211
- $pe = Get-AzureSiteRecoveryProtectionEntity - Id peId;
1212
- if ($count -ne 0 )
1213
- {
1214
- $count = $count -1 ;
1215
- }
1216
- else
1217
- {
1218
- throw (" WaitForCanFailover failed." );
1219
- return ;
1220
- }
1224
+ $pes = Get-AzureSiteRecoveryProtectionEntity - ProtectionContainerId $pcId ;
1225
+
1226
+ $count = $count -1 ;
1227
+
1228
+ Assert-True { $count -gt 0 } " Job did not reached desired state within 5*$count seconds."
1221
1229
1222
- } while ( -not ($pe .CanFailover -eq $true ))
1230
+ } while (-not ($pes [ 0 ] .CanFailover -eq $true ))
1223
1231
}
1224
1232
1225
1233
<#
0 commit comments