-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Service fabric] Retry for remaining commands (#7607)
* Retry for remaining commands * PR comment
- Loading branch information
1 parent
b7a7568
commit ebe288d
Showing
9 changed files
with
277 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
Tasks/ServiceFabricDeployV1/Tests/StartApplicationUpgradeShouldRetry.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
[CmdletBinding()] | ||
param() | ||
|
||
Import-Module ServiceFabric | ||
. $PSScriptRoot\..\..\..\Tests\lib\Initialize-Test.ps1 | ||
|
||
$ApplicationTypeName = "app type name" | ||
$ApplicationTypeVersion = "app type version" | ||
$applicationPackagePathInImageStore = "image path" | ||
|
||
$UpgradeParameters = @{ | ||
'ApplicationTypeName' = $ApplicationTypeName; | ||
'ApplicationTypeVersion' = $ApplicationTypeVersion | ||
'ApplicationParameter' = {} | ||
} | ||
|
||
$upgradeStatus = @{ | ||
'UpgradeState' = 'RollingForwardCompleted' | ||
} | ||
$global:startUpgradeAttempted = 0 | ||
$global:getRetriesAttempted = 0 | ||
$global:appHealthPrinted = $false | ||
|
||
Register-Mock Start-ServiceFabricApplicationUpgrade { | ||
$global:startUpgradeAttempted++ | ||
throw [System.Fabric.FabricTransientException]::new("Could not ping!") | ||
} -- @UpgradeParameters | ||
|
||
Register-Mock Get-ServiceFabricApplicationUpgrade { | ||
$global:getRetriesAttempted++ | ||
|
||
if ($global:getRetriesAttempted -eq 3) | ||
{ | ||
$upgradeStatus.UpgradeState = 'RollingForwardCompleted' | ||
return $upgradeStatus | ||
} | ||
|
||
if ($global:getRetriesAttempted -eq 2) | ||
{ | ||
return $null | ||
} | ||
|
||
throw [System.Fabric.FabricTransientException]::new("Could not ping!") | ||
} -- -ApplicationName $ApplicationName | ||
|
||
Register-Mock Get-ServiceFabricApplicationHealth { | ||
$global:appHealthPrinted = $true | ||
} | ||
|
||
Register-Mock Start-Sleep {} | ||
Register-Mock Write-VstsTaskError | ||
|
||
# Act | ||
. $PSScriptRoot\..\..\..\Tasks\ServiceFabricDeployV1\ps_modules\PowershellHelpers\Helpers.ps1 | ||
. $PSScriptRoot\..\..\..\Tasks\ServiceFabricDeployV1\ServiceFabricSDK\Utilities.ps1 | ||
|
||
# Act/Assert | ||
Assert-Throws { | ||
Start-ServiceFabricApplicationUpgradeAction -UpgradeParameters $UpgradeParameters | ||
} | ||
Assert-AreEqual 3 $global:startUpgradeAttempted "Number of start upgrade retries not correct" | ||
Assert-AreEqual $true $global:appHealthPrinted "cluster health not printed in case of error" |
60 changes: 60 additions & 0 deletions
60
Tasks/ServiceFabricDeployV1/Tests/StartApplicationUpgradeShouldRetryTillSuccess.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
[CmdletBinding()] | ||
param() | ||
|
||
Import-Module ServiceFabric | ||
. $PSScriptRoot\..\..\..\Tests\lib\Initialize-Test.ps1 | ||
|
||
$ApplicationTypeName = "app type name" | ||
$ApplicationTypeVersion = "app type version" | ||
$applicationPackagePathInImageStore = "image path" | ||
|
||
$UpgradeParameters = @{ | ||
'ApplicationTypeName' = $ApplicationTypeName; | ||
'ApplicationTypeVersion' = $ApplicationTypeVersion | ||
'ApplicationParameter' = {} | ||
} | ||
|
||
$upgradeStatus = @{ | ||
'UpgradeState' = 'RollingForwardCompleted' | ||
} | ||
$global:startUpgradeAttempted = 0 | ||
$global:getRetriesAttempted = 0 | ||
$global:appHealthPrinted = $false | ||
|
||
Register-Mock Start-ServiceFabricApplicationUpgrade { | ||
$global:startUpgradeAttempted++ | ||
throw [System.Fabric.FabricTransientException]::new("Could not ping!") | ||
} -- @UpgradeParameters | ||
|
||
Register-Mock Get-ServiceFabricApplicationUpgrade { | ||
$global:getRetriesAttempted++ | ||
|
||
if ($global:getRetriesAttempted -eq 6) | ||
{ | ||
$upgradeStatus.UpgradeState = 'RollingForwardInProgress' | ||
return $upgradeStatus | ||
} | ||
|
||
if ($global:getRetriesAttempted -eq 3) | ||
{ | ||
$upgradeStatus.UpgradeState = 'RollingForwardCompleted' | ||
return $upgradeStatus | ||
} | ||
|
||
throw [System.Fabric.FabricTransientException]::new("Could not ping!") | ||
} -- -ApplicationName $ApplicationName | ||
|
||
Register-Mock Get-ServiceFabricApplicationHealth { | ||
$global:appHealthPrinted = $true | ||
} | ||
|
||
Register-Mock Start-Sleep {} | ||
Register-Mock Write-VstsTaskError | ||
|
||
# Act | ||
. $PSScriptRoot\..\..\..\Tasks\ServiceFabricDeployV1\ps_modules\PowershellHelpers\Helpers.ps1 | ||
. $PSScriptRoot\..\..\..\Tasks\ServiceFabricDeployV1\ServiceFabricSDK\Utilities.ps1 | ||
|
||
# Act/Assert | ||
Start-ServiceFabricApplicationUpgradeAction -UpgradeParameters $UpgradeParameters | ||
Assert-AreEqual 2 $global:startUpgradeAttempted "Number of start upgrade retries not correct" |
Oops, something went wrong.