Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d589b6d
Common test controller stuff.
vladimir-shcherbakov Aug 20, 2018
287eed9
app.config removed form project
vladimir-shcherbakov Aug 20, 2018
48d949b
shared lib key added
vladimir-shcherbakov Aug 20, 2018
f6500bf
preview added to version
vladimir-shcherbakov Aug 20, 2018
f2f85bf
Assembly names changed
vladimir-shcherbakov Aug 20, 2018
0706fee
Fix reference versions
MiYanni Aug 20, 2018
b557bf7
Update packages.config
MiYanni Aug 20, 2018
4b47a1c
Update TestFx.csproj
MiYanni Aug 20, 2018
4973728
Merge pull request #1 from vladimir-shcherbakov/MiYanni-patch-1
vladimir-shcherbakov Aug 20, 2018
9526a7e
Newsoft.JSON changed to 10.0.3
vladimir-shcherbakov Aug 21, 2018
029a699
Merge branch 'develop' into test-controller
MiYanni Aug 29, 2018
a65f8e5
Merge branch 'develop' into test-controller
MiYanni Aug 30, 2018
ebe94ce
Merge remote-tracking branch 'ustr/develop' into test-controller
vladimir-shcherbakov Sep 13, 2018
2618002
Import targets file for dependencies
vladimir-shcherbakov Sep 13, 2018
4a26f38
removed packages.config
vladimir-shcherbakov Sep 13, 2018
f9780a5
removed packages.config ref from csproj; Powershell replaced with Pow…
vladimir-shcherbakov Sep 13, 2018
b734d61
Fixes to TestFx project configuration.
MiYanni Sep 13, 2018
a666ddc
Merge branch 'test-controller' of https://github.com/Azure/azure-powe…
MiYanni Sep 13, 2018
b1490e0
Allowed sign job to sign the TestFx files. Added a fix so that Scenar…
MiYanni Sep 14, 2018
62d6407
Added signing exclusion for net452 test dlls.
MiYanni Sep 14, 2018
4d88b7e
Merge branch 'develop' into test-controller
markcowl Oct 8, 2018
b652e19
Merge branch 'develop' into test-controller
MiYanni Oct 12, 2018
aabc32b
Merge branch 'develop' into test-controller
vladimir-shcherbakov Oct 15, 2018
a1331a5
PR comments fix;
vladimir-shcherbakov Oct 15, 2018
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
6 changes: 6 additions & 0 deletions Azure.PowerShell.Common.Netcore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Compute.Test.Netcore", "src
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Strategies.Test.Netcore", "src\Strategies.Test\Strategies.Test.Netcore.csproj", "{6756A7F2-1141-4065-BA23-0C555D2A2BC3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestFx.Netcore", "src\TestFx\TestFx.Netcore.csproj", "{1E20E5A0-3353-4888-9B29-AE1A2C1C8DD0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Authentication.Test.Netcore", "src\Authentication.Test\Authentication.Test.Netcore.csproj", "{78D9B754-6A18-4125-80CC-63437BDE3244}"
EndProject
Global
Expand Down Expand Up @@ -127,6 +129,10 @@ Global
{6756A7F2-1141-4065-BA23-0C555D2A2BC3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6756A7F2-1141-4065-BA23-0C555D2A2BC3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6756A7F2-1141-4065-BA23-0C555D2A2BC3}.Release|Any CPU.Build.0 = Release|Any CPU
{1E20E5A0-3353-4888-9B29-AE1A2C1C8DD0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1E20E5A0-3353-4888-9B29-AE1A2C1C8DD0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1E20E5A0-3353-4888-9B29-AE1A2C1C8DD0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1E20E5A0-3353-4888-9B29-AE1A2C1C8DD0}.Release|Any CPU.Build.0 = Release|Any CPU
{78D9B754-6A18-4125-80CC-63437BDE3244}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{78D9B754-6A18-4125-80CC-63437BDE3244}.Debug|Any CPU.Build.0 = Debug|Any CPU
{78D9B754-6A18-4125-80CC-63437BDE3244}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
6 changes: 6 additions & 0 deletions Azure.PowerShell.Common.sln
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Strategies.Test", "src\Stra
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScenarioTest", "src\ScenarioTest\ScenarioTest.csproj", "{C1BDA476-A5CC-4394-914D-48B0EC31A710}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestFx", "src\TestFx\TestFx.csproj", "{8C625DE3-0067-454A-AF2C-EFD672EEB31A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -149,6 +151,10 @@ Global
{C1BDA476-A5CC-4394-914D-48B0EC31A710}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C1BDA476-A5CC-4394-914D-48B0EC31A710}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C1BDA476-A5CC-4394-914D-48B0EC31A710}.Release|Any CPU.Build.0 = Release|Any CPU
{8C625DE3-0067-454A-AF2C-EFD672EEB31A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8C625DE3-0067-454A-AF2C-EFD672EEB31A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8C625DE3-0067-454A-AF2C-EFD672EEB31A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8C625DE3-0067-454A-AF2C-EFD672EEB31A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
1 change: 1 addition & 0 deletions build/sign.proj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<ItemGroup>
<UnsignedFiles Include="$(OutputDir)net452\Microsoft.Azure.Commands*.dll" />
<UnsignedFiles Include="$(OutputDir)net452\Microsoft.WindowsAzure.Commands*.dll" />
<UnsignedFiles Include="$(OutputDir)net452\Microsoft.Azure.PowerShell*.dll" Exclude="$(OutputDir)net452\Microsoft.Azure.PowerShell*.Test.dll" />
</ItemGroup>
</Target>

Expand Down
4 changes: 2 additions & 2 deletions src/Aks/Aks.Netcore.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="$(ProjectDir)..\Dependencies.Netcore.targets" />
<PropertyGroup>

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>Microsoft.Azure.PowerShell.Aks</AssemblyName>
<RootNamespace>Microsoft.Azure.Commands.Common.Aks</RootNamespace>
Expand Down
6 changes: 3 additions & 3 deletions src/Dependencies.Test.targets
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
</PropertyGroup>

<Import Project="$(MSBuildThisFileDirectory)Dependencies.targets" />
<Import Project="$(PackagesDirectory)MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props" Condition="Exists('$(PackagesDirectory)MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props') and '$(ServiceManagementDependencies)' == 'true'" />
<Import Project="$(PackagesDirectory)xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('$(PackagesDirectory)xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props')" />
<Import Project="$(PackagesDirectory)xunit.core.2.1.0\build\portable-net45+win8+wp8+wpa81\xunit.core.props" Condition="Exists('$(PackagesDirectory)xunit.core.2.1.0\build\portable-net45+win8+wp8+wpa81\xunit.core.props')" />
<Import Project="$(PackagesDirectory)MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props" Condition="Exists('$(PackagesDirectory)MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props') and '$(ServiceManagementDependencies)' == 'true' and '$(UseTestImports)' != 'false'" />
<Import Project="$(PackagesDirectory)xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('$(PackagesDirectory)xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props') and '$(UseTestImports)' != 'false'" />
<Import Project="$(PackagesDirectory)xunit.core.2.1.0\build\portable-net45+win8+wp8+wpa81\xunit.core.props" Condition="Exists('$(PackagesDirectory)xunit.core.2.1.0\build\portable-net45+win8+wp8+wpa81\xunit.core.props') and '$(UseTestImports)' != 'false'" />

<ItemGroup>
<Reference Include="Moq, Version=4.2.1510.2205, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
Expand Down
55 changes: 25 additions & 30 deletions src/ScenarioTest.ResourceManager/EnvironmentSetupHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -585,9 +585,7 @@ public void SetupModulesFromCommon(AzureModule mode, params string[] modules)

public void SetupModules(params string[] modules)
{
this.modules = new List<string>();
this.modules.Add("Assert.ps1");
this.modules.Add("Common.ps1");
this.modules = new List<string> {"Assert.ps1", "Common.ps1"};
this.modules.AddRange(modules);
}

Expand All @@ -597,14 +595,18 @@ public virtual Collection<PSObject> RunPowerShellTest(params string[] scripts)
// permissive record matcher.
if (HttpMockServer.Matcher == null || HttpMockServer.Matcher.GetType() == typeof(SimpleRecordMatcher))
{
Dictionary<string, string> d = new Dictionary<string, string>();
d.Add("Microsoft.Resources", null);
d.Add("Microsoft.Features", null);
d.Add("Microsoft.Authorization", null);
d.Add("Microsoft.Compute", null);
d.Add("Microsoft.KeyVault", null);
var providersToIgnore = new Dictionary<string, string>();
providersToIgnore.Add("Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01");
var d = new Dictionary<string, string>
{
{"Microsoft.Resources", null},
{"Microsoft.Features", null},
{"Microsoft.Authorization", null},
{"Microsoft.Compute", null},
{"Microsoft.KeyVault", null}
};
var providersToIgnore = new Dictionary<string, string>
{
{"Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01"}
};
HttpMockServer.Matcher = new PermissiveRecordMatcherWithApiExclusion(true, d, providersToIgnore);
}

Expand All @@ -613,26 +615,18 @@ public virtual Collection<PSObject> RunPowerShellTest(params string[] scripts)
SetupPowerShellModules(powershell);

Collection<PSObject> output = null;
for (int i = 0; i < scripts.Length; ++i)
foreach (var script in scripts)
{
if (TracingInterceptor != null)
{
TracingInterceptor.Information(scripts[i]);
}
powershell.AddScript(scripts[i]);
TracingInterceptor?.Information(script);
powershell.AddScript(script);
}
try
{
output = powershell.Invoke();
if (powershell.Streams.Error.Count > 0)
{
throw new RuntimeException(
string.Format(
"Test failed due to a non-empty error stream. First error: {0}{1}",
PowerShellExtensions.FormatErrorRecord(powershell.Streams.Error[0]),
powershell.Streams.Error.Count > 0
? "Check the error stream in the test log for additional errors."
: ""));
$"Test failed due to a non-empty error stream. First error: {PowerShellExtensions.FormatErrorRecord(powershell.Streams.Error[0])}{(powershell.Streams.Error.Count > 0 ? "Check the error stream in the test log for additional errors." : "")}");
}

return output;
Expand Down Expand Up @@ -660,13 +654,14 @@ private void SetupPowerShellModules(System.Management.Automation.PowerShell powe
}
#endif
powershell.AddScript("$error.clear()");
powershell.AddScript(string.Format("Write-Debug \"current directory: {0}\"", System.AppDomain.CurrentDomain.BaseDirectory));
powershell.AddScript(string.Format("Write-Debug \"current executing assembly: {0}\"", Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)));
powershell.AddScript(string.Format("cd \"{0}\"", System.AppDomain.CurrentDomain.BaseDirectory));
powershell.AddScript($"Write-Debug \"current directory: {System.AppDomain.CurrentDomain.BaseDirectory}\"");
powershell.AddScript(
$"Write-Debug \"current executing assembly: {Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)}\"");
powershell.AddScript($"cd \"{System.AppDomain.CurrentDomain.BaseDirectory}\"");

foreach (string moduleName in modules)
foreach (var moduleName in modules)
{
powershell.AddScript(string.Format("Import-Module \"{0}\"", moduleName.AsAbsoluteLocation()));
powershell.AddScript($"Import-Module \"{moduleName.AsAbsoluteLocation()}\"");
if (moduleName.EndsWith(".psd1"))
{
#if NETSTANDARD
Expand All @@ -682,8 +677,8 @@ private void SetupPowerShellModules(System.Management.Automation.PowerShell powe

powershell.AddScript("Disable-AzureRmDataCollection -ErrorAction Ignore");
powershell.AddScript(
string.Format("set-location \"{0}\"", System.AppDomain.CurrentDomain.BaseDirectory));
powershell.AddScript(string.Format(@"$TestOutputRoot='{0}'", System.AppDomain.CurrentDomain.BaseDirectory));
$"set-location \"{System.AppDomain.CurrentDomain.BaseDirectory}\"");
powershell.AddScript($@"$TestOutputRoot='{System.AppDomain.CurrentDomain.BaseDirectory}'");
powershell.AddScript("$VerbosePreference='Continue'");
powershell.AddScript("$DebugPreference='Continue'");
powershell.AddScript("$ErrorActionPreference='Stop'");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<UseTestImports>false</UseTestImports>
</PropertyGroup>
<Import Project="$(ProjectDir)..\Dependencies.Test.targets" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand Down
1 change: 1 addition & 0 deletions src/ScenarioTest/ScenarioTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ServiceManagementDependencies>true</ServiceManagementDependencies>
<UseTestImports>false</UseTestImports>
</PropertyGroup>
<Import Project="$(ProjectDir)..\Dependencies.Test.targets" />
<PropertyGroup>
Expand Down
21 changes: 21 additions & 0 deletions src/TestFx/ITestRunner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// ----------------------------------------------------------------------------------
//
// 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.TestFx
{
public interface ITestRunner
{
void RunTestScript(params string[] scripts);
}
}
32 changes: 32 additions & 0 deletions src/TestFx/ITestRunnerFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// ----------------------------------------------------------------------------------
//
// 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 System.Collections.Generic;
using Microsoft.WindowsAzure.Commands.ScenarioTest;

namespace Microsoft.Azure.Commands.TestFx
{
public interface ITestRunnerFactory
{
ITestRunner Build();
ITestRunnerFactory WithProjectSubfolderForTests(string folderName);
ITestRunnerFactory WithCommonPsScripts(string[] psScriptList);
ITestRunnerFactory WithNewPsScriptFilename(string psScriptName);
ITestRunnerFactory WithExtraRmModules(Func<EnvironmentSetupHelper, string[]> buildModuleList);
ITestRunnerFactory WithNewRmModules(Func<EnvironmentSetupHelper, string[]> buildModuleList);
ITestRunnerFactory WithExtraUserAgentsToIgnore(Dictionary<string, string> userAgentsToIgnore);
ITestRunnerFactory WithRecordMatcher(RecordMatcherDelegate recordMatcher);
}
}
32 changes: 32 additions & 0 deletions src/TestFx/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System.Reflection;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Microsoft Azure PowerShell TestFx")]
[assembly: AssemblyDescription("Microsoft Azure PowerShell TestFx library. Only for use with the Azure PowerShell runtime. Not intended for general development use.")]
[assembly: AssemblyProduct("Microsoft Azure PowerShell")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyCopyright("Copyright © Microsoft Corporation")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("8c625de3-0067-454a-af2c-efd672eeb31a")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Loading