Skip to content

Commit 4234f54

Browse files
LukeSlevAlfredo Santamaria Gomeza-santamariawyunchi-ms
authored
[ServiceFabric] New Az Cmdlets for Service fabric Managed app cmdlets (App, AppType, AppTypeVersion, Service) (Azure#14458)
* change to use managedclusters sdk * create managedcmdletbase to separate sdk clients * include managed client in tests project * move to folders in managed clusters * re-record managed clusters tests * update managed clusters pacakge to published version 1.0.0-beta.1 * managed app type cmdlets * managed app type version cmdlets * managed app cmdlets * managed service cmdlets and module export update * add tests for managed app, app type, app type version, service * Help Doc updates, changelog and module * Fix StaticAnalysis BreakingChange and Signature issues * remove .ManagedClusters from models namespace * regenerate help * Rename UpgradeMode to ApplicationUpgradeMode * suppress managed clusters breaking changes as it is in preview (#2) * Fix static analysis signature issues * fix breaking changes exceptions (#3) * adding missing header * fixing breakingChangeIssues file * add missing braking changes * remove duplicates from braking exceptions * fix app tests * Change Tags to singular for application Co-authored-by: Alfredo Santamaria Gomez <[email protected]> Co-authored-by: Alfredo Santamaria Gomez <[email protected]> Co-authored-by: Alfredo Santamaria <[email protected]> Co-authored-by: Yunchi Wang <[email protected]>
1 parent 1dff131 commit 4234f54

File tree

82 files changed

+42944
-8594
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+42944
-8594
lines changed

src/ServiceFabric/ServiceFabric.Test/ScenarioTests/Common.ps1

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,37 @@ function WaitForClusterReadyState($clusterName, $resourceGroupName, $timeoutInSe
192192
return $false
193193
}
194194

195+
function WaitForManagedClusterReadyStateIfRecord($clusterName, $resourceGroupName)
196+
{
197+
if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne [Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback)
198+
{
199+
# Wait for Ready cluster state before updating otherwise update is going to fail
200+
if (-not (WaitForManagedClusterReadyState $clusterName $resourceGroupName))
201+
{
202+
Assert-True $false 'Cluster is not in Ready state. Can not continue with test.'
203+
}
204+
}
205+
}
206+
207+
function WaitForManagedClusterReadyState($clusterName, $resourceGroupName, $timeoutInSeconds = 1200)
208+
{
209+
$timeoutTime = (Get-Date).AddSeconds($timeoutInSeconds)
210+
while (-not $clusterReady -and (Get-Date) -lt $timeoutTime) {
211+
$cluster = (Get-AzServiceFabricManagedCluster -ResourceGroupName $resourceGroupName -Name $clusterName)[0]
212+
if ($cluster.ClusterState -eq "Ready")
213+
{
214+
return $true
215+
break
216+
}
217+
218+
Write-Host "Cluster state: $($cluster.ClusterState). Waiting for Ready state before continuing."
219+
Start-Sleep -Seconds 15
220+
}
221+
222+
Write-Error "WaitForClusterReadyState timed out"
223+
return $false
224+
}
225+
195226
function WaitForAllJob($timeoutInSeconds = 1200)
196227
{
197228
$timeoutTime = (Get-Date).AddSeconds($timeoutInSeconds)
@@ -219,6 +250,53 @@ function WaitForAllJob($timeoutInSeconds = 1200)
219250
return $false
220251
}
221252

253+
<#
254+
.SYNOPSIS
255+
Asserts if two hashtables with simple key and value types are equal
256+
#>
257+
function Assert-HashtableEqual($h1, $h2)
258+
{
259+
if($h1.count -ne $h2.count)
260+
{
261+
throw "Hashtable size not equal. Hashtable1: " + $h1.count + " Hashtable2: " + $h2.count
262+
}
263+
264+
foreach($key in $h1.Keys)
265+
{
266+
if($h1[$key] -ne $h2[$key])
267+
{
268+
throw "Tag content not equal. Key:$key Tags1:" + $h1[$key] + " Tags2:" + $h2[$key]
269+
}
270+
}
271+
}
272+
273+
###################
274+
#
275+
# Verify that the actual string ends with the expected suffix
276+
#
277+
# param [string] $expectedSuffix : The expected suffix
278+
# param [string] $actual : The actual string
279+
# param [string] $message : The message to return if the actual string does not end with the suffix
280+
####################
281+
function Assert-EndsWith
282+
{
283+
param([string] $expectedSuffix, [string] $actual, [string] $message)
284+
285+
Assert-NotNull $actual
286+
287+
if (!$message)
288+
{
289+
$message = "Assertion failed because actual '$actual' does not end with '$expectedSuffix'"
290+
}
291+
292+
if (-not $actual.EndsWith($expectedSuffix))
293+
{
294+
throw $message
295+
}
296+
297+
return $true
298+
}
299+
222300
# Application functions
223301

224302
function Get-AppTypeName
@@ -249,4 +327,41 @@ function Get-AppPackageV2
249327
function Get-ServiceTypeName
250328
{
251329
return "CalcServiceType"
330+
}
331+
332+
# Managed Application functions
333+
334+
function Get-ManagedAppTypeName
335+
{
336+
return "VotingType"
337+
}
338+
339+
function Get-ManagedAppTypeV1Name
340+
{
341+
return "1.0.0"
342+
}
343+
344+
function Get-ManagedAppTypeV2Name
345+
{
346+
return "2.0.0"
347+
}
348+
349+
function Get-ManagedAppPackageV1
350+
{
351+
return "https://sfmconeboxst.blob.core.windows.net/managed-application-deployment/Voting.sfpkg"
352+
}
353+
354+
function Get-ManagedAppPackageV2
355+
{
356+
return "https://sfmconeboxst.blob.core.windows.net/managed-application-deployment/Voting.2.0.0.sfpkg"
357+
}
358+
359+
function Get-ManagedStatelessServiceTypeName
360+
{
361+
return "VotingWebType"
362+
}
363+
364+
function Get-ManagedStatefulServiceTypeName
365+
{
366+
return "VotingDataType"
252367
}

src/ServiceFabric/ServiceFabric.Test/ScenarioTests/ServiceFabricApplicationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public ServiceFabricApplicationTests(ITestOutputHelper output)
3030
_logger = new XunitTracingInterceptor(output);
3131
XunitTracingInterceptor.AddToContext(_logger);
3232

33-
ServiceFabricCommonCmdletBase.WriteVerboseIntervalInSec = 0;
33+
ServiceFabricManagedCmdletBase.WriteVerboseIntervalInSec = 0;
3434
ServiceFabricCmdletBase.RunningTest = true;
3535
}
3636

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Commands.ServiceFabric.Commands;
16+
using Microsoft.Azure.ServiceManagement.Common.Models;
17+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
18+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
19+
using Xunit;
20+
using Xunit.Abstractions;
21+
22+
namespace Microsoft.Azure.Commands.ServiceFabric.Test.ScenarioTests
23+
{
24+
public class ServiceFabricManagedClustersApplicationTests : RMTestBase
25+
{
26+
public XunitTracingInterceptor _logger;
27+
28+
public ServiceFabricManagedClustersApplicationTests(ITestOutputHelper output)
29+
{
30+
_logger = new XunitTracingInterceptor(output);
31+
XunitTracingInterceptor.AddToContext(_logger);
32+
33+
ServiceFabricCommonCmdletBase.WriteVerboseIntervalInSec = 0;
34+
ServiceFabricCmdletBase.RunningTest = true;
35+
}
36+
37+
[Fact]
38+
[Trait(Category.AcceptanceType, Category.CheckIn)]
39+
public void TestManagedAppType()
40+
{
41+
TestController.NewInstance.RunPsTest(_logger, "Test-ManagedAppType");
42+
}
43+
44+
[Fact]
45+
[Trait(Category.AcceptanceType, Category.CheckIn)]
46+
public void TestManagedAppTypeVersion()
47+
{
48+
TestController.NewInstance.RunPsTest(_logger, "Test-ManagedAppTypeVersion");
49+
}
50+
51+
[Fact]
52+
[Trait(Category.AcceptanceType, Category.CheckIn)]
53+
public void TestManagedApp()
54+
{
55+
TestController.NewInstance.RunPsTest(_logger, "Test-ManagedApp");
56+
}
57+
58+
[Fact]
59+
[Trait(Category.AcceptanceType, Category.CheckIn)]
60+
public void TestManagedService()
61+
{
62+
TestController.NewInstance.RunPsTest(_logger, "Test-ManagedService");
63+
}
64+
}
65+
}

0 commit comments

Comments
 (0)