diff --git a/src/Accounts/Accounts/AzureRmAlias/Mappings.json b/src/Accounts/Accounts/AzureRmAlias/Mappings.json
index 81a564096520..ed5253695ccd 100644
--- a/src/Accounts/Accounts/AzureRmAlias/Mappings.json
+++ b/src/Accounts/Accounts/AzureRmAlias/Mappings.json
@@ -356,6 +356,7 @@
"Test-AzBatchAutoScale": "Test-AzureBatchAutoScale",
"Get-AzBatchLocationQuotas": "Get-AzureRmBatchLocationQuotas",
"Get-AzBatchSubtask": "Get-AzureBatchSubtask",
+ "Get-AzBatchSupportedVirtualMachineSku": "Get-AzureBatchSupportedVirtualMachineSku",
"Get-AzBatchTask": "Get-AzureBatchTask",
"New-AzBatchTask": "New-AzureBatchTask",
"Remove-AzBatchTask": "Remove-AzureBatchTask",
@@ -365,6 +366,7 @@
"Set-AzBatchTask": "Set-AzureBatchTask",
"Stop-AzBatchTask": "Stop-AzureBatchTask",
"Get-AzBatchComputeNode": "Get-AzureBatchComputeNode",
+ "Get-AzBatchComputeNodeExtension": "Get-AzureBatchComputeNodeExtension",
"Get-AzBatchJobSchedule": "Get-AzureBatchJobSchedule",
"New-AzBatchJobSchedule": "New-AzureBatchJobSchedule",
"Remove-AzBatchJobSchedule": "Remove-AzureBatchJobSchedule",
diff --git a/src/Batch/Batch.Test/Batch.Test.csproj b/src/Batch/Batch.Test/Batch.Test.csproj
index dddff3a9b42d..a02b3b5baa78 100644
--- a/src/Batch/Batch.Test/Batch.Test.csproj
+++ b/src/Batch/Batch.Test/Batch.Test.csproj
@@ -13,8 +13,8 @@
-
-
+
+
diff --git a/src/Batch/Batch.Test/BatchAccounts/GetBatchAccountCommandTests.cs b/src/Batch/Batch.Test/BatchAccounts/GetBatchAccountCommandTests.cs
index f6d05d9c8305..3f67df2eb207 100644
--- a/src/Batch/Batch.Test/BatchAccounts/GetBatchAccountCommandTests.cs
+++ b/src/Batch/Batch.Test/BatchAccounts/GetBatchAccountCommandTests.cs
@@ -92,7 +92,7 @@ public void GetBatchAccount_IdentityTest()
{
string accountName = "account01";
string resourceGroup = "resourceGroup";
- BatchAccount accountResource = BatchTestHelpers.CreateAccountResource(accountName, resourceGroup, identity: new BatchAccountIdentity(ResourceIdentityType.None, string.Empty, string.Empty));
+ BatchAccount accountResource = BatchTestHelpers.CreateAccountResource(accountName, resourceGroup, identity: new BatchAccountIdentity(ResourceIdentityType.None, string.Empty, string.Empty, null as IDictionary));
BatchAccountContext expected = BatchAccountContext.ConvertAccountResourceToNewAccountContext(accountResource, null);
batchClientMock.Setup(b => b.GetAccount(resourceGroup, accountName)).Returns(expected);
diff --git a/src/Batch/Batch.Test/BatchTestHelpers.cs b/src/Batch/Batch.Test/BatchTestHelpers.cs
index a13f19761c11..65bb6a954a8c 100644
--- a/src/Batch/Batch.Test/BatchTestHelpers.cs
+++ b/src/Batch/Batch.Test/BatchTestHelpers.cs
@@ -81,7 +81,7 @@ public static BatchAccount CreateAccountResource(
tags: tags == null ? null : TagsConversionHelper.CreateTagDictionary(tags, true),
dedicatedCoreQuotaPerVMFamilyEnforced: dedicatedCoreQuotaPerVMFamilyEnforced,
dedicatedCoreQuotaPerVMFamily: machineFamilyQuotas,
- identity: identity ?? new BatchAccountIdentity(ResourceIdentityType.None));
+ identity: identity);
return resource;
}
@@ -376,18 +376,23 @@ public static RequestInterceptor ExamineRequestInterceptor(Action assertAc
}
///
- /// Builds a CloudPoolGetResponse object
+ /// Builds a CloudPoolGetResponse object using a pool ID
///
public static AzureOperationResponse CreateCloudPoolGetResponse(string poolId)
{
- var response = new AzureOperationResponse();
- response.Response = new HttpResponseMessage(HttpStatusCode.OK);
-
ProxyModels.CloudPool pool = new ProxyModels.CloudPool();
pool.Id = poolId;
+ return CreateCloudPoolGetResponse(pool);
+ }
+ ///
+ /// Builds a CloudPoolGetResponse object using a pool model
+ ///
+ public static AzureOperationResponse CreateCloudPoolGetResponse(ProxyModels.CloudPool pool)
+ {
+ var response = new AzureOperationResponse();
+ response.Response = new HttpResponseMessage(HttpStatusCode.OK);
response.Body = pool;
-
return response;
}
@@ -552,6 +557,50 @@ public static RequestInterceptor ExamineRequestInterceptor(Action assertAc
return response;
}
+ ///
+ /// Builds a ComputeNodeExtensionGetResponse object
+ ///
+ public static AzureOperationResponse CreateComputeNodeExtensionGetResponse(Azure.Batch.VMExtension extension)
+ {
+ var response = new AzureOperationResponse();
+ response.Response = new HttpResponseMessage(HttpStatusCode.OK);
+
+ ProxyModels.NodeVMExtension proxyExtension = CreateProxyExtension(extension);
+ response.Body = proxyExtension;
+
+ return response;
+ }
+
+ ///
+ /// Builds a ComputeNodeExtensionListResponse object
+ ///
+ public static AzureOperationResponse, ProxyModels.ComputeNodeExtensionListHeaders> CreateComputeNodeExtensionListResponse(IEnumerable extensions)
+ {
+ var response = new AzureOperationResponse, ProxyModels.ComputeNodeExtensionListHeaders>();
+ response.Response = new HttpResponseMessage(HttpStatusCode.OK);
+
+ List proxyExtensions = new List();
+
+ foreach (Azure.Batch.VMExtension extension in extensions)
+ {
+ ProxyModels.NodeVMExtension proxyExtension = CreateProxyExtension(extension);
+ proxyExtensions.Add(proxyExtension);
+ }
+
+ response.Body = new MockPagedEnumerable(proxyExtensions);
+
+ return response;
+ }
+
+ private static ProxyModels.NodeVMExtension CreateProxyExtension(Azure.Batch.VMExtension extension)
+ {
+ ProxyModels.NodeVMExtension proxyExtension = new ProxyModels.NodeVMExtension();
+ proxyExtension.InstanceView = new ProxyModels.VMExtensionInstanceView();
+ proxyExtension.VmExtension = new ProxyModels.VMExtension(extension.Name, extension.Publisher, extension.Type);
+ proxyExtension.ProvisioningState = ProvisioningState.Succeeded.ToString();
+ return proxyExtension;
+ }
+
///
/// Builds a CloudJobScheduleGetResponse object
///
@@ -707,20 +756,33 @@ public static AzureOperationResponse<
///
/// Builds a TaskCountsGetResponse object
///
- public static AzureOperationResponse CreateTaskCountsGetResponse(
- int active, int running, int succeeded, int failed)
+ public static AzureOperationResponse CreateTaskCountsGetResponse(
+ int requiredTaskSlots, int activeTasks, int runningTasks, int succeededTasks, int failedTasks)
{
- var response = new AzureOperationResponse();
+ var response = new AzureOperationResponse();
response.Response = new HttpResponseMessage(HttpStatusCode.OK);
+ var completedTasks = succeededTasks + failedTasks;
+
ProxyModels.TaskCounts taskCounts = new ProxyModels.TaskCounts();
- taskCounts.Active = active;
- taskCounts.Running = running;
- taskCounts.Succeeded = succeeded;
- taskCounts.Failed = failed;
- taskCounts.Completed = succeeded + failed;
+ taskCounts.Active = activeTasks;
+ taskCounts.Running = runningTasks;
+ taskCounts.Succeeded = succeededTasks;
+ taskCounts.Failed = failedTasks;
+ taskCounts.Completed = completedTasks;
+
+ ProxyModels.TaskSlotCounts slotCount = new ProxyModels.TaskSlotCounts();
+ slotCount.Active = requiredTaskSlots * activeTasks;
+ slotCount.Running = requiredTaskSlots * runningTasks;
+ slotCount.Succeeded = requiredTaskSlots * succeededTasks;
+ slotCount.Failed = requiredTaskSlots * failedTasks;
+ slotCount.Completed = requiredTaskSlots * completedTasks;
+
+ ProxyModels.TaskCountsResult result = new ProxyModels.TaskCountsResult();
+ result.TaskCounts = taskCounts;
+ result.TaskSlotCounts = slotCount;
- response.Body = taskCounts;
+ response.Body = result;
return response;
}
diff --git a/src/Batch/Batch.Test/ComputeNodeExtensions/GetBatchComputeNodeExtensionCommandTests.cs b/src/Batch/Batch.Test/ComputeNodeExtensions/GetBatchComputeNodeExtensionCommandTests.cs
new file mode 100644
index 000000000000..c0405cc23944
--- /dev/null
+++ b/src/Batch/Batch.Test/ComputeNodeExtensions/GetBatchComputeNodeExtensionCommandTests.cs
@@ -0,0 +1,218 @@
+// ----------------------------------------------------------------------------------
+//
+// Copyright Microsoft Corporation
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// ----------------------------------------------------------------------------------
+
+using Microsoft.Azure.Batch;
+using Microsoft.Azure.Batch.Protocol;
+using Microsoft.Azure.Commands.Batch.Models;
+using Microsoft.Rest.Azure;
+using Microsoft.WindowsAzure.Commands.ScenarioTest;
+using Moq;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Management.Automation;
+using System.Threading.Tasks;
+using Xunit;
+using BatchClient = Microsoft.Azure.Commands.Batch.Models.BatchClient;
+using ProxyModels = Microsoft.Azure.Batch.Protocol.Models;
+
+namespace Microsoft.Azure.Commands.Batch.Test.ComputeNodeExtensions
+{
+ public class GetBatchComputeNodeExtensionCommandTests : WindowsAzure.Commands.Test.Utilities.Common.RMTestBase
+ {
+ private GetBatchComputeNodeExtensionCommand cmdlet;
+ private Mock batchClientMock;
+ private Mock commandRuntimeMock;
+
+ public GetBatchComputeNodeExtensionCommandTests(Xunit.Abstractions.ITestOutputHelper output)
+ {
+ ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagement.Common.Models.XunitTracingInterceptor(output));
+ batchClientMock = new Mock();
+ commandRuntimeMock = new Mock();
+ cmdlet = new GetBatchComputeNodeExtensionCommand()
+ {
+ CommandRuntime = commandRuntimeMock.Object,
+ BatchClient = batchClientMock.Object,
+ };
+ }
+
+ [Fact]
+ [Trait(Category.AcceptanceType, Category.CheckIn)]
+ public void GetBatchComputeNodeExtensionTest()
+ {
+ string extensionName = "testExtension";
+ string publisher = "testPublisher";
+ string type = "testType";
+
+ // Setup cmdlet to get a compute node by id
+ BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
+ cmdlet.BatchContext = context;
+ cmdlet.PoolId = "testPool";
+ cmdlet.ComputeNodeId = "testComputeNode";
+ cmdlet.Name = extensionName;
+
+ VMExtension extension = new VMExtension(extensionName, publisher, type);
+
+ // Build an extension instead of querying the service on a Get ComputeNodeExtension call
+ AzureOperationResponse response = BatchTestHelpers.CreateComputeNodeExtensionGetResponse(extension);
+ RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<
+ ProxyModels.ComputeNodeExtensionGetOptions,
+ AzureOperationResponse>(response);
+
+ cmdlet.AdditionalBehaviors = new List() { interceptor };
+
+ // Setup the cmdlet to write pipeline output to a list that can be examined later
+ List pipeline = new List();
+ commandRuntimeMock.Setup(r => r.WriteObject(It.IsAny())).Callback