Skip to content

Commit cd63ab3

Browse files
committed
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
2 parents 077615c + f0b5063 commit cd63ab3

File tree

105 files changed

+22384
-5938
lines changed

Some content is hidden

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

105 files changed

+22384
-5938
lines changed

ChangeLog.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1-
## 2015.09.03 version 0.9.8
1+
## 2015.09.03 version 0.9.8
22
* Azure Compute (ARM) Cmdlets
3-
* Add -Launch parameter for Get-AzureRemoteDesktopFile cmdlet
3+
* Added -Launch parameter for Get-AzureRemoteDesktopFile cmdlet
4+
* Added Id parameter for VM cmdlets to support piping scenario without ResourceGroupName parameter
5+
* Added Set-AzureVMDataDisk cmdlet
6+
* Added Add-AzureVhd cmdlet
7+
* Changed the output format of Get image cmdlets as a table
8+
* Fixed Set-AzureVMAccessExtension cmdlet
9+
* Azure Compute (Service Management) cmdlets
10+
* Changed the warning message to a non-terminating error message for ResourceNotFound in VM cmdlets
11+
* Exposed ComputeImageConfig in Get-AzurePlatformVMImage cmdlet
12+
* Fixed Publish-AzurePlatformExtension and Set-AzurePlatformExtension cmdlets
413
* Azure Backup - added the following cmdlets
514
* Backup-AzureRMBackupItem
615
* Register-AzureRMBackupContainer
@@ -18,6 +27,14 @@
1827
* Set-AzureRMBackupProtectionPolicy
1928
* Get-AzureRMBackupRecoveryPoint
2029
* Restore-AzureRMBackupItem
30+
* Azure Batch - added the following cmdlets
31+
* Enable-AzureBatchJob
32+
* Disable-AzureBatchJob
33+
* Enable-AzureBatchJobSchedule
34+
* Disable-AzureBatchJobSchedule
35+
* Stop-AzureBatchJob
36+
* Stop-AzureBatchJobSchedule
37+
* Stop-AzureBatchTask
2138

2239
## 2015.08.17 version 0.9.7
2340
* Azure Profile cmdlets

src/Common/Commands.ScenarioTest/Resources/ServiceManagement/ServiceManagementTests.ps1

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ Tests Create-AzureVM with valid information.
1818
#>
1919
function Test-GetAzureVM
2020
{
21-
# Setup
21+
# Virtual Machine cmdlets are now showing a non-terminating error message for ResourceNotFound
22+
# To continue script, $ErrorActionPreference should be set to 'SilentlyContinue'.
23+
$ErrorActionPreference='SilentlyContinue';
2224

25+
# Setup
2326
$location = Get-DefaultLocation
2427
$imgName = Get-DefaultImage $location
2528

@@ -74,6 +77,10 @@ function Run-ServiceManagementCloudExceptionTests
7477
# Test Start/Stop-AzureVM for Multiple VMs
7578
function Run-StartAndStopMultipleVirtualMachinesTest
7679
{
80+
# Virtual Machine cmdlets are now showing a non-terminating error message for ResourceNotFound
81+
# To continue script, $ErrorActionPreference should be set to 'SilentlyContinue'.
82+
$ErrorActionPreference='SilentlyContinue';
83+
7784
# Setup
7885
$location = Get-DefaultLocation;
7986
$imgName = Get-DefaultImage $location;

src/ResourceManager/AzureBatch/Commands.Batch.Test/Commands.Batch.Test.csproj

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,13 @@
169169
<Compile Include="Files\GetBatchNodeFileContentCommandTests.cs" />
170170
<Compile Include="JobSchedules\DisableBatchJobScheduleCommandTests.cs" />
171171
<Compile Include="JobSchedules\EnableBatchJobScheduleCommandTests.cs" />
172+
<Compile Include="JobSchedules\StopBatchJobScheduleCommandTests.cs" />
172173
<Compile Include="Jobs\DisableBatchJobCommandTests.cs" />
173174
<Compile Include="Jobs\EnableBatchJobCommandTests.cs" />
174175
<Compile Include="Jobs\GetBatchJobCommandTests.cs" />
175176
<Compile Include="Jobs\NewBatchJobCommandTests.cs" />
176177
<Compile Include="Jobs\RemoveBatchJobCommandTests.cs" />
178+
<Compile Include="Jobs\StopBatchJobCommandTests.cs" />
177179
<Compile Include="Models\BatchAccountContextTest.cs" />
178180
<Compile Include="Pools\DisableBatchAutoScaleCommandTests.cs" />
179181
<Compile Include="Pools\EnableBatchAutoScaleCommandTests.cs" />
@@ -204,6 +206,7 @@
204206
<Compile Include="JobSchedules\GetBatchJobScheduleCommandTests.cs" />
205207
<Compile Include="JobSchedules\NewBatchJobScheduleCommandTests.cs" />
206208
<Compile Include="JobSchedules\RemoveBatchJobScheduleCommandTests.cs" />
209+
<Compile Include="Tasks\StopBatchTaskCommandTests.cs" />
207210
</ItemGroup>
208211
<ItemGroup>
209212
<None Include="MSSharedLibKey.snk" />
@@ -372,6 +375,12 @@
372375
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.JobScheduleTests\TestNewJobSchedule.json">
373376
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
374377
</None>
378+
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.JobScheduleTests\TestTerminateJobScheduleById.json">
379+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
380+
</None>
381+
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.JobScheduleTests\TestTerminateJobSchedulePipeline.json">
382+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
383+
</None>
375384
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.JobTests\TestDeleteJob.json">
376385
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
377386
</None>
@@ -399,6 +408,12 @@
399408
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.JobTests\TestNewJob.json">
400409
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
401410
</None>
411+
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.JobTests\TestTerminateJobById.json">
412+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
413+
</None>
414+
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.JobTests\TestTerminateJobPipeline.json">
415+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
416+
</None>
402417
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.PoolTests\TestChangeOSVersionById.json">
403418
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
404419
</None>
@@ -480,6 +495,9 @@
480495
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.TaskTests\TestListTasksWithMaxCount.json">
481496
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
482497
</None>
498+
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.TaskTests\TestTerminateTask.json">
499+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
500+
</None>
483501
</ItemGroup>
484502
<ItemGroup>
485503
<ProjectReference Include="..\..\..\Common\Commands.Common.Test\Commands.Common.Test.csproj">
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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 System;
16+
using Microsoft.Azure.Batch;
17+
using Microsoft.Azure.Batch.Protocol;
18+
using Microsoft.Azure.Batch.Protocol.Models;
19+
using Microsoft.Azure.Commands.Batch.Models;
20+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
21+
using Moq;
22+
using System.Collections.Generic;
23+
using System.Linq;
24+
using System.Management.Automation;
25+
using System.Threading.Tasks;
26+
using Xunit;
27+
using BatchClient = Microsoft.Azure.Commands.Batch.Models.BatchClient;
28+
29+
namespace Microsoft.Azure.Commands.Batch.Test.Pools
30+
{
31+
public class StopBatchJobScheduleCommandTests
32+
{
33+
private StopBatchJobScheduleCommand cmdlet;
34+
private Mock<BatchClient> batchClientMock;
35+
private Mock<ICommandRuntime> commandRuntimeMock;
36+
37+
public StopBatchJobScheduleCommandTests()
38+
{
39+
batchClientMock = new Mock<BatchClient>();
40+
commandRuntimeMock = new Mock<ICommandRuntime>();
41+
cmdlet = new StopBatchJobScheduleCommand()
42+
{
43+
CommandRuntime = commandRuntimeMock.Object,
44+
BatchClient = batchClientMock.Object,
45+
};
46+
}
47+
48+
[Fact]
49+
[Trait(Category.AcceptanceType, Category.CheckIn)]
50+
public void StopJobScheduleParametersTest()
51+
{
52+
BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
53+
cmdlet.BatchContext = context;
54+
cmdlet.Id = null;
55+
56+
Assert.Throws<ArgumentNullException>(() => cmdlet.ExecuteCmdlet());
57+
58+
cmdlet.Id = "testJobSchedule";
59+
60+
// Don't go to the service on a Terminate CloudJobSchedule call
61+
RequestInterceptor interceptor = new RequestInterceptor((baseRequest) =>
62+
{
63+
BatchRequest<CloudJobScheduleTerminateParameters, CloudJobScheduleTerminateResponse> request =
64+
(BatchRequest<CloudJobScheduleTerminateParameters, CloudJobScheduleTerminateResponse>)baseRequest;
65+
66+
request.ServiceRequestFunc = (cancellationToken) =>
67+
{
68+
CloudJobScheduleTerminateResponse response = new CloudJobScheduleTerminateResponse();
69+
Task<CloudJobScheduleTerminateResponse> task = Task.FromResult(response);
70+
return task;
71+
};
72+
});
73+
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
74+
75+
// Verify no exceptions when required parameter is set
76+
cmdlet.ExecuteCmdlet();
77+
}
78+
}
79+
}
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
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 System;
16+
using Microsoft.Azure.Batch;
17+
using Microsoft.Azure.Batch.Common;
18+
using Microsoft.Azure.Batch.Protocol;
19+
using Microsoft.Azure.Batch.Protocol.Models;
20+
using Microsoft.Azure.Commands.Batch.Models;
21+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
22+
using Moq;
23+
using System.Collections.Generic;
24+
using System.Linq;
25+
using System.Management.Automation;
26+
using System.Threading.Tasks;
27+
using Xunit;
28+
using BatchClient = Microsoft.Azure.Commands.Batch.Models.BatchClient;
29+
30+
namespace Microsoft.Azure.Commands.Batch.Test.Pools
31+
{
32+
public class StopBatchJobCommandTests
33+
{
34+
private StopBatchJobCommand cmdlet;
35+
private Mock<BatchClient> batchClientMock;
36+
private Mock<ICommandRuntime> commandRuntimeMock;
37+
38+
public StopBatchJobCommandTests()
39+
{
40+
batchClientMock = new Mock<BatchClient>();
41+
commandRuntimeMock = new Mock<ICommandRuntime>();
42+
cmdlet = new StopBatchJobCommand()
43+
{
44+
CommandRuntime = commandRuntimeMock.Object,
45+
BatchClient = batchClientMock.Object,
46+
};
47+
}
48+
49+
[Fact]
50+
[Trait(Category.AcceptanceType, Category.CheckIn)]
51+
public void StopJobParametersTest()
52+
{
53+
BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
54+
cmdlet.BatchContext = context;
55+
cmdlet.Id = null;
56+
57+
Assert.Throws<ArgumentNullException>(() => cmdlet.ExecuteCmdlet());
58+
59+
cmdlet.Id = "testJob";
60+
61+
// Don't go to the service on a Terminate CloudJob call
62+
RequestInterceptor interceptor = new RequestInterceptor((baseRequest) =>
63+
{
64+
BatchRequest<CloudJobTerminateParameters, CloudJobTerminateResponse> request =
65+
(BatchRequest<CloudJobTerminateParameters, CloudJobTerminateResponse>)baseRequest;
66+
67+
request.ServiceRequestFunc = (cancellationToken) =>
68+
{
69+
CloudJobTerminateResponse response = new CloudJobTerminateResponse();
70+
Task<CloudJobTerminateResponse> task = Task.FromResult(response);
71+
return task;
72+
};
73+
});
74+
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
75+
76+
// Verify no exceptions when required parameter is set
77+
cmdlet.ExecuteCmdlet();
78+
}
79+
80+
[Fact]
81+
[Trait(Category.AcceptanceType, Category.CheckIn)]
82+
public void StopJobRequestTest()
83+
{
84+
BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
85+
cmdlet.BatchContext = context;
86+
87+
string terminateReason = "testing";
88+
string requestTerminateReason = null;
89+
90+
cmdlet.Id = "testJob";
91+
cmdlet.TerminateReason = terminateReason;
92+
93+
// Don't go to the service on a Terminate CloudJob call
94+
RequestInterceptor interceptor = new RequestInterceptor((baseRequest) =>
95+
{
96+
BatchRequest<CloudJobTerminateParameters, CloudJobTerminateResponse> request =
97+
(BatchRequest<CloudJobTerminateParameters, CloudJobTerminateResponse>)baseRequest;
98+
99+
requestTerminateReason = request.TypedParameters.TerminateReason;
100+
101+
request.ServiceRequestFunc = (cancellationToken) =>
102+
{
103+
CloudJobTerminateResponse response = new CloudJobTerminateResponse();
104+
Task<CloudJobTerminateResponse> task = Task.FromResult(response);
105+
return task;
106+
};
107+
});
108+
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
109+
110+
cmdlet.ExecuteCmdlet();
111+
112+
// Verify that the job terminate reason was properly set on the outgoing request
113+
Assert.Equal(terminateReason, requestTerminateReason);
114+
}
115+
}
116+
}

src/ResourceManager/AzureBatch/Commands.Batch.Test/ScenarioTests/JobScheduleTests.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,40 @@ public void TestDisableAndEnableJobSchedule()
206206
TestUtilities.GetCallingClass(),
207207
TestUtilities.GetCurrentMethodName());
208208
}
209+
210+
[Fact]
211+
[Trait(Category.AcceptanceType, Category.CheckIn)]
212+
public void TestTerminateJobScheduleById()
213+
{
214+
TestTerminateJobSchedule(false);
215+
}
216+
217+
[Fact]
218+
[Trait(Category.AcceptanceType, Category.CheckIn)]
219+
public void TestTerminateJobSchedulePipeline()
220+
{
221+
TestTerminateJobSchedule(true);
222+
}
223+
224+
private void TestTerminateJobSchedule(bool usePipeline)
225+
{
226+
BatchController controller = BatchController.NewInstance;
227+
BatchAccountContext context = null;
228+
string jobScheduleId = "testTerminateJobSchedule" + (usePipeline ? "Pipeline" : "Id");
229+
controller.RunPsTestWorkflow(
230+
() => { return new string[] { string.Format("Test-TerminateJobSchedule '{0}' '{1}' '{2}'", accountName, jobScheduleId, usePipeline ? 1 : 0) }; },
231+
() =>
232+
{
233+
context = ScenarioTestHelpers.GetBatchAccountContextWithKeys(controller, accountName);
234+
ScenarioTestHelpers.CreateTestJobSchedule(controller, context, jobScheduleId, null);
235+
},
236+
() =>
237+
{
238+
ScenarioTestHelpers.DeleteJobSchedule(controller, context, jobScheduleId);
239+
},
240+
TestUtilities.GetCallingClass(),
241+
usePipeline ? "TestTerminateJobSchedulePipeline" : "TestTerminateJobScheduleById");
242+
}
209243
}
210244

211245
// Cmdlets that use the HTTP Recorder interceptor for use with scenario tests
@@ -258,4 +292,14 @@ public override void ExecuteCmdlet()
258292
base.ExecuteCmdlet();
259293
}
260294
}
295+
296+
[Cmdlet(VerbsLifecycle.Stop, "AzureBatchJobSchedule_ST")]
297+
public class StopBatchJobScheduleScenarioTestCommand : StopBatchJobScheduleCommand
298+
{
299+
public override void ExecuteCmdlet()
300+
{
301+
AdditionalBehaviors = new List<BatchClientBehavior>() { ScenarioTestHelpers.CreateHttpRecordingInterceptor() };
302+
base.ExecuteCmdlet();
303+
}
304+
}
261305
}

src/ResourceManager/AzureBatch/Commands.Batch.Test/ScenarioTests/JobScheduleTests.ps1

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,4 +390,28 @@ function Test-DisableAndEnableJobSchedule
390390
$jobSchedule | Enable-AzureBatchJobSchedule_ST -BatchContext $context
391391
$jobSchedule = Get-AzureBatchJobSchedule_ST -Filter "id eq '$jobScheduleId'" -BatchContext $context
392392
Assert-AreEqual 'Active' $jobSchedule.State
393+
}
394+
395+
<#
396+
.SYNOPSIS
397+
Tests terminating a job schedule
398+
#>
399+
function Test-TerminateJobSchedule
400+
{
401+
param([string]$accountName, [string]$jobScheduleId, [string]$usePipeline)
402+
403+
$context = Get-AzureBatchAccountKeys -Name $accountName
404+
405+
if ($usePipeline -eq '1')
406+
{
407+
Get-AzureBatchJobSchedule_ST -Id $jobScheduleId -BatchContext $context | Stop-AzureBatchJobSchedule_ST -BatchContext $context
408+
}
409+
else
410+
{
411+
Stop-AzureBatchJobSchedule_ST $jobScheduleId -BatchContext $context
412+
}
413+
414+
# Verify the job schedule was terminated
415+
$jobSchedule = Get-AzureBatchJobSchedule_ST $jobScheduleId -BatchContext $context
416+
Assert-True { ($jobSchedule.State.ToString().ToLower() -eq 'terminating') -or ($jobSchedule.State.ToString().ToLower() -eq 'completed') }
393417
}

0 commit comments

Comments
 (0)