Skip to content

Commit 01b2fcb

Browse files
committed
Merge pull request #663 from jasper-schneider/clientV2
Update Batch cmdlets to use general availability API
2 parents 34effd3 + af6a16f commit 01b2fcb

File tree

249 files changed

+62366
-26650
lines changed

Some content is hidden

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

249 files changed

+62366
-26650
lines changed

ChangeLog.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2015.08.07 version 0.9.6
2+
* Azure Batch cmdlets
3+
* Cmdlets updated to use the general availability API. See http://blogs.technet.com/b/windowshpc/archive/2015/07/10/what-39-s-new-in-azure-batch-july-release-general-availability.aspx
4+
* Breaking changes to cmdlets resulting from API update:
5+
* Workitems have been removed.
6+
* If you were adding all tasks to a single job, use the New-AzureBatchJob cmdlet to directly create your job.
7+
* If you were managing workitems with a recurring schedule defined, use the AzureBatchJobSchedule cmdlets instead.
8+
* If you were using the AzureBatchVM cmdlets, use the AzureBatchComputeNode cmdlets instead.
9+
* The AzureBatchTaskFile and AzureBatchVMFile cmdlets have been consolidated into the AzureBatchNodeFile cmdlets.
10+
* The Name property on most entities has been replaced by an Id property.
11+
112
2015.07.17 version 0.9.5
213
* Azure SQL cmdlets
314
* Allowing to use of Storage V2 accounts in Auditing policies

src/ResourceManager/Batch/Commands.Batch.Test/BatchTestHelpers.cs

Lines changed: 99 additions & 162 deletions
Large diffs are not rendered by default.

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

Lines changed: 98 additions & 98 deletions
Large diffs are not rendered by default.
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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.Management.Automation;
24+
using System.Threading.Tasks;
25+
using Xunit;
26+
using BatchClient = Microsoft.Azure.Commands.Batch.Models.BatchClient;
27+
28+
namespace Microsoft.Azure.Commands.Batch.Test.ComputeNodeUsers
29+
{
30+
public class NewBatchComputeNodeUserCommandTests
31+
{
32+
private NewBatchComputeNodeUserCommand cmdlet;
33+
private Mock<BatchClient> batchClientMock;
34+
private Mock<ICommandRuntime> commandRuntimeMock;
35+
36+
public NewBatchComputeNodeUserCommandTests()
37+
{
38+
batchClientMock = new Mock<BatchClient>();
39+
commandRuntimeMock = new Mock<ICommandRuntime>();
40+
cmdlet = new NewBatchComputeNodeUserCommand()
41+
{
42+
CommandRuntime = commandRuntimeMock.Object,
43+
BatchClient = batchClientMock.Object,
44+
};
45+
}
46+
47+
[Fact]
48+
[Trait(Category.AcceptanceType, Category.CheckIn)]
49+
public void NewBatchComputeNodeUserParametersTest()
50+
{
51+
// Setup cmdlet without the required parameters
52+
BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
53+
cmdlet.BatchContext = context;
54+
55+
Assert.Throws<ArgumentNullException>(() => cmdlet.ExecuteCmdlet());
56+
57+
cmdlet.PoolId = "testPool";
58+
cmdlet.ComputeNodeId = "computeNode1";
59+
60+
Assert.Throws<ArgumentNullException>(() => cmdlet.ExecuteCmdlet());
61+
cmdlet.Name = "testUser";
62+
63+
Assert.Throws<ArgumentNullException>(() => cmdlet.ExecuteCmdlet());
64+
cmdlet.Password = "Password1234";
65+
66+
// Don't go to the service on an Add ComputeNodeUser call
67+
RequestInterceptor interceptor = new RequestInterceptor((baseRequest) =>
68+
{
69+
BatchRequest<ComputeNodeAddUserParameters, ComputeNodeAddUserResponse> request =
70+
(BatchRequest<ComputeNodeAddUserParameters, ComputeNodeAddUserResponse>)baseRequest;
71+
72+
request.ServiceRequestFunc = (cancellationToken) =>
73+
{
74+
ComputeNodeAddUserResponse response = new ComputeNodeAddUserResponse();
75+
Task<ComputeNodeAddUserResponse> task = Task.FromResult(response);
76+
return task;
77+
};
78+
});
79+
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
80+
81+
// Verify no exceptions when required parameters are set
82+
cmdlet.ExecuteCmdlet();
83+
}
84+
}
85+
}

src/ResourceManager/Batch/Commands.Batch.Test/VMUsers/RemoveBatchVMUserCommandTests.cs renamed to src/ResourceManager/Batch/Commands.Batch.Test/ComputeNodeUsers/RemoveBatchComputeNodeUserCommandTests.cs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
using System;
1616
using Microsoft.Azure.Batch;
1717
using Microsoft.Azure.Batch.Protocol;
18-
using Microsoft.Azure.Batch.Protocol.Entities;
18+
using Microsoft.Azure.Batch.Protocol.Models;
1919
using Microsoft.WindowsAzure.Commands.ScenarioTest;
2020
using Moq;
2121
using System.Collections.Generic;
@@ -24,19 +24,19 @@
2424
using Xunit;
2525
using BatchClient = Microsoft.Azure.Commands.Batch.Models.BatchClient;
2626

27-
namespace Microsoft.Azure.Commands.Batch.Test.Users
27+
namespace Microsoft.Azure.Commands.Batch.Test.ComputeNodeUsers
2828
{
29-
public class RemoveBatchVMUserCommandTests
29+
public class RemoveBatchComputeNodeUserCommandTests
3030
{
31-
private RemoveBatchVMUserCommand cmdlet;
31+
private RemoveBatchComputeNodeUserCommand cmdlet;
3232
private Mock<BatchClient> batchClientMock;
3333
private Mock<ICommandRuntime> commandRuntimeMock;
3434

35-
public RemoveBatchVMUserCommandTests()
35+
public RemoveBatchComputeNodeUserCommandTests()
3636
{
3737
batchClientMock = new Mock<BatchClient>();
3838
commandRuntimeMock = new Mock<ICommandRuntime>();
39-
cmdlet = new RemoveBatchVMUserCommand()
39+
cmdlet = new RemoveBatchComputeNodeUserCommand()
4040
{
4141
CommandRuntime = commandRuntimeMock.Object,
4242
BatchClient = batchClientMock.Object,
@@ -45,7 +45,7 @@ public RemoveBatchVMUserCommandTests()
4545

4646
[Fact]
4747
[Trait(Category.AcceptanceType, Category.CheckIn)]
48-
public void RemoveBatchUserParametersTest()
48+
public void RemoveBatchComputeNodeUserParametersTest()
4949
{
5050
// Setup cmdlet without the required parameters
5151
BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
@@ -57,20 +57,22 @@ public void RemoveBatchUserParametersTest()
5757

5858
Assert.Throws<ArgumentNullException>(() => cmdlet.ExecuteCmdlet());
5959

60-
cmdlet.PoolName = "testPool";
61-
cmdlet.VMName = "vm1";
60+
cmdlet.PoolId = "testPool";
61+
cmdlet.ComputeNodeId = "computeNode1";
6262
cmdlet.Name = "testUser";
6363

6464
// Don't go to the service on a DeleteTVMUser call
65-
YieldInjectionInterceptor interceptor = new YieldInjectionInterceptor((opContext, request) =>
65+
RequestInterceptor interceptor = new RequestInterceptor((baseRequest) =>
6666
{
67-
if (request is DeleteTVMUserRequest)
67+
BatchRequest<ComputeNodeDeleteUserParameters, ComputeNodeDeleteUserResponse> request =
68+
(BatchRequest<ComputeNodeDeleteUserParameters, ComputeNodeDeleteUserResponse>)baseRequest;
69+
70+
request.ServiceRequestFunc = (cancellationToken) =>
6871
{
69-
DeleteTVMUserResponse response = new DeleteTVMUserResponse();
70-
Task<object> task = Task<object>.Factory.StartNew(() => { return response; });
72+
ComputeNodeDeleteUserResponse response = new ComputeNodeDeleteUserResponse();
73+
Task<ComputeNodeDeleteUserResponse> task = Task.FromResult(response);
7174
return task;
72-
}
73-
return null;
75+
};
7476
});
7577
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
7678

0 commit comments

Comments
 (0)