Skip to content

Commit 862f6ce

Browse files
Merge pull request AzureRT#16 from balukambala/dev
Scenario tests, DSC reportId/NodeId fixes
2 parents 363e815 + a0a4924 commit 862f6ce

15 files changed

+581
-7
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@
7171
<HintPath>..\..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.0.5785.18045-prerelease\lib\net45\Microsoft.Azure.Test.HttpRecorder.dll</HintPath>
7272
<Private>True</Private>
7373
</Reference>
74+
<Reference Include="Microsoft.Azure.Management.Automation">
75+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Automation.2.0.0\lib\net40\Microsoft.Azure.Management.Automation.dll</HintPath>
76+
</Reference>
77+
<Reference Include="Microsoft.Azure.Test.Framework">
78+
<HintPath>..\..\..\packages\Microsoft.Azure.Test.Framework.1.0.5785.18045-prerelease\lib\net45\Microsoft.Azure.Test.Framework.dll</HintPath>
79+
</Reference>
7480
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory">
7581
<SpecificVersion>False</SpecificVersion>
7682
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.18.206251556\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath>
@@ -135,6 +141,8 @@
135141
</ItemGroup>
136142
<ItemGroup>
137143
<Compile Include="Properties\AssemblyInfo.cs" />
144+
<Compile Include="ScenarioTests\AutomationScenarioTestsBase.cs" />
145+
<Compile Include="ScenarioTests\AutomationTests.cs" />
138146
<Compile Include="UnitTests\GetAzureAutomationCertificateTest.cs" />
139147
<Compile Include="UnitTests\GetAzureAutomationConnectionTest.cs" />
140148
<Compile Include="UnitTests\GetAzureAutomationCredentialTest.cs" />
@@ -195,7 +203,29 @@
195203
<ItemGroup>
196204
<None Include="MSSharedLibKey.snk" />
197205
<None Include="packages.config" />
206+
<None Include="ScenarioTests\AutomationTests.ps1">
207+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
208+
</None>
209+
<None Include="ScenarioTests\Resources\fastjob.ps1">
210+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
211+
</None>
212+
<None Include="ScenarioTests\Resources\Test-Workflow.ps1">
213+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
214+
</None>
215+
<None Include="ScenarioTests\Resources\Test-WorkflowV2.ps1">
216+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
217+
</None>
218+
<None Include="ScenarioTests\Resources\Test-WorkFlowWithVariousParameters.ps1">
219+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
220+
</None>
221+
<None Include="ScenarioTests\Resources\Use-WorkflowCheckpointSample.ps1">
222+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
223+
</None>
224+
<None Include="ScenarioTests\Resources\Write-DebugAndVerboseOutput.ps1">
225+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
226+
</None>
198227
</ItemGroup>
228+
<ItemGroup />
199229
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
200230
<Import Project="..\..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
201231
</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 = "Fix to make x86 compatible.")]
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 = "Fix to make x86 compatible.")]
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 = "Fix to make x86 compatible.")]
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 = "Fix to make x86 compatible.")]
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 = "Fix to make x86 compatible.")]
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)