@@ -207,6 +207,74 @@ function Test-ManagedApp
207
207
Assert-ThrowsContains { Get-AzServiceFabricManagedClusterApplication - ResourceGroupName $resourceGroupName - ClusterName $clusterName - Name $appName } " NotFound"
208
208
}
209
209
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
+
210
278
function Test-ManagedService
211
279
{
212
280
# Cluster Setup
0 commit comments