-
Notifications
You must be signed in to change notification settings - Fork 4k
Add AksTestRunner and replace TestController #17962
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// | ||
// 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; | ||
using Microsoft.Azure.Commands.Common.Authentication; | ||
using Microsoft.Rest.ClientRuntime.Azure.TestFramework; | ||
using System.Collections.Generic; | ||
using Microsoft.Azure.Test.HttpRecorder; | ||
using Microsoft.Azure.Commands.Common.Authentication.Models; | ||
using System.Reflection; | ||
using System.IO; | ||
using Microsoft.Azure.Management.Internal.Resources; | ||
using Microsoft.Azure.Management.ContainerService; | ||
using Microsoft.Azure.Management.Authorization.Version2015_07_01; | ||
using Microsoft.Azure.Commands.Common.MSGraph.Version1_0; | ||
using Microsoft.Azure.Commands.TestFx; | ||
using Xunit.Abstractions; | ||
|
||
namespace Commands.Aks.Test.ScenarioTests | ||
{ | ||
public class AksTestRunner | ||
{ | ||
protected readonly ITestRunner TestRunner; | ||
|
||
protected AksTestRunner(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.Aks.psd1") | ||
}) | ||
.WithNewRecordMatcherArguments ( | ||
userAgentsToIgnore: new Dictionary<string, string> | ||
{ | ||
{"Microsoft.Azure.Management.Resources.ResourceManagementClient", "2017-05-10"}, | ||
{"Microsoft.Azure.Management.ResourceManager.ResourceManagementClient", "2017-05-10"} | ||
}, | ||
resourceProviders: new Dictionary<string, string> | ||
{ | ||
{"Microsoft.Resources", null}, | ||
{"Microsoft.Features", null}, | ||
{"Microsoft.Authorization", null} | ||
} | ||
).WithMockContextAction(() => | ||
{ | ||
if (HttpMockServer.GetCurrentMode() == HttpRecorderMode.Playback) | ||
{ | ||
AzureSession.Instance.DataStore = new MemoryDataStore(); | ||
var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); | ||
var dir = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath); | ||
var subscription = HttpMockServer.Variables["SubscriptionId"]; | ||
AzureSession.Instance.DataStore.WriteFile(Path.Combine(home, ".ssh", "id_rsa.pub"), File.ReadAllText(dir + "/Fixtures/id_rsa.pub")); | ||
var jsonOutput = @"{""" + subscription + @""":{ ""service_principal"":""foo"",""client_secret"":""bar""}}"; | ||
AzureSession.Instance.DataStore.WriteFile(Path.Combine(home, ".azure", "acsServicePrincipal.json"), jsonOutput); | ||
} | ||
else if (HttpMockServer.GetCurrentMode() == HttpRecorderMode.Record) | ||
{ | ||
AzureSession.Instance.DataStore = new MemoryDataStore(); | ||
var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); | ||
var dir = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath); | ||
var subscription = HttpMockServer.Variables["SubscriptionId"]; | ||
var currentEnvironment = TestEnvironmentFactory.GetTestEnvironment(); | ||
string spn = null; | ||
string spnSecret = null; | ||
if (currentEnvironment.ConnectionString.KeyValuePairs.ContainsKey("ServicePrincipal")) | ||
{ | ||
spn = currentEnvironment.ConnectionString.KeyValuePairs["ServicePrincipal"]; | ||
} | ||
if (currentEnvironment.ConnectionString.KeyValuePairs.ContainsKey("ServicePrincipalSecret")) | ||
{ | ||
spnSecret = currentEnvironment.ConnectionString.KeyValuePairs["ServicePrincipalSecret"]; | ||
} | ||
AzureSession.Instance.DataStore.WriteFile(Path.Combine(home, ".ssh", "id_rsa.pub"), File.ReadAllText(dir + "/Fixtures/id_rsa.pub")); | ||
var jsonOutput = @"{""" + subscription + @""":{ ""service_principal"":""" + spn + @""",""client_secret"":"""+ spnSecret + @"""}}"; | ||
AzureSession.Instance.DataStore.WriteFile(Path.Combine(home, ".azure", "acsServicePrincipal.json"), jsonOutput); | ||
} | ||
} | ||
) | ||
.Build(); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,76 @@ | ||
using Microsoft.Azure.Commands.ScenarioTest; | ||
using Microsoft.Azure.ServiceManagement.Common.Models; | ||
using Microsoft.WindowsAzure.Commands.ScenarioTest; | ||
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Commands.Aks.Test.ScenarioTests | ||
{ | ||
public class KubernetesTests : RMTestBase | ||
public class KubernetesTests : AksTestRunner | ||
{ | ||
XunitTracingInterceptor _logger; | ||
public KubernetesTests(ITestOutputHelper output) | ||
public KubernetesTests(ITestOutputHelper output) : base(output) | ||
{ | ||
_logger = new XunitTracingInterceptor(output); | ||
XunitTracingInterceptor.AddToContext(_logger); | ||
TestExecutionHelpers.SetUpSessionAndProfile(); | ||
} | ||
|
||
[Fact] | ||
[Trait(Category.AcceptanceType, Category.CheckIn)] | ||
public void TestSimpleAzureKubernetes() | ||
{ | ||
TestController.NewInstance.RunPowerShellTest(_logger, "Test-NewAzAksSimple"); | ||
TestRunner.RunTestScript("Test-NewAzAksSimple"); | ||
} | ||
|
||
[Fact] | ||
[Trait(Category.AcceptanceType, Category.CheckIn)] | ||
public void TestAzureKubernetes() | ||
{ | ||
TestController.NewInstance.RunPowerShellTest(_logger, "Test-NewAzAks"); | ||
TestRunner.RunTestScript("Test-NewAzAks"); | ||
} | ||
|
||
[Fact] | ||
[Trait(Category.AcceptanceType, Category.CheckIn)] | ||
public void TestNewAzureKubernetesByServicePrincipal() | ||
{ | ||
TestController.NewInstance.RunPowerShellTest(_logger, "Test-NewAzAksByServicePrincipal"); | ||
TestRunner.RunTestScript("Test-NewAzAksByServicePrincipal"); | ||
} | ||
|
||
[Fact] | ||
[Trait(Category.AcceptanceType, Category.CheckIn)] | ||
public void TestAzureKubernetesAddons() | ||
{ | ||
TestController.NewInstance.RunPowerShellTest(_logger, "Test-NewAzAksAddons"); | ||
TestRunner.RunTestScript("Test-NewAzAksAddons"); | ||
} | ||
|
||
[Fact(Skip = "Please make sure you have graph directory.read permission which is required for grant acrpull permission.")] | ||
[Trait(Category.AcceptanceType, Category.CheckIn)] | ||
public void TestNewAzAksWithAcr() | ||
{ | ||
TestController.NewInstance.RunPowerShellTest(_logger, "Test-NewAzAksWithAcr"); | ||
TestRunner.RunTestScript("Test-NewAzAksWithAcr"); | ||
} | ||
|
||
[Fact(Skip = "Updating service principal profile is not allowed on MSI cluster.")] | ||
[Trait(Category.AcceptanceType, Category.CheckIn)] | ||
public void TestResetAzureKubernetesServicePrincipal() | ||
{ | ||
TestController.NewInstance.RunPowerShellTest(_logger, "Test-ResetAzureKubernetesServicePrincipal"); | ||
TestRunner.RunTestScript("Test-ResetAzureKubernetesServicePrincipal"); | ||
} | ||
|
||
[Fact] | ||
[Trait(Category.AcceptanceType, Category.CheckIn)] | ||
public void TestUpgradeKubernetesVersion() | ||
{ | ||
TestController.NewInstance.RunPowerShellTest(_logger, "Test-UpgradeKubernetesVersion"); | ||
TestRunner.RunTestScript("Test-UpgradeKubernetesVersion"); | ||
} | ||
|
||
[Fact] | ||
[Trait(Category.AcceptanceType, Category.CheckIn)] | ||
public void TestLoadBalancer() | ||
{ | ||
TestController.NewInstance.RunPowerShellTest(_logger, "Test-LoadBalancer"); | ||
TestRunner.RunTestScript("Test-LoadBalancer"); | ||
} | ||
|
||
[Fact] | ||
[Trait(Category.AcceptanceType, Category.CheckIn)] | ||
public void TestApiServiceAccess() | ||
{ | ||
TestController.NewInstance.RunPowerShellTest(_logger, "Test-ApiServiceAccess"); | ||
TestRunner.RunTestScript("Test-ApiServiceAccess"); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,20 @@ | ||
using Microsoft.Azure.Commands.ScenarioTest; | ||
using Microsoft.Azure.ServiceManagement.Common.Models; | ||
using Microsoft.WindowsAzure.Commands.ScenarioTest; | ||
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common; | ||
using Microsoft.WindowsAzure.Commands.ScenarioTest; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Commands.Aks.Test.ScenarioTests | ||
{ | ||
public class NodePoolTests : RMTestBase | ||
public class NodePoolTests : AksTestRunner | ||
{ | ||
XunitTracingInterceptor _logger; | ||
public NodePoolTests(ITestOutputHelper output) | ||
public NodePoolTests(ITestOutputHelper output) : base(output) | ||
{ | ||
_logger = new XunitTracingInterceptor(output); | ||
XunitTracingInterceptor.AddToContext(_logger); | ||
TestExecutionHelpers.SetUpSessionAndProfile(); | ||
} | ||
|
||
[Fact] | ||
[Trait(Category.AcceptanceType, Category.CheckIn)] | ||
public void TestAksNodePool() | ||
{ | ||
TestController.NewInstance.RunPowerShellTest(_logger, "Test-NewNodePool"); | ||
TestRunner.RunTestScript("Test-NewNodePool"); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.