Skip to content

Commit 814268c

Browse files
Add ServiceFabricTestRunner and replace TestController (#18231)
1 parent a62bbde commit 814268c

File tree

6 files changed

+91
-257
lines changed

6 files changed

+91
-257
lines changed

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

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,53 +13,46 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using Microsoft.Azure.Commands.ServiceFabric.Commands;
16-
using Microsoft.Azure.ServiceManagement.Common.Models;
1716
using Microsoft.WindowsAzure.Commands.ScenarioTest;
18-
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
1917
using Xunit;
2018
using Xunit.Abstractions;
2119

2220
namespace Microsoft.Azure.Commands.ServiceFabric.Test.ScenarioTests
2321
{
24-
public class ServiceFabricApplicationTests : RMTestBase
22+
public class ServiceFabricApplicationTests : ServiceFabricTestRunner
2523
{
26-
public XunitTracingInterceptor _logger;
27-
28-
public ServiceFabricApplicationTests(ITestOutputHelper output)
24+
public ServiceFabricApplicationTests(ITestOutputHelper output) : base(output)
2925
{
30-
_logger = new XunitTracingInterceptor(output);
31-
XunitTracingInterceptor.AddToContext(_logger);
32-
33-
ServiceFabricManagedCmdletBase.WriteVerboseIntervalInSec = 0;
26+
ServiceFabricCommonCmdletBase.WriteVerboseIntervalInSec = 0;
3427
ServiceFabricCmdletBase.RunningTest = true;
3528
}
3629

3730
[Fact]
3831
[Trait(Category.AcceptanceType, Category.CheckIn)]
3932
public void TestAppType()
4033
{
41-
TestController.NewInstance.RunPsTest(_logger, "Test-AppType");
34+
TestRunner.RunTestScript("Test-AppType");
4235
}
4336

4437
[Fact]
4538
[Trait(Category.AcceptanceType, Category.CheckIn)]
4639
public void TestAppTypeVersion()
4740
{
48-
TestController.NewInstance.RunPsTest(_logger, "Test-AppTypeVersion");
41+
TestRunner.RunTestScript("Test-AppTypeVersion");
4942
}
5043

5144
[Fact]
5245
[Trait(Category.AcceptanceType, Category.CheckIn)]
5346
public void TestApp()
5447
{
55-
TestController.NewInstance.RunPsTest(_logger, "Test-App");
48+
TestRunner.RunTestScript("Test-App");
5649
}
5750

5851
[Fact]
5952
[Trait(Category.AcceptanceType, Category.CheckIn)]
6053
public void TestService()
6154
{
62-
TestController.NewInstance.RunPsTest(_logger, "Test-Service");
55+
TestRunner.RunTestScript("Test-Service");
6356
}
6457
}
6558
}

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

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,16 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
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;
16+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
1917
using Xunit;
2018
using Xunit.Abstractions;
2119

2220
namespace Microsoft.Azure.Commands.ServiceFabric.Test.ScenarioTests
2321
{
24-
public class ServiceFabricManagedClustersApplicationTests : RMTestBase
22+
public class ServiceFabricManagedClustersApplicationTests : ServiceFabricTestRunner
2523
{
26-
public XunitTracingInterceptor _logger;
27-
28-
public ServiceFabricManagedClustersApplicationTests(ITestOutputHelper output)
24+
public ServiceFabricManagedClustersApplicationTests(ITestOutputHelper output) : base(output)
2925
{
30-
_logger = new XunitTracingInterceptor(output);
31-
XunitTracingInterceptor.AddToContext(_logger);
32-
3326
ServiceFabricCommonCmdletBase.WriteVerboseIntervalInSec = 0;
3427
ServiceFabricCmdletBase.RunningTest = true;
3528
}
@@ -38,28 +31,28 @@ public ServiceFabricManagedClustersApplicationTests(ITestOutputHelper output)
3831
[Trait(Category.AcceptanceType, Category.CheckIn)]
3932
public void TestManagedAppType()
4033
{
41-
TestController.NewInstance.RunPsTest(_logger, "Test-ManagedAppType");
34+
TestRunner.RunTestScript("Test-ManagedAppType");
4235
}
4336

4437
[Fact]
4538
[Trait(Category.AcceptanceType, Category.CheckIn)]
4639
public void TestManagedAppTypeVersion()
4740
{
48-
TestController.NewInstance.RunPsTest(_logger, "Test-ManagedAppTypeVersion");
41+
TestRunner.RunTestScript("Test-ManagedAppTypeVersion");
4942
}
5043

5144
[Fact]
5245
[Trait(Category.AcceptanceType, Category.CheckIn)]
5346
public void TestManagedApp()
5447
{
55-
TestController.NewInstance.RunPsTest(_logger, "Test-ManagedApp");
48+
TestRunner.RunTestScript("Test-ManagedApp");
5649
}
5750

5851
[Fact]
5952
[Trait(Category.AcceptanceType, Category.CheckIn)]
6053
public void TestManagedService()
6154
{
62-
TestController.NewInstance.RunPsTest(_logger, "Test-ManagedService");
55+
TestRunner.RunTestScript("Test-ManagedService");
6356
}
6457
}
6558
}

src/ServiceFabric/ServiceFabric.Test/ScenarioTests/ServiceFabricManagedClustersTests.cs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,16 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using Microsoft.Azure.Commands.ServiceFabric.Commands;
16-
using Microsoft.Azure.ServiceManagement.Common.Models;
1716
using Microsoft.WindowsAzure.Commands.ScenarioTest;
18-
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
1917
using Xunit;
2018
using Xunit.Abstractions;
2119

2220
namespace Microsoft.Azure.Commands.ServiceFabric.Test.ScenarioTests
2321
{
24-
public class ServiceFabricManagedClustersTests : RMTestBase
22+
public class ServiceFabricManagedClustersTests : ServiceFabricTestRunner
2523
{
26-
public XunitTracingInterceptor _logger;
27-
28-
public ServiceFabricManagedClustersTests(ITestOutputHelper output)
24+
public ServiceFabricManagedClustersTests(ITestOutputHelper output) : base(output)
2925
{
30-
_logger = new XunitTracingInterceptor(output);
31-
XunitTracingInterceptor.AddToContext(_logger);
32-
3326
ServiceFabricCommonCmdletBase.WriteVerboseIntervalInSec = 0;
3427
ServiceFabricCmdletBase.RunningTest = true;
3528
}
@@ -38,21 +31,21 @@ public ServiceFabricManagedClustersTests(ITestOutputHelper output)
3831
[Trait(Category.AcceptanceType, Category.CheckIn)]
3932
public void TestCreateBasicCluster()
4033
{
41-
TestController.NewInstance.RunPsTest(_logger, "Test-CreateBasicCluster");
34+
TestRunner.RunTestScript("Test-CreateBasicCluster");
4235
}
4336

4437
[Fact]
4538
[Trait(Category.AcceptanceType, Category.CheckIn)]
4639
public void TestNodeTypeOperations()
4740
{
48-
TestController.NewInstance.RunPsTest(_logger, "Test-NodeTypeOperations");
41+
TestRunner.RunTestScript("Test-NodeTypeOperations");
4942
}
5043

5144
[Fact]
5245
[Trait(Category.AcceptanceType, Category.CheckIn)]
5346
public void TestCertAndExtension()
5447
{
55-
TestController.NewInstance.RunPsTest(_logger, "Test-CertAndExtension");
48+
TestRunner.RunTestScript("Test-CertAndExtension");
5649
}
5750
}
5851
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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 System.Collections.Generic;
16+
using Microsoft.Azure.Commands.TestFx;
17+
using Xunit.Abstractions;
18+
19+
namespace Microsoft.Azure.Commands.ServiceFabric.Test.ScenarioTests
20+
{
21+
public class ServiceFabricTestRunner
22+
{
23+
protected readonly ITestRunner TestRunner;
24+
25+
protected ServiceFabricTestRunner(ITestOutputHelper output)
26+
{
27+
TestRunner = TestManager.CreateInstance(output)
28+
.WithNewPsScriptFilename($"{GetType().Name}.ps1")
29+
.WithProjectSubfolderForTests("ScenarioTests")
30+
.WithCommonPsScripts(new[]
31+
{
32+
@"Common.ps1",
33+
@"../AzureRM.Resources.ps1"
34+
})
35+
.WithNewRmModules(helper => new[]
36+
{
37+
helper.RMProfileModule,
38+
helper.GetRMModulePath("Az.ServiceFabric.psd1")
39+
})
40+
.WithNewRecordMatcherArguments(
41+
userAgentsToIgnore: new Dictionary<string, string>
42+
{
43+
{"Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01"}
44+
},
45+
resourceProviders: new Dictionary<string, string>
46+
{
47+
{"Microsoft.Resources", null},
48+
{"Microsoft.Features", null},
49+
{"Microsoft.Authorization", null},
50+
{"Microsoft.KeyVault", null}
51+
}
52+
)
53+
.Build();
54+
}
55+
}
56+
}

0 commit comments

Comments
 (0)