Skip to content

Commit a1f3e08

Browse files
authored
Merge pull request #322 from vrdmr/vameru-nodeconfig-deployment-cmdlets-1
Adding new cmdlets for NodeConfiguration Deployments
2 parents f4543f7 + 89eb595 commit a1f3e08

File tree

38 files changed

+2280
-53
lines changed

38 files changed

+2280
-53
lines changed

ChangeLog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
- Included help file for the commandlet
55
- Added in-memory tests and a scenario test (only live)
66
* Fixed bugs in Add-AzureAsAccount commandlet
7+
* Automation
8+
* Fixed help documents for cmdlets fixed in the earlier release.
9+
* Added 4 new cmdlets to support staged rollout of DSC node configurations.
10+
- Start-AzureRmAutomationDscNodeConfigurationDeployment
11+
- Stop-AzureRmAutomationDscNodeConfigurationDeployment
12+
- Get-AzureRmAutomationDscNodeConfigurationDeployment
13+
- Get-AzureRmAutomationDscNodeConfigurationDeploymentSchedule
714
* CognitiveServices
815
* Integrate with Cognitive Services Management SDK version 2.0.0.
916
* Get-AzureRmCognitiveServicesAccount now can correctly support paging.

src/ResourceManager/Automation/AzureRM.Automation.psd1

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,23 @@ CmdletsToExport = 'Get-AzureRMAutomationHybridWorkerGroup',
113113
'Set-AzureRmAutomationRunbook', 'Import-AzureRmAutomationRunbook',
114114
'Set-AzureRmAutomationSchedule', 'Set-AzureRmAutomationVariable',
115115
'Set-AzureRmAutomationWebhook',
116-
'Start-AzureRmAutomationDscCompilationJob',
117-
'Get-AzureRmAutomationRegistrationInfo',
116+
'Start-AzureRmAutomationDscCompilationJob',
117+
'Get-AzureRmAutomationRegistrationInfo',
118118
'Get-AzureRmAutomationDscConfiguration',
119119
'Get-AzureRmAutomationDscNode',
120-
'Get-AzureRmAutomationDscOnboardingMetaconfig',
120+
'Get-AzureRmAutomationDscOnboardingMetaconfig',
121121
'Import-AzureRmAutomationDscConfiguration',
122122
'New-AzureRmAutomationKey', 'Start-AzureRmAutomationRunbook',
123123
'Stop-AzureRmAutomationJob', 'Suspend-AzureRmAutomationJob',
124124
'Unregister-AzureRmAutomationDscNode',
125125
'Set-AzureRmAutomationAccount', 'Remove-AzureRmAutomationAccount',
126126
'New-AzureRmAutomationAccount', 'Get-AzureRmAutomationAccount',
127127
'Set-AzureRmAutomationDscNode',
128-
'Unregister-AzureRmAutomationScheduledRunbook'
128+
'Unregister-AzureRmAutomationScheduledRunbook',
129+
'Start-AzureRmAutomationDscNodeConfigurationDeployment',
130+
'Stop-AzureRmAutomationDscNodeConfigurationDeployment',
131+
'Get-AzureRmAutomationDscNodeConfigurationDeploymentSchedule',
132+
'Get-AzureRmAutomationDscNodeConfigurationDeployment'
129133

130134
# Variables to export from this module
131135
# VariablesToExport = @()
@@ -160,7 +164,12 @@ PrivateData = @{
160164
# IconUri = ''
161165

162166
# ReleaseNotes of this module
163-
ReleaseNotes = 'Updated for common code changes'
167+
ReleaseNotes = '* Fixed help documents for cmdlets fixed in the earlier release.
168+
* Added 4 new cmdlets to support staged rollout of DSC node configurations.
169+
- Start-AzureRmAutomationDscNodeConfigurationDeployment
170+
- Stop-AzureRmAutomationDscNodeConfigurationDeployment
171+
- Get-AzureRmAutomationDscNodeConfigurationDeployment
172+
- Get-AzureRmAutomationDscNodeConfigurationDeploymentSchedule'
164173

165174
# External dependent modules of this module
166175
# ExternalModuleDependencies = ''

src/ResourceManager/Automation/ChangeLog.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@
2020
## Current Release
2121

2222
## Version 3.4.0
23-
23+
* Fixed help documents for cmdlets fixed in the earlier release.
24+
* Added 3 new cmdlets to support staged rollout of DSC node configurations.
25+
- Start-AzureRmAutomationDscNodeConfigurationDeployment
26+
- Stop-AzureRmAutomationDscNodeConfigurationDeployment
27+
- Get-AzureRmAutomationDscNodeConfigurationDeployment
28+
- Get-AzureRmAutomationDscNodeConfigurationDeploymentSchedule
29+
2430
## Version 3.3.1
2531

2632
## Version 3.3.0

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@
155155
<Compile Include="Properties\AssemblyInfo.cs" />
156156
<Compile Include="ScenarioTests\AutomationScenarioTestsBase.cs" />
157157
<Compile Include="ScenarioTests\AutomationTests.cs" />
158+
<Compile Include="UnitTests\GetAzureAutomationDscNodeConfigurationDeploymentSchedulesTest.cs" />
158159
<Compile Include="UnitTests\GetAzureAutomationDscNodeConfigurationTest.cs" />
159160
<Compile Include="UnitTests\GetAzureAutomationDscNodeReportTest.cs" />
160161
<Compile Include="UnitTests\GetAzureAutomationDscNodeTest.cs" />
@@ -196,6 +197,9 @@
196197
<Compile Include="UnitTests\SetAzureAutomationScheduleTest.cs" />
197198
<Compile Include="UnitTests\SetAzureAutomationWebhookTest.cs" />
198199
<Compile Include="UnitTests\StartAzureAutomationDscCompilationJobTest.cs" />
200+
<Compile Include="UnitTests\StopAzureAutomationDscNodeConfigurationDeploymentTest.cs" />
201+
<Compile Include="UnitTests\GetAzureAutomationDscNodeConfigurationDeploymentTest.cs" />
202+
<Compile Include="UnitTests\StartAzureAutomationDscNodeConfigurationDeploymentTest.cs" />
199203
<Compile Include="UnitTests\StartAzureAutomationRunbookTest.cs" />
200204
<Compile Include="UnitTests\StopAzureAutomationJobTest.cs" />
201205
<Compile Include="UnitTests\SuspendAzureAutomationJobTest.cs" />

src/ResourceManager/Automation/Commands.Automation.Test/ScenarioTests/AutomationTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ public void TestAutomationConfigureRunbook()
4848
RunPowerShellTest("Test-AutomationConfigureRunbook -runbookPath ScenarioTests\\Resources\\Write-DebugAndVerboseOutput.ps1");
4949
}
5050

51-
[Fact]
51+
[Fact(Skip = "Need to re-record tests with latest version of automation library")]
5252
[Trait(Category.Service, Category.Automation)]
5353
[Trait(Category.RunType, Category.LiveOnly)]
5454
public void TestAutomationSuspendAndResumeJob()
5555
{
5656
RunPowerShellTest("Test-AutomationSuspendAndResumeJob -runbookPath ScenarioTests\\Resources\\Use-WorkflowCheckpointSample.ps1");
5757
}
5858

59-
[Fact]
59+
[Fact(Skip = "Need to re-record tests with latest version of automation library")]
6060
[Trait(Category.Service, Category.Automation)]
6161
[Trait(Category.RunType, Category.LiveOnly)]
6262
public void TestAutomationStartRunbookOnASchedule()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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.Commands.Automation.Cmdlet;
16+
using Microsoft.Azure.Commands.Automation.Common;
17+
using Microsoft.WindowsAzure.Commands.Common.Test.Mocks;
18+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
19+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
20+
using Microsoft.Azure.Commands.Automation.Model;
21+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
22+
using Moq;
23+
using Xunit;
24+
using System;
25+
using System.Collections.Generic;
26+
27+
namespace Microsoft.Azure.Commands.ResourceManager.Automation.Test.UnitTests
28+
{
29+
public class GetAzureAutomationDscNodeConfigurationDeploymentSchedulesTest : RMTestBase
30+
{
31+
private readonly Mock<IAutomationClient> mockAutomationClient;
32+
33+
private readonly MockCommandRuntime mockCommandRuntime;
34+
35+
private readonly GetAzureAutomationDscNodeConfigurationDeploymentSchedule cmdlet;
36+
37+
public GetAzureAutomationDscNodeConfigurationDeploymentSchedulesTest()
38+
{
39+
mockAutomationClient = new Mock<IAutomationClient>();
40+
mockCommandRuntime = new MockCommandRuntime();
41+
cmdlet = new GetAzureAutomationDscNodeConfigurationDeploymentSchedule
42+
{
43+
AutomationClient = mockAutomationClient.Object,
44+
CommandRuntime = mockCommandRuntime
45+
};
46+
}
47+
48+
[Fact]
49+
[Trait(Category.AcceptanceType, Category.CheckIn)]
50+
public void GetAzureAutomationDscNodeConfigurationDeploymentSchedulesByJobScheduleIdSuccessful()
51+
{
52+
// Setup
53+
var resourceGroupName = "resourceGroup";
54+
var accountName = "automation";
55+
var jobScheduleId = Guid.NewGuid();
56+
57+
mockAutomationClient.Setup(
58+
f =>
59+
f.GetNodeConfigurationDeploymentSchedule(resourceGroupName, accountName, jobScheduleId)
60+
);
61+
62+
// Test
63+
cmdlet.ResourceGroupName = resourceGroupName;
64+
cmdlet.AutomationAccountName = accountName;
65+
cmdlet.JobScheduleId = jobScheduleId;
66+
cmdlet.SetParameterSet("ByJobScheduleId");
67+
68+
cmdlet.ExecuteCmdlet();
69+
70+
// Assert
71+
mockAutomationClient.Verify(
72+
f =>
73+
f.GetNodeConfigurationDeploymentSchedule(resourceGroupName, accountName, jobScheduleId), Times.Once());
74+
}
75+
76+
[Fact]
77+
[Trait(Category.AcceptanceType, Category.CheckIn)]
78+
public void GetAzureAutomationDscNodeConfigurationDeploymentSchedulesByAllSuccessful()
79+
{
80+
// Setup
81+
var resourceGroupName = "resourceGroup";
82+
var accountName = "automation";
83+
var nextLink = string.Empty;
84+
85+
mockAutomationClient.Setup(
86+
f => f.ListNodeConfigurationDeploymentSchedules(resourceGroupName, accountName, ref nextLink)).Returns((string a, string b, string c) => new List<NodeConfigurationDeploymentSchedule>());
87+
88+
// Test
89+
cmdlet.ResourceGroupName = resourceGroupName;
90+
cmdlet.AutomationAccountName = accountName;
91+
cmdlet.SetParameterSet("ByAll");
92+
93+
cmdlet.ExecuteCmdlet();
94+
95+
// Assert
96+
mockAutomationClient.Verify(f => f.ListNodeConfigurationDeploymentSchedules(resourceGroupName, accountName, ref nextLink), Times.Once());
97+
}
98+
}
99+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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.Commands.Automation.Cmdlet;
16+
using Microsoft.Azure.Commands.Automation.Common;
17+
using Microsoft.WindowsAzure.Commands.Common.Test.Mocks;
18+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
19+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
20+
using Moq;
21+
using Xunit;
22+
using System;
23+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
24+
25+
namespace Microsoft.Azure.Commands.ResourceManager.Automation.Test.UnitTests
26+
{
27+
public class GetAzureAutomationDscNodeConfigurationDeploymentTest : RMTestBase
28+
{
29+
private readonly Mock<IAutomationClient> mockAutomationClient;
30+
31+
private readonly MockCommandRuntime mockCommandRuntime;
32+
33+
private readonly GetAzureAutomationDscNodeConfigurationDeployment cmdlet;
34+
35+
public GetAzureAutomationDscNodeConfigurationDeploymentTest()
36+
{
37+
mockAutomationClient = new Mock<IAutomationClient>();
38+
mockCommandRuntime = new MockCommandRuntime();
39+
cmdlet = new GetAzureAutomationDscNodeConfigurationDeployment
40+
{
41+
AutomationClient = mockAutomationClient.Object,
42+
CommandRuntime = mockCommandRuntime
43+
};
44+
}
45+
46+
[Fact]
47+
[Trait(Category.AcceptanceType, Category.CheckIn)]
48+
public void GetAzureAutomationDscCompilationJobTestSuccessful()
49+
{
50+
// Setup
51+
var resourceGroupName = "resourceGroup";
52+
var accountName = "automation";
53+
var jobId = Guid.NewGuid();
54+
55+
string[][] nodeNames =
56+
{
57+
new[] {"WebServerPilot1", "WebServerPilot2"},
58+
new[] {"WebServerProd1", "WebServerProd2"}
59+
};
60+
61+
mockAutomationClient.Setup(
62+
f =>
63+
f.GetNodeConfigurationDeployment(resourceGroupName, accountName, jobId)
64+
);
65+
66+
// Test
67+
cmdlet.ResourceGroupName = resourceGroupName;
68+
cmdlet.AutomationAccountName = accountName;
69+
cmdlet.JobId = jobId;
70+
cmdlet.SetParameterSet("ByJobId");
71+
72+
cmdlet.ExecuteCmdlet();
73+
74+
// Assert
75+
mockAutomationClient.Verify(
76+
f =>
77+
f.GetNodeConfigurationDeployment(resourceGroupName, accountName, jobId), Times.Once());
78+
}
79+
}
80+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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.Commands.Automation.Cmdlet;
16+
using Microsoft.Azure.Commands.Automation.Common;
17+
using Microsoft.WindowsAzure.Commands.Common.Test.Mocks;
18+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
19+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
20+
using Moq;
21+
using Xunit;
22+
using System;
23+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
24+
25+
namespace Microsoft.Azure.Commands.ResourceManager.Automation.Test.UnitTests
26+
{
27+
public class StartAzureAutomationDscNodeConfigurationDeploymentTest : RMTestBase
28+
{
29+
private readonly Mock<IAutomationClient> mockAutomationClient;
30+
31+
private readonly MockCommandRuntime mockCommandRuntime;
32+
33+
private readonly StartAzureAutomationDscNodeConfigurationDeployment cmdlet;
34+
35+
public StartAzureAutomationDscNodeConfigurationDeploymentTest()
36+
{
37+
mockAutomationClient = new Mock<IAutomationClient>();
38+
mockCommandRuntime = new MockCommandRuntime();
39+
cmdlet = new StartAzureAutomationDscNodeConfigurationDeployment
40+
{
41+
AutomationClient = mockAutomationClient.Object,
42+
CommandRuntime = mockCommandRuntime
43+
};
44+
}
45+
46+
[Fact]
47+
[Trait(Category.AcceptanceType, Category.CheckIn)]
48+
public void StartAzureAutomationDscCompilationJobTestSuccessful()
49+
{
50+
// Setup
51+
var resourceGroupName = "resourceGroup";
52+
var accountName = "automation";
53+
var nodeConfigurationName = "config.runbook";
54+
string[][] nodeNames =
55+
{
56+
new[] {"WebServerPilot1", "WebServerPilot2"},
57+
new[] {"WebServerProd1", "WebServerProd2"}
58+
};
59+
60+
mockAutomationClient.Setup(
61+
f =>
62+
f.StartNodeConfigurationDeployment(resourceGroupName, accountName, nodeConfigurationName, nodeNames,
63+
null)
64+
);
65+
66+
// Test
67+
cmdlet.ResourceGroupName = resourceGroupName;
68+
cmdlet.AutomationAccountName = accountName;
69+
cmdlet.NodeConfigurationName = nodeConfigurationName;
70+
cmdlet.NodeName = nodeNames;
71+
cmdlet.Schedule = null;
72+
cmdlet.SetParameterSet("ByAll");
73+
74+
cmdlet.ExecuteCmdlet();
75+
76+
// Assert
77+
mockAutomationClient.Verify(
78+
f =>
79+
f.StartNodeConfigurationDeployment(resourceGroupName, accountName, nodeConfigurationName, nodeNames,
80+
null), Times.Once());
81+
}
82+
}
83+
}

0 commit comments

Comments
 (0)