Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BlueprintTestRunner and replace TestController #18069

Merged
merged 1 commit into from
May 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,58 +1,61 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Azure.Commands.ScenarioTest;
// ----------------------------------------------------------------------------------
//
// 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 Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

namespace Microsoft.Azure.Commands.Blueprint.Test.ScenarioTests
{
public class BlueprintAssignmentTests
public class BlueprintAssignmentTests : BlueprintTestRunner
{
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;

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

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

[Fact(Skip = "Investigate auto-registration for RP")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewBlueprintAssignmentWithSystemAssignedIdentity()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-NewBlueprintAssignmentWithSystemAssignedIdentity");
TestRunner.RunTestScript("Test-NewBlueprintAssignmentWithSystemAssignedIdentity");
}

[Fact(Skip="Investigate auto-registration for RP")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNewBlueprintAssignment()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-NewBlueprintAssignment");
TestRunner.RunTestScript("Test-NewBlueprintAssignment");
}

[Fact(Skip = "Investigate auto-registration for RP")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSetBlueprintAssignment()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-SetBlueprintAssignment");
TestRunner.RunTestScript("Test-SetBlueprintAssignment");
}

[Fact(Skip = "Investigate auto-registration for RP")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRemoveBlueprintAssignment()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-RemoveBlueprintAssignment");
TestRunner.RunTestScript("Test-RemoveBlueprintAssignment");
}

}
Expand Down
52 changes: 52 additions & 0 deletions src/Blueprint/Blueprint.Test/ScenarioTests/BlueprintTestRunner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// ----------------------------------------------------------------------------------
//
// 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.Blueprint.Test.ScenarioTests
{
public class BlueprintTestRunner
{
protected readonly ITestRunner TestRunner;

protected BlueprintTestRunner(ITestOutputHelper output)
{
TestRunner = TestManager.CreateInstance(output)
.WithNewPsScriptFilename($"{GetType().Name}.ps1")
.WithProjectSubfolderForTests("ScenarioTests")
.WithNewRmModules(helper => new[]
{
helper.RMProfileModule,
helper.GetRMModulePath("Az.Blueprint.psd1"),
helper.GetRMModulePath("Az.Resources.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();
}
}
}
37 changes: 19 additions & 18 deletions src/Blueprint/Blueprint.Test/ScenarioTests/BlueprintTests.cs
Original file line number Diff line number Diff line change
@@ -1,46 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Azure.Commands.Blueprint.Test.ScenarioTests;
using Microsoft.Azure.Commands.ScenarioTest;
// ----------------------------------------------------------------------------------
//
// 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 Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

namespace Microsoft.Azure.Commands.Blueprint.Test.ScenarioTests
{
public class BlueprintTests
public class BlueprintTests : BlueprintTestRunner
{
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;


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

[Fact(Skip = "There is a framework issue where HttpClient calls are not recorded in session records causing tests to fail in playback mode")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetBlueprint()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GetBlueprint");
TestRunner.RunTestScript("Test-GetBlueprint");
}

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

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetBlueprintWithDefinitionLocationNameAndLatestPublished()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GetBlueprintWithDefinitionLocationNameAndLatestPublished");
TestRunner.RunTestScript("Test-GetBlueprintWithDefinitionLocationNameAndLatestPublished");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,56 +1,62 @@
namespace Microsoft.Azure.Commands.Blueprint.Test.ScenarioTests
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------

namespace Microsoft.Azure.Commands.Blueprint.Test.ScenarioTests
{
using Microsoft.Azure.Commands.ScenarioTest;
using Microsoft.Azure.ServiceManagement.Common.Models;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;
using Xunit.Abstractions;

public class ManagementGroupAssignmentTests
public class ManagementGroupAssignmentTests : BlueprintTestRunner
{
private XunitTracingInterceptor logger;

public ManagementGroupAssignmentTests(ITestOutputHelper output)
public ManagementGroupAssignmentTests(ITestOutputHelper output) : base(output)
{

this.logger = new XunitTracingInterceptor(output);
XunitTracingInterceptor.AddToContext(this.logger);
TestExecutionHelpers.SetUpSessionAndProfile();
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetAssignmentsInManagementGroup()
{
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetAssignmentsInManagementGroup");
TestRunner.RunTestScript("Test-GetAssignmentsInManagementGroup");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetSingleAssignmentInManagementGroup()
{
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetSingleAssignmentInManagementGroup");
TestRunner.RunTestScript("Test-GetSingleAssignmentInManagementGroup");
}

[Fact(Skip = "Investigate auto-registration for RP")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateAssignmentInManagementGroup()
{
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-CreateAssignmentInManagementGroup");
TestRunner.RunTestScript("Test-CreateAssignmentInManagementGroup");
}

[Fact(Skip = "Investigate auto-registration for RP")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestUpdateAssignmentInManagementGroup()
{
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-UpdateAssignmentInManagementGroup");
TestRunner.RunTestScript("Test-UpdateAssignmentInManagementGroup");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRemoveAssignmentInManagementGroup()
{
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-RemoveAssignmentInManagementGroup");
TestRunner.RunTestScript("Test-RemoveAssignmentInManagementGroup");
}
}
}
Loading