Skip to content

Commit f5dcfe5

Browse files
committed
Merge pull request #24 from Azure/dev
.
2 parents 7bcd368 + a259013 commit f5dcfe5

File tree

49 files changed

+16176
-8728
lines changed

Some content is hidden

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

49 files changed

+16176
-8728
lines changed

ChangeLog.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
2015.06.05 version 0.9.3
1+
2015.06.25 version 0.9.4
2+
* Added Batch cmdlets
3+
* Start-AzureBatchPoolResize
4+
* Stop-AzureBatchPoolResize
5+
6+
2015.06.05 version 0.9.3
27
* Fixed bug in Websites cmdlets related to slots #454
38
* Fix bug in Set-AzureResource cmdlet #456
49
* Fix for new azure resource of Microsoft.Storage #457

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@
166166
<Compile Include="Pools\GetBatchPoolCommandTests.cs" />
167167
<Compile Include="Pools\NewBatchPoolCommandTests.cs" />
168168
<Compile Include="Pools\RemoveBatchPoolCommandTests.cs" />
169+
<Compile Include="Pools\StartBatchPoolResizeCommandTests.cs" />
170+
<Compile Include="Pools\StopBatchPoolResizeCommandTests.cs" />
169171
<Compile Include="Properties\AssemblyInfo.cs" />
170172
<Compile Include="ScenarioTests\BatchAccountTests.cs" />
171173
<Compile Include="ScenarioTests\BatchController.cs" />
@@ -339,6 +341,18 @@
339341
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.PoolTests\TestNewPool.json">
340342
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
341343
</None>
344+
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.PoolTests\TestResizePoolByName.json">
345+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
346+
</None>
347+
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.PoolTests\TestResizePoolByPipeline.json">
348+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
349+
</None>
350+
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.PoolTests\TestStopResizePoolByName.json">
351+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
352+
</None>
353+
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.PoolTests\TestStopResizePoolByPipeline.json">
354+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
355+
</None>
342356
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.TaskTests\TestCreateTask.json">
343357
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
344358
</None>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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.Entities;
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 StartBatchPoolResizeCommandTests
32+
{
33+
private StartBatchPoolResizeCommand cmdlet;
34+
private Mock<BatchClient> batchClientMock;
35+
private Mock<ICommandRuntime> commandRuntimeMock;
36+
37+
public StartBatchPoolResizeCommandTests()
38+
{
39+
batchClientMock = new Mock<BatchClient>();
40+
commandRuntimeMock = new Mock<ICommandRuntime>();
41+
cmdlet = new StartBatchPoolResizeCommand()
42+
{
43+
CommandRuntime = commandRuntimeMock.Object,
44+
BatchClient = batchClientMock.Object,
45+
};
46+
}
47+
48+
[Fact]
49+
[Trait(Category.AcceptanceType, Category.CheckIn)]
50+
public void StartPoolResizeParametersTest()
51+
{
52+
BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
53+
cmdlet.BatchContext = context;
54+
cmdlet.Name = null;
55+
56+
Assert.Throws<ArgumentNullException>(() => cmdlet.ExecuteCmdlet());
57+
58+
cmdlet.Name = "testPool";
59+
60+
// Don't go to the service on a ResizePool call
61+
YieldInjectionInterceptor interceptor = new YieldInjectionInterceptor((opContext, request) =>
62+
{
63+
if (request is ResizePoolRequest)
64+
{
65+
ResizePoolResponse response = new ResizePoolResponse();
66+
Task<object> task = Task<object>.Factory.StartNew(() => { return response; });
67+
return task;
68+
}
69+
return null;
70+
});
71+
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
72+
73+
// Verify no exceptions when required parameter is set
74+
cmdlet.ExecuteCmdlet();
75+
}
76+
}
77+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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.WindowsAzure.Commands.ScenarioTest;
19+
using Moq;
20+
using System.Collections.Generic;
21+
using System.Linq;
22+
using System.Management.Automation;
23+
using System.Threading.Tasks;
24+
using Xunit;
25+
using BatchClient = Microsoft.Azure.Commands.Batch.Models.BatchClient;
26+
27+
namespace Microsoft.Azure.Commands.Batch.Test.Pools
28+
{
29+
public class StopBatchPoolResizeCommandTests
30+
{
31+
private StopBatchPoolResizeCommand cmdlet;
32+
private Mock<BatchClient> batchClientMock;
33+
private Mock<ICommandRuntime> commandRuntimeMock;
34+
35+
public StopBatchPoolResizeCommandTests()
36+
{
37+
batchClientMock = new Mock<BatchClient>();
38+
commandRuntimeMock = new Mock<ICommandRuntime>();
39+
cmdlet = new StopBatchPoolResizeCommand()
40+
{
41+
CommandRuntime = commandRuntimeMock.Object,
42+
BatchClient = batchClientMock.Object,
43+
};
44+
}
45+
46+
[Fact]
47+
[Trait(Category.AcceptanceType, Category.CheckIn)]
48+
public void StopPoolResizeParametersTest()
49+
{
50+
BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
51+
cmdlet.BatchContext = context;
52+
cmdlet.Name = null;
53+
54+
Assert.Throws<ArgumentNullException>(() => cmdlet.ExecuteCmdlet());
55+
56+
cmdlet.Name = "testPool";
57+
58+
// Don't go to the service on a StopPoolResize call
59+
YieldInjectionInterceptor interceptor = new YieldInjectionInterceptor((opContext, request) =>
60+
{
61+
if (request is StopPoolResizeRequest)
62+
{
63+
StopPoolResizeResponse response = new StopPoolResizeResponse();
64+
Task<object> task = Task<object>.Factory.StartNew(() => { return response; });
65+
return task;
66+
}
67+
return null;
68+
});
69+
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
70+
71+
// Verify no exceptions when required parameter is set
72+
cmdlet.ExecuteCmdlet();
73+
}
74+
}
75+
}

src/ResourceManager/Batch/Commands.Batch.Test/ScenarioTests/PoolTests.cs

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using Microsoft.Azure.Batch;
16+
using Microsoft.Azure.Commands.Batch.Models;
1617
using Microsoft.Azure.Test;
1718
using Microsoft.WindowsAzure.Commands.ScenarioTest;
1819
using System.Collections.Generic;
@@ -24,6 +25,15 @@ namespace Microsoft.Azure.Commands.Batch.Test.ScenarioTests
2425
{
2526
public class PoolTests
2627
{
28+
// NOTE: To save time on VM allocation when recording, some of tests assume the following:
29+
// - A Batch account named 'pooltests' exists under the subscription being used for recording.
30+
// - The following commands were run to create a pool, and all 3 VMs are allocated:
31+
// $context = Get-AzureBatchAccountKeys "pooltests"
32+
// New-AzureBatchPool -Name "testPool" -VMSize "small" -OSFamily "4" -TargetOSVersion "*" -TargetDedicated 3 -BatchContext $context
33+
34+
private const string commonAccountName = "pooltests";
35+
private const string testPoolName = "testPool";
36+
2737
[Fact]
2838
[Trait(Category.AcceptanceType, Category.CheckIn)]
2939
public void TestNewPool()
@@ -224,6 +234,78 @@ public void TestDeletePoolPipeline()
224234
TestUtilities.GetCallingClass(),
225235
TestUtilities.GetCurrentMethodName());
226236
}
237+
238+
[Fact]
239+
[Trait(Category.AcceptanceType, Category.CheckIn)]
240+
public void TestResizePoolByName()
241+
{
242+
BatchController controller = BatchController.NewInstance;
243+
BatchAccountContext context = null;
244+
controller.RunPsTestWorkflow(
245+
() => { return new string[] { string.Format("Test-ResizePoolByName '{0}' '{1}'", commonAccountName, testPoolName) }; },
246+
() =>
247+
{
248+
context = ScenarioTestHelpers.GetBatchAccountContextWithKeys(controller, commonAccountName);
249+
ScenarioTestHelpers.WaitForSteadyPoolAllocation(controller, context, testPoolName);
250+
},
251+
null,
252+
TestUtilities.GetCallingClass(),
253+
TestUtilities.GetCurrentMethodName());
254+
}
255+
256+
[Fact]
257+
[Trait(Category.AcceptanceType, Category.CheckIn)]
258+
public void TestResizePoolByPipeline()
259+
{
260+
BatchController controller = BatchController.NewInstance;
261+
BatchAccountContext context = null;
262+
controller.RunPsTestWorkflow(
263+
() => { return new string[] { string.Format("Test-ResizePoolByPipeline '{0}' '{1}'", commonAccountName, testPoolName) }; },
264+
() =>
265+
{
266+
context = ScenarioTestHelpers.GetBatchAccountContextWithKeys(controller, commonAccountName);
267+
ScenarioTestHelpers.WaitForSteadyPoolAllocation(controller, context, testPoolName);
268+
},
269+
null,
270+
TestUtilities.GetCallingClass(),
271+
TestUtilities.GetCurrentMethodName());
272+
}
273+
274+
[Fact]
275+
[Trait(Category.AcceptanceType, Category.CheckIn)]
276+
public void TestStopResizePoolByName()
277+
{
278+
BatchController controller = BatchController.NewInstance;
279+
BatchAccountContext context = null;
280+
controller.RunPsTestWorkflow(
281+
() => { return new string[] { string.Format("Test-StopResizePoolByName '{0}' '{1}'", commonAccountName, testPoolName) }; },
282+
() =>
283+
{
284+
context = ScenarioTestHelpers.GetBatchAccountContextWithKeys(controller, commonAccountName);
285+
ScenarioTestHelpers.WaitForSteadyPoolAllocation(controller, context, testPoolName);
286+
},
287+
null,
288+
TestUtilities.GetCallingClass(),
289+
TestUtilities.GetCurrentMethodName());
290+
}
291+
292+
[Fact]
293+
[Trait(Category.AcceptanceType, Category.CheckIn)]
294+
public void TestStopResizePoolByPipeline()
295+
{
296+
BatchController controller = BatchController.NewInstance;
297+
BatchAccountContext context = null;
298+
controller.RunPsTestWorkflow(
299+
() => { return new string[] { string.Format("Test-StopResizePoolByPipeline '{0}' '{1}'", commonAccountName, testPoolName) }; },
300+
() =>
301+
{
302+
context = ScenarioTestHelpers.GetBatchAccountContextWithKeys(controller, commonAccountName);
303+
ScenarioTestHelpers.WaitForSteadyPoolAllocation(controller, context, testPoolName);
304+
},
305+
null,
306+
TestUtilities.GetCallingClass(),
307+
TestUtilities.GetCurrentMethodName());
308+
}
227309
}
228310

229311
// Cmdlets that use the HTTP Recorder interceptor for use with scenario tests
@@ -256,4 +338,24 @@ public override void ExecuteCmdlet()
256338
base.ExecuteCmdlet();
257339
}
258340
}
341+
342+
[Cmdlet(VerbsLifecycle.Start, "AzureBatchPoolResize_ST")]
343+
public class StartBatchPoolResizeScenarioTestCommand : StartBatchPoolResizeCommand
344+
{
345+
public override void ExecuteCmdlet()
346+
{
347+
AdditionalBehaviors = new List<BatchClientBehavior>() { ScenarioTestHelpers.CreateHttpRecordingInterceptor() };
348+
base.ExecuteCmdlet();
349+
}
350+
}
351+
352+
[Cmdlet(VerbsLifecycle.Stop, "AzureBatchPoolResize_ST")]
353+
public class StopBatchPoolResizeScenarioTestCommand : StopBatchPoolResizeCommand
354+
{
355+
public override void ExecuteCmdlet()
356+
{
357+
AdditionalBehaviors = new List<BatchClientBehavior>() { ScenarioTestHelpers.CreateHttpRecordingInterceptor() };
358+
base.ExecuteCmdlet();
359+
}
360+
}
259361
}

0 commit comments

Comments
 (0)