Skip to content

Commit 81beeda

Browse files
iliu816NoriZC
andauthored
[Az.ServiceFabric] Set-AzServiceFabricManagedClusterApplication: Fix bug where -RecreateApplication flag did not overwrite existing upgrade policy (#28310)
Co-authored-by: NoriZC <[email protected]>
1 parent bd63b5a commit 81beeda

File tree

6 files changed

+8154
-1244
lines changed

6 files changed

+8154
-1244
lines changed

src/ServiceFabric/ServiceFabric.Test/ScenarioTests/ServiceFabricManagedClustersApplicationTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ public void TestManagedApp()
4848
TestRunner.RunTestScript("Test-ManagedApp");
4949
}
5050

51+
[Fact]
52+
[Trait(Category.AcceptanceType, Category.CheckIn)]
53+
public void TestManagedAppUpgradeRecreate()
54+
{
55+
TestRunner.RunTestScript("Test-ManagedAppUpgrade-Recreate");
56+
}
57+
5158
[Fact]
5259
[Trait(Category.AcceptanceType, Category.CheckIn)]
5360
public void TestManagedService()

src/ServiceFabric/ServiceFabric.Test/ScenarioTests/ServiceFabricManagedClustersApplicationTests.ps1

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,74 @@ function Test-ManagedApp
207207
Assert-ThrowsContains { Get-AzServiceFabricManagedClusterApplication -ResourceGroupName $resourceGroupName -ClusterName $clusterName -Name $appName } "NotFound"
208208
}
209209

210+
function Test-ManagedAppUpgrade-Recreate
211+
{
212+
# Cluster Setup
213+
$resourceGroupName = "sfmcps-rg-" + (getAssetname)
214+
$clusterName = "sfmcps-" + (getAssetname)
215+
$location = "southcentralus"
216+
$testClientTp = "123BDACDCDFB2C7B250192C6078E47D1E1DB119B"
217+
$pass = (ConvertTo-SecureString -AsPlainText -Force (-join ((33..126) | Get-Random -Count 16 | % {[char]$_})))
218+
$tags = @{"SFRP.EnableDiagnosticMI"="true"; "SFRP.DisableDefaultOutboundAccess"="true"; "SFRP.WaitTimeBetweenUD"="00:00:10"; "testName"="Test-ManagedApp-RecreateApplication"}
219+
220+
Assert-ThrowsContains { Get-AzServiceFabricManagedCluster -ResourceGroupName $resourceGroupName -Name $clusterName } "NotFound"
221+
222+
$cluster = New-AzServiceFabricManagedCluster -ResourceGroupName $resourceGroupName -ClusterName $clusterName -Location $location `
223+
-AdminPassword $pass -Sku Standard -ClientCertThumbprint $testClientTp -Tag $tags -Verbose
224+
Assert-AreEqual "Succeeded" $cluster.ProvisioningState
225+
Assert-AreEqual "WaitingForNodes" $cluster.ClusterState
226+
227+
New-AzServiceFabricManagedNodeType -ResourceGroupName $resourceGroupName -ClusterName $clusterName -Name pnt -InstanceCount 5 -Primary -AsJob
228+
229+
#wait for nodetypes
230+
WaitForAllJob
231+
232+
# Wait for clusterState
233+
WaitForManagedClusterReadyStateIfRecord $clusterName $resourceGroupName
234+
235+
$appName = getAssetName "testApp"
236+
$serviceName = getAssetName "testStatelessService"
237+
238+
$apps = Get-AzServiceFabricManagedClusterApplication -ResourceGroupName $resourceGroupName -ClusterName $clusterName
239+
Assert-Null $apps
240+
241+
$app = New-AzServiceFabricManagedClusterApplication -ResourceGroupName $resourceGroupName -ClusterName $clusterName -ApplicationTypeName $appTypeName -ApplicationTypeVersion $v1 -Name $appName -PackageUrl $packageV1 -Verbose
242+
Assert-AreEqual "Succeeded" $app.ProvisioningState
243+
244+
$appFromGet = Get-AzServiceFabricManagedClusterApplication -ResourceGroupName $resourceGroupName -ClusterName $clusterName -Name $appName
245+
Assert-NotNull $appFromGet
246+
Assert-AreEqual $app.Id $appFromGet.Id
247+
248+
$service = New-AzServiceFabricManagedClusterService -ResourceGroupName $resourceGroupName -ClusterName $clusterName -Stateless -InstanceCount -1 -ApplicationName $appName -Name $serviceName -Type $statelessServiceTypeName -PartitionSchemeSingleton -Verbose
249+
Assert-AreEqual "Succeeded" $service.ProvisioningState
250+
251+
$serviceFromGet = Get-AzServiceFabricManagedClusterService -ResourceGroupName $resourceGroupName -ClusterName $clusterName -ApplicationName $appName -Name $serviceName
252+
Assert-NotNull $serviceFromGet
253+
Assert-AreEqual $service.Id $serviceFromGet.Id
254+
255+
$appTypeVersion = New-AzServiceFabricManagedClusterApplicationTypeVersion -ResourceGroupName $resourceGroupName -ClusterName $clusterName -Name $appTypeName -Version $v2 -PackageUrl $packageV2 -Verbose
256+
Assert-AreEqual "Succeeded" $appTypeVersion.ProvisioningState
257+
258+
# Test upgrade with recreate policy
259+
$app = $appFromGet | Set-AzServiceFabricManagedClusterApplication -ApplicationTypeVersion $v2 -RecreateApplication -Verbose
260+
Assert-AreEqual "Succeeded" $app.ProvisioningState
261+
Assert-EndsWith $v2 $app.Version
262+
Assert-True { $app.UpgradePolicy.RecreateApplication }
263+
264+
# Test noop
265+
$appNoop = $app | Set-AzServiceFabricManagedClusterApplication
266+
Assert-AreEqual "Succeeded" $appNoop.ProvisioningState
267+
Assert-AreEqualObjectProperties $app $appNoop
268+
269+
$removeResponse = Remove-AzServiceFabricManagedClusterApplication -ResourceGroupName $resourceGroupName -ClusterName $clusterName -Name $appName -Force -PassThru -Verbose
270+
Assert-True { $removeResponse }
271+
272+
$removeResponse = Remove-AzServiceFabricManagedClusterApplicationType -ResourceGroupName $resourceGroupName -ClusterName $clusterName -Name $appTypeName -Force -PassThru -Verbose
273+
Assert-True { $removeResponse }
274+
275+
Assert-ThrowsContains { Get-AzServiceFabricManagedClusterApplication -ResourceGroupName $resourceGroupName -ClusterName $clusterName -Name $appName } "NotFound"
276+
}
277+
210278
function Test-ManagedService
211279
{
212280
# Cluster Setup

0 commit comments

Comments
 (0)