Skip to content

Commit

Permalink
Add CdnTestRunner and replace TestController (#18066)
Browse files Browse the repository at this point in the history
* Add CdnTestRunner and replace TestController

* Add CdnTestRunner and replace TestController
  • Loading branch information
CaptainFanZzz authored May 9, 2022
1 parent 45cc564 commit f6b28b8
Show file tree
Hide file tree
Showing 18 changed files with 144 additions and 290 deletions.
12 changes: 4 additions & 8 deletions src/Cdn/Cdn.Test/ScenarioTests/AfdCustomDomainTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,24 @@

namespace Microsoft.Azure.Commands.Cdn.Test.ScenarioTests.ScenarioTest
{
public class AfdCustomDomainTests
public class AfdCustomDomainTests : CdnTestRunner
{
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;

public AfdCustomDomainTests(Xunit.Abstractions.ITestOutputHelper output)
public AfdCustomDomainTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
}

[Fact(Skip = "Test is flaky due to creation of custom domain issue which prolongs response time. Will enable once RP issue is resolved.")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateAfdCustomDomain()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-CreateAfdCustomDomain");
TestRunner.RunTestScript("Test-CreateAfdCustomDomain");
}

[Fact(Skip = "Test is flaky due to RP issue which prolongs response time. Will enable once RP issue is resolved.")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetAfdCustomDomain()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GetAfdCustomDomain");
TestRunner.RunTestScript("Test-GetAfdCustomDomain");
}
}
}
16 changes: 6 additions & 10 deletions src/Cdn/Cdn.Test/ScenarioTests/AfdEndpointTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,38 @@

namespace Microsoft.Azure.Commands.Cdn.Test.ScenarioTests.ScenarioTest
{
public class AfdEndpointTests
public class AfdEndpointTests : CdnTestRunner
{
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;

public AfdEndpointTests(Xunit.Abstractions.ITestOutputHelper output)
public AfdEndpointTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateAfdEndpoint()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-CreateAfdEndpoint");
TestRunner.RunTestScript("Test-CreateAfdEndpoint");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetAfdEndpoint()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GetAfdEndpoint");
TestRunner.RunTestScript("Test-GetAfdEndpoint");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRemoveAfdEndpoint()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-RemoveAfdEndpoint");
TestRunner.RunTestScript("Test-RemoveAfdEndpoint");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSetAfdEndpoint()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-SetAfdEndpoint");
TestRunner.RunTestScript("Test-SetAfdEndpoint");
}
}
}
16 changes: 6 additions & 10 deletions src/Cdn/Cdn.Test/ScenarioTests/AfdOriginGroupTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,38 @@

namespace Microsoft.Azure.Commands.Cdn.Test.ScenarioTests.ScenarioTest
{
public class AfdOriginGroupTests
public class AfdOriginGroupTests : CdnTestRunner
{
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;

public AfdOriginGroupTests(Xunit.Abstractions.ITestOutputHelper output)
public AfdOriginGroupTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateAfdOriginGroup()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-CreateAfdOriginGroup");
TestRunner.RunTestScript("Test-CreateAfdOriginGroup");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetAfdOriginGroup()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GetAfdOriginGroup");
TestRunner.RunTestScript("Test-GetAfdOriginGroup");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSetAfdOriginGroup()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-SetAfdOriginGroup");
TestRunner.RunTestScript("Test-SetAfdOriginGroup");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRemoveAfdOriginGroup()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-RemoveAfdOriginGroup");
TestRunner.RunTestScript("Test-RemoveAfdOriginGroup");
}
}
}
14 changes: 5 additions & 9 deletions src/Cdn/Cdn.Test/ScenarioTests/AfdOriginTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,31 @@

namespace Microsoft.Azure.Commands.Cdn.Test.ScenarioTests.ScenarioTest
{
public class AfdOriginTests
public class AfdOriginTests : CdnTestRunner
{
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;

public AfdOriginTests(Xunit.Abstractions.ITestOutputHelper output)
public AfdOriginTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateAfdOrigin()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-CreateAfdOrigin");
TestRunner.RunTestScript("Test-CreateAfdOrigin");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetAfdOrigin()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GetAfdOrigin");
TestRunner.RunTestScript("Test-GetAfdOrigin");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSetAfdOrigin()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-SetAfdOrigin");
TestRunner.RunTestScript("Test-SetAfdOrigin");
}
}
}
16 changes: 6 additions & 10 deletions src/Cdn/Cdn.Test/ScenarioTests/AfdProfileTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,38 @@

namespace Microsoft.Azure.Commands.Cdn.Test.ScenarioTests.ScenarioTest
{
public class AfdProfileTests
public class AfdProfileTests : CdnTestRunner
{
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;

public AfdProfileTests(Xunit.Abstractions.ITestOutputHelper output)
public AfdProfileTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateStandardAfdProfile()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-CreateStandardAfdProfile");
TestRunner.RunTestScript("Test-CreateStandardAfdProfile");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreatePremiumAfdProfile()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-CreatePremiumAfdProfile");
TestRunner.RunTestScript("Test-CreatePremiumAfdProfile");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetStandardAfdProfile()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GetStandardAfdProfile");
TestRunner.RunTestScript("Test-GetStandardAfdProfile");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRemovePremiumAfdProfile()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-RemovePremiumAfdProfile");
TestRunner.RunTestScript("Test-RemovePremiumAfdProfile");
}
}
}
12 changes: 4 additions & 8 deletions src/Cdn/Cdn.Test/ScenarioTests/AfdRouteTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,24 @@

namespace Microsoft.Azure.Commands.Cdn.Test.ScenarioTests.ScenarioTest
{
public class AfdRouteTests
public class AfdRouteTests : CdnTestRunner
{
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;

public AfdRouteTests(Xunit.Abstractions.ITestOutputHelper output)
public AfdRouteTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
}

[Fact(Skip = "Test is flaky due to creation of custom domain issue which prolongs response time. Will enable once RP issue is resolved.")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateAfdRoute()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-CreateAfdRoute");
TestRunner.RunTestScript("Test-CreateAfdRoute");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetAfdRoute()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GetAfdRoute");
TestRunner.RunTestScript("Test-GetAfdRoute");
}
}
}
12 changes: 4 additions & 8 deletions src/Cdn/Cdn.Test/ScenarioTests/AfdRuleSetTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,24 @@

namespace Microsoft.Azure.Commands.Cdn.Test.ScenarioTests.ScenarioTest
{
public class AfdRuleSetTests
public class AfdRuleSetTests : CdnTestRunner
{
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;

public AfdRuleSetTests(Xunit.Abstractions.ITestOutputHelper output)
public AfdRuleSetTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateAfdRuleSet()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-CreateAfdRuleSet");
TestRunner.RunTestScript("Test-CreateAfdRuleSet");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRemoveAfdRuleSet()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-RemoveAfdRuleSet");
TestRunner.RunTestScript("Test-RemoveAfdRuleSet");
}
}
}
10 changes: 3 additions & 7 deletions src/Cdn/Cdn.Test/ScenarioTests/AfdRuleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,17 @@

namespace Microsoft.Azure.Commands.Cdn.Test.ScenarioTests.ScenarioTest
{
public class AfdRuleTests
public class AfdRuleTests : CdnTestRunner
{
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;

public AfdRuleTests(Xunit.Abstractions.ITestOutputHelper output)
public AfdRuleTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateAfdRule()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-CreateAfdRule");
TestRunner.RunTestScript("Test-CreateAfdRule");
}
}
}
10 changes: 3 additions & 7 deletions src/Cdn/Cdn.Test/ScenarioTests/AfdSecurityPolicyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,17 @@

namespace Microsoft.Azure.Commands.Cdn.Test.ScenarioTests.ScenarioTest
{
public class AfdSecurityPolicyTests
public class AfdSecurityPolicyTests : CdnTestRunner
{
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;

public AfdSecurityPolicyTests(Xunit.Abstractions.ITestOutputHelper output)
public AfdSecurityPolicyTests(Xunit.Abstractions.ITestOutputHelper output) : base(output)
{
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetAfdSecurityPolicy()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GetAfdSecurityPolicy");
TestRunner.RunTestScript("Test-GetAfdSecurityPolicy");
}
}
}
56 changes: 56 additions & 0 deletions src/Cdn/Cdn.Test/ScenarioTests/CdnTestRunner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using System.Collections.Generic;
using Microsoft.Azure.Commands.TestFx;
using Xunit.Abstractions;

namespace Microsoft.Azure.Commands.Cdn.Test.ScenarioTests
{
public class CdnTestRunner
{
protected readonly ITestRunner TestRunner;

protected CdnTestRunner(ITestOutputHelper output)
{
TestRunner = TestManager.CreateInstance(output)
.WithNewPsScriptFilename($"{GetType().Name}.ps1")
.WithProjectSubfolderForTests("ScenarioTests")
.WithCommonPsScripts(new[]
{
@"Common.ps1",
@"../AzureRM.Resources.ps1",
})
.WithNewRmModules(helper => new[]
{
helper.RMProfileModule,
helper.GetRMModulePath("Az.Cdn.psd1")
})
.WithNewRecordMatcherArguments(
userAgentsToIgnore: new Dictionary<string, string>
{
{"Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01"},
},
resourceProviders: new Dictionary<string, string>
{
{"Microsoft.Resources", null},
{"Microsoft.Features", null},
{"Microsoft.Authorization", null},
{"Microsoft.Compute", null}
}
)
.Build();
}
}
}
Loading

0 comments on commit f6b28b8

Please sign in to comment.