Skip to content

Commit 29a6ac3

Browse files
committed
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
2 parents 10e283b + b7d3a4d commit 29a6ac3

File tree

111 files changed

+4578
-1169
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+4578
-1169
lines changed

src/Common/Commands.Common/MetricHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ private void LoadTelemetryClientContext(AzurePSQoSEvent qos, TelemetryContext cl
148148
clientContext.User.Id = qos.Uid;
149149
clientContext.User.AccountId = qos.Uid;
150150
clientContext.Session.Id = qos.SessionId;
151-
clientContext.Device.OperatingSystem = "Windows";
151+
clientContext.Device.OperatingSystem = Environment.OSVersion.ToString();
152152
}
153153

154154
private void PopulatePropertiesFromQos(AzurePSQoSEvent qos, IDictionary<string, string> eventProperties)
@@ -157,7 +157,7 @@ private void PopulatePropertiesFromQos(AzurePSQoSEvent qos, IDictionary<string,
157157
eventProperties.Add("ModuleName", qos.ModuleName);
158158
eventProperties.Add("ModuleVersion", qos.ModuleVersion);
159159
eventProperties.Add("HostVersion", qos.HostVersion);
160-
eventProperties.Add("OS", "Windows");
160+
eventProperties.Add("OS", Environment.OSVersion.ToString());
161161
eventProperties.Add("CommandParameters", qos.Parameters);
162162
eventProperties.Add("UserId", qos.Uid);
163163
eventProperties.Add("x-ms-client-request-id", qos.ClientRequestId);

src/Common/Commands.Common/ProfileClient.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,9 @@ private AzureSubscription MergeSubscriptionProperties(AzureSubscription subscrip
841841
Id = subscription1.Id,
842842
Name = subscription1.Name,
843843
Environment = subscription1.Environment,
844+
State = (subscription1.State != null &&
845+
subscription1.State.Equals(subscription2.State, StringComparison.OrdinalIgnoreCase)) ?
846+
subscription1.State: null,
844847
Account = subscription1.Account ?? subscription2.Account
845848
};
846849

src/ResourceManager/Automation/Commands.Automation.Test/Commands.Automation.Test.csproj

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,20 @@
6363
<Reference Include="Microsoft.Azure.Common.NetFramework">
6464
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
6565
</Reference>
66+
<Reference Include="Microsoft.Azure.Management.Automation">
67+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Automation.2.0.0\lib\net40\Microsoft.Azure.Management.Automation.dll</HintPath>
68+
</Reference>
6669
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
6770
<SpecificVersion>False</SpecificVersion>
6871
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.11-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
6972
</Reference>
73+
<Reference Include="Microsoft.Azure.Test.Framework, Version=1.0.5799.28345, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
74+
<SpecificVersion>False</SpecificVersion>
75+
<HintPath>..\..\..\packages\Microsoft.Azure.Test.Framework.1.0.5799.28345-prerelease\lib\net45\Microsoft.Azure.Test.Framework.dll</HintPath>
76+
</Reference>
7077
<Reference Include="Microsoft.Azure.Test.HttpRecorder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
78+
<SpecificVersion>False</SpecificVersion>
7179
<HintPath>..\..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.0.5799.28345-prerelease\lib\net45\Microsoft.Azure.Test.HttpRecorder.dll</HintPath>
72-
<Private>True</Private>
7380
</Reference>
7481
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory">
7582
<SpecificVersion>False</SpecificVersion>
@@ -112,7 +119,9 @@
112119
<HintPath>..\..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
113120
</Reference>
114121
<Reference Include="System" />
115-
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
122+
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
123+
<SpecificVersion>False</SpecificVersion>
124+
</Reference>
116125
<Reference Include="System.Net" />
117126
<Reference Include="System.Net.Http" />
118127
<Reference Include="System.Net.Http.Extensions, Version=2.2.28.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
@@ -135,6 +144,8 @@
135144
</ItemGroup>
136145
<ItemGroup>
137146
<Compile Include="Properties\AssemblyInfo.cs" />
147+
<Compile Include="ScenarioTests\AutomationScenarioTestsBase.cs" />
148+
<Compile Include="ScenarioTests\AutomationTests.cs" />
138149
<Compile Include="UnitTests\GetAzureAutomationCertificateTest.cs" />
139150
<Compile Include="UnitTests\GetAzureAutomationConnectionTest.cs" />
140151
<Compile Include="UnitTests\GetAzureAutomationCredentialTest.cs" />
@@ -195,6 +206,28 @@
195206
<ItemGroup>
196207
<None Include="MSSharedLibKey.snk" />
197208
<None Include="packages.config" />
209+
<None Include="ScenarioTests\AutomationTests.ps1">
210+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
211+
</None>
212+
<None Include="ScenarioTests\Resources\fastjob.ps1">
213+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
214+
</None>
215+
<None Include="ScenarioTests\Resources\Test-Workflow.ps1">
216+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
217+
</None>
218+
<None Include="ScenarioTests\Resources\Test-WorkflowV2.ps1">
219+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
220+
</None>
221+
<None Include="ScenarioTests\Resources\Test-WorkFlowWithVariousParameters.ps1">
222+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
223+
</None>
224+
<None Include="ScenarioTests\Resources\Use-WorkflowCheckpointSample.ps1">
225+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
226+
</None>
227+
<None Include="ScenarioTests\Resources\Write-DebugAndVerboseOutput.ps1">
228+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
229+
</None>
198230
</ItemGroup>
231+
<ItemGroup />
199232
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
200233
</Project>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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 Microsoft.Azure.Common.Authentication;
16+
using Microsoft.Azure.Management.Resources;
17+
using Microsoft.Azure.Subscriptions;
18+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
19+
using Microsoft.Azure.Test;
20+
using Microsoft.Azure.Management.Automation;
21+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
22+
23+
namespace Microsoft.Azure.Commands.Automation.Test
24+
{
25+
public abstract class AutomationScenarioTestsBase : RMTestBase
26+
{
27+
private EnvironmentSetupHelper helper;
28+
29+
protected AutomationScenarioTestsBase()
30+
{
31+
helper = new EnvironmentSetupHelper();
32+
}
33+
34+
protected void SetupManagementClients()
35+
{
36+
var automationManagementClient = GetAutomationManagementClient();
37+
38+
helper.SetupManagementClients(automationManagementClient);
39+
}
40+
41+
protected void RunPowerShellTest(params string[] scripts)
42+
{
43+
using (UndoContext context = UndoContext.Current)
44+
{
45+
context.Start(TestUtilities.GetCallingClass(2), TestUtilities.GetCurrentMethodName(2));
46+
47+
SetupManagementClients();
48+
49+
helper.SetupEnvironment(AzureModule.AzureResourceManager);
50+
51+
helper.SetupModules(AzureModule.AzureResourceManager,
52+
"ScenarioTests\\" + this.GetType().Name + ".ps1",
53+
helper.RMProfileModule,
54+
helper.GetRMModulePath(@"AzureRM.Automation.psd1"));
55+
56+
helper.RunPowerShellTest(scripts);
57+
}
58+
}
59+
60+
protected AutomationManagementClient GetAutomationManagementClient()
61+
{
62+
return TestBase.GetServiceClient<AutomationManagementClient>(new CSMTestEnvironmentFactory());
63+
}
64+
}
65+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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 Microsoft.WindowsAzure.Commands.ScenarioTest;
16+
using Xunit;
17+
18+
namespace Microsoft.Azure.Commands.Automation.Test
19+
{
20+
public class AutomationTests : AutomationScenarioTestsBase
21+
{
22+
[Fact(Skip = "Need x64 test framework.")]
23+
[Trait(Category.AcceptanceType, Category.CheckIn)]
24+
[Trait(Category.Service, Category.Automation)]
25+
public void TestAutomationStartAndStopRunbook()
26+
{
27+
RunPowerShellTest("Test-AutomationStartAndStopRunbook -runbookPath ScenarioTests\\Resources\\Test-Workflow.ps1");
28+
}
29+
30+
[Fact(Skip = "Need x64 test framework.")]
31+
[Trait(Category.AcceptanceType, Category.CheckIn)]
32+
[Trait(Category.Service, Category.Automation)]
33+
public void TestAutomationPublishAndEditRunbook()
34+
{
35+
RunPowerShellTest("Test-AutomationPublishAndEditRunbook -runbookPath ScenarioTests\\Resources\\Test-Workflow.ps1 -editRunbookPath Resources\\Automation\\Test-WorkflowV2.ps1");
36+
}
37+
38+
[Fact(Skip = "Need x64 test framework.")]
39+
[Trait(Category.AcceptanceType, Category.CheckIn)]
40+
[Trait(Category.Service, Category.Automation)]
41+
public void TestAutomationConfigureRunbook()
42+
{
43+
RunPowerShellTest("Test-AutomationConfigureRunbook -runbookPath ScenarioTests\\Resources\\Write-DebugAndVerboseOutput.ps1");
44+
}
45+
46+
[Fact]
47+
[Trait(Category.Service, Category.Automation)]
48+
[Trait(Category.RunType, Category.LiveOnly)]
49+
public void TestAutomationSuspendAndResumeJob()
50+
{
51+
RunPowerShellTest("Test-AutomationSuspendAndResumeJob -runbookPath ScenarioTests\\Resources\\Use-WorkflowCheckpointSample.ps1");
52+
}
53+
54+
[Fact]
55+
[Trait(Category.Service, Category.Automation)]
56+
[Trait(Category.RunType, Category.LiveOnly)]
57+
public void TestAutomationStartRunbookOnASchedule()
58+
{
59+
RunPowerShellTest("Test-AutomationStartRunbookOnASchedule -runbookPath ScenarioTests\\Resources\\Test-Workflow.ps1");
60+
}
61+
62+
[Fact(Skip = "Need x64 test framework.")]
63+
[Trait(Category.AcceptanceType, Category.CheckIn)]
64+
[Trait(Category.Service, Category.Automation)]
65+
public void TestAutomationStartUnpublishedRunbook()
66+
{
67+
RunPowerShellTest("Test-AutomationStartUnpublishedRunbook -runbookPath ScenarioTests\\Resources\\Test-WorkFlowWithVariousParameters.ps1");
68+
}
69+
70+
[Fact(Skip = "Need x64 test framework.")]
71+
[Trait(Category.AcceptanceType, Category.CheckIn)]
72+
[Trait(Category.Service, Category.Automation)]
73+
public void TestAutomationRunbookWithParameter()
74+
{
75+
RunPowerShellTest("Test-RunbookWithParameter -runbookPath ScenarioTests\\Resources\\fastJob.ps1 @{'nums'='[1,2,3,4,5,6,7]'} 28");
76+
}
77+
}
78+
}

0 commit comments

Comments
 (0)