Skip to content

Commit 07f9d34

Browse files
authored
Merge pull request #10001 from matthchr/feature/more-preview-stuff
Update Batch preview module to support data plane API version 2019-08-01.10.0 and mgmt API version 2019-08-01
2 parents 44c86d9 + f173f25 commit 07f9d34

File tree

136 files changed

+701145
-5756
lines changed

Some content is hidden

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

136 files changed

+701145
-5756
lines changed

src/Batch/Batch.Test/Batch.Test.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
</PropertyGroup>
1515

1616
<ItemGroup>
17-
<PackageReference Include="Microsoft.Azure.Batch" Version="10.1.0" />
18-
<PackageReference Include="Microsoft.Azure.Management.Batch" Version="7.0.0" />
17+
<PackageReference Include="Microsoft.Azure.Batch" Version="12.0.0" />
18+
<PackageReference Include="Microsoft.Azure.Management.Batch" Version="9.0.0" />
1919
<PackageReference Include="WindowsAzure.Storage" Version="9.3.0" />
2020
</ItemGroup>
2121

src/Batch/Batch.Test/BatchAccounts/GetBatchNodeAgentSkusCommandTests.cs renamed to src/Batch/Batch.Test/BatchAccounts/GetBatchSupportedImagesCommandTests.cs

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@
2828

2929
namespace Microsoft.Azure.Commands.Batch.Test.Accounts
3030
{
31-
public class GetBatchNodeAgentSkusCommandTests : WindowsAzure.Commands.Test.Utilities.Common.RMTestBase
31+
public class GetBatchSupportedImagesCommandTests : WindowsAzure.Commands.Test.Utilities.Common.RMTestBase
3232
{
33-
private GetBatchAccountNodeAgentSkuCommand cmdlet;
33+
private GetBatchAccountSupportedImagesCommand cmdlet;
3434
private Mock<BatchClient> batchClientMock;
3535
private Mock<ICommandRuntime> commandRuntimeMock;
3636

37-
public GetBatchNodeAgentSkusCommandTests(Xunit.Abstractions.ITestOutputHelper output)
37+
public GetBatchSupportedImagesCommandTests(Xunit.Abstractions.ITestOutputHelper output)
3838
{
3939
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagement.Common.Models.XunitTracingInterceptor(output));
4040
batchClientMock = new Mock<BatchClient>();
4141
commandRuntimeMock = new Mock<ICommandRuntime>();
42-
cmdlet = new GetBatchAccountNodeAgentSkuCommand()
42+
cmdlet = new GetBatchAccountSupportedImagesCommand()
4343
{
4444
CommandRuntime = commandRuntimeMock.Object,
4545
BatchClient = batchClientMock.Object,
@@ -48,45 +48,45 @@ public GetBatchNodeAgentSkusCommandTests(Xunit.Abstractions.ITestOutputHelper ou
4848

4949
[Fact]
5050
[Trait(Category.AcceptanceType, Category.CheckIn)]
51-
public void ListBatchNodeAgentSkusParametersTest()
51+
public void ListBatchSupportedImagesParametersTest()
5252
{
5353
BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
5454
cmdlet.BatchContext = context;
5555

5656
string[] idsOfNodeAgentSkus = new[] { "batch.node.centos 7", "batch.node.debian 8", "batch.node.opensuse 13.2" };
5757

5858
// Don't go to the service on an Get NodeAgentSkus call
59-
AzureOperationResponse<IPage<ProxyModels.NodeAgentSku>, ProxyModels.AccountListNodeAgentSkusHeaders> response =
60-
BatchTestHelpers.CreateNodeAgentSkuResponse(idsOfNodeAgentSkus);
59+
AzureOperationResponse<IPage<ProxyModels.ImageInformation>, ProxyModels.AccountListSupportedImagesHeaders> response =
60+
BatchTestHelpers.CreateSupportedImagesResponse(idsOfNodeAgentSkus);
6161

6262
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<
63-
ProxyModels.AccountListNodeAgentSkusOptions,
64-
AzureOperationResponse<IPage<ProxyModels.NodeAgentSku>, ProxyModels.AccountListNodeAgentSkusHeaders>>(responseToUse: response);
63+
ProxyModels.AccountListSupportedImagesOptions,
64+
AzureOperationResponse<IPage<ProxyModels.ImageInformation>, ProxyModels.AccountListSupportedImagesHeaders>>(responseToUse: response);
6565

6666
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
6767

6868
// Setup the cmdlet to write pipeline output to a list that can be examined later
69-
List<PSNodeAgentSku> pipeline = new List<PSNodeAgentSku>();
69+
var pipeline = new List<PSImageInformation>();
7070
commandRuntimeMock.Setup(r =>
71-
r.WriteObject(It.IsAny<PSNodeAgentSku>()))
72-
.Callback<object>(p => pipeline.Add((PSNodeAgentSku)p));
71+
r.WriteObject(It.IsAny<PSImageInformation>()))
72+
.Callback<object>(p => pipeline.Add((PSImageInformation)p));
7373

7474
// Verify no exceptions when required parameter is set
7575
cmdlet.ExecuteCmdlet();
7676

7777
Assert.Equal(3, pipeline.Count);
7878
int nodeAgentCount = 0;
79-
foreach (PSNodeAgentSku p in pipeline)
79+
foreach (PSImageInformation imageInfo in pipeline)
8080
{
81-
Assert.Contains(p.Id, idsOfNodeAgentSkus);
81+
Assert.Contains(imageInfo.NodeAgentSkuId, idsOfNodeAgentSkus);
8282
nodeAgentCount++;
8383
}
8484
Assert.Equal(idsOfNodeAgentSkus.Length, nodeAgentCount);
8585
}
8686

8787
[Fact]
8888
[Trait(Category.AcceptanceType, Category.CheckIn)]
89-
public void ListBatchNodeAgentSkusWithFilterTest()
89+
public void ListBatchSupportedImagesWithFilterTest()
9090
{
9191
BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
9292
cmdlet.BatchContext = context;
@@ -95,11 +95,14 @@ public void ListBatchNodeAgentSkusWithFilterTest()
9595
string requestFilter = null;
9696

9797
// Don't go to the service on an Get NodeAgentSkus call
98-
AzureOperationResponse<IPage<ProxyModels.NodeAgentSku>, ProxyModels.AccountListNodeAgentSkusHeaders> getResponse = BatchTestHelpers.CreateGenericAzureOperationListResponse<ProxyModels.NodeAgentSku, ProxyModels.AccountListNodeAgentSkusHeaders>();
99-
RequestInterceptor requestInterceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<ProxyModels.AccountListNodeAgentSkusOptions, AzureOperationResponse<IPage<ProxyModels.NodeAgentSku>, ProxyModels.AccountListNodeAgentSkusHeaders>>(responseToUse: getResponse);
98+
var getResponse = BatchTestHelpers.CreateGenericAzureOperationListResponse<ProxyModels.ImageInformation, ProxyModels.AccountListSupportedImagesHeaders>();
99+
RequestInterceptor requestInterceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<
100+
ProxyModels.AccountListSupportedImagesOptions,
101+
AzureOperationResponse<IPage<ProxyModels.ImageInformation>,
102+
ProxyModels.AccountListSupportedImagesHeaders>>(responseToUse: getResponse);
100103
ResponseInterceptor responseInterceptor = new ResponseInterceptor((response, request) =>
101104
{
102-
ProxyModels.AccountListNodeAgentSkusOptions listNodeAgentSkusOptions = (ProxyModels.AccountListNodeAgentSkusOptions)request.Options;
105+
var listNodeAgentSkusOptions = (ProxyModels.AccountListSupportedImagesOptions)request.Options;
103106
requestFilter = listNodeAgentSkusOptions.Filter;
104107

105108
return Task.FromResult(response);

src/Batch/Batch.Test/BatchTestHelpers.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,14 @@ public static class BatchTestHelpers
4848
/// <summary>
4949
/// Builds an AccountResource object using the specified parameters
5050
/// </summary>
51-
public static BatchAccount CreateAccountResource(string accountName, string resourceGroupName, string location = "location",
52-
Hashtable tags = null, string storageId = null)
51+
public static BatchAccount CreateAccountResource(
52+
string accountName,
53+
string resourceGroupName,
54+
string location = "location",
55+
Hashtable tags = null,
56+
string storageId = null,
57+
bool dedicatedCoreQuotaPerVMFamilyEnforced = false,
58+
IList<VirtualMachineFamilyCoreQuota> machineFamilyQuotas = null)
5359
{
5460
string tenantUrlEnding = "batch-test.windows-int.net";
5561
string endpoint = string.Format("{0}.{1}", accountName, tenantUrlEnding);
@@ -58,6 +64,8 @@ public static BatchAccount CreateAccountResource(string accountName, string reso
5864

5965
string id = string.Format("id/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Batch/batchAccounts/abc", subscription, resourceGroup);
6066

67+
machineFamilyQuotas = machineFamilyQuotas ?? new List<VirtualMachineFamilyCoreQuota> { new VirtualMachineFamilyCoreQuota("foo", 55 ) };
68+
6169
BatchAccount resource = new BatchAccount(
6270
dedicatedCoreQuota: DefaultQuotaCount,
6371
lowPriorityCoreQuota: DefaultQuotaCount,
@@ -69,7 +77,9 @@ public static BatchAccount CreateAccountResource(string accountName, string reso
6977
location: location,
7078
provisioningState: ProvisioningState.Succeeded,
7179
autoStorage: new AutoStorageProperties() { StorageAccountId = storageId },
72-
tags: tags == null ? null : TagsConversionHelper.CreateTagDictionary(tags, true));
80+
tags: tags == null ? null : TagsConversionHelper.CreateTagDictionary(tags, true),
81+
dedicatedCoreQuotaPerVMFamilyEnforced: dedicatedCoreQuotaPerVMFamilyEnforced,
82+
dedicatedCoreQuotaPerVMFamily: machineFamilyQuotas);
7383

7484
return resource;
7585
}
@@ -796,15 +806,15 @@ public static AzureOperationResponse<
796806
/// <summary>
797807
/// Builds a NodeAgentSKUResponse object
798808
/// </summary>
799-
public static AzureOperationResponse<IPage<ProxyModels.NodeAgentSku>, ProxyModels.AccountListNodeAgentSkusHeaders> CreateNodeAgentSkuResponse(IEnumerable<string> skuIds)
809+
public static AzureOperationResponse<IPage<ProxyModels.ImageInformation>, ProxyModels.AccountListSupportedImagesHeaders> CreateSupportedImagesResponse(IEnumerable<string> skuIds)
800810
{
801-
IEnumerable<ProxyModels.NodeAgentSku> nodeAgents =
802-
skuIds.Select(id => new ProxyModels.NodeAgentSku() { Id = id });
811+
IEnumerable<ProxyModels.ImageInformation> imageInfo =
812+
skuIds.Select(id => new ProxyModels.ImageInformation() { NodeAgentSKUId = id });
803813

804-
var response = new AzureOperationResponse<IPage<ProxyModels.NodeAgentSku>, ProxyModels.AccountListNodeAgentSkusHeaders>()
814+
var response = new AzureOperationResponse<IPage<ProxyModels.ImageInformation>, ProxyModels.AccountListSupportedImagesHeaders>()
805815
{
806816
Response = new HttpResponseMessage(HttpStatusCode.OK),
807-
Body = new MockPagedEnumerable<ProxyModels.NodeAgentSku>(nodeAgents)
817+
Body = new MockPagedEnumerable<ProxyModels.ImageInformation>(imageInfo)
808818
};
809819

810820
return response;

src/Batch/Batch.Test/Pools/NewBatchPoolCommandTests.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public void NewBatchPoolParametersGetPassedToRequestTest()
103103
cmdlet.TaskSchedulingPolicy = new PSTaskSchedulingPolicy(Azure.Batch.Common.ComputeNodeFillType.Spread);
104104
cmdlet.VirtualMachineConfiguration = new PSVirtualMachineConfiguration(new PSImageReference("offer", "publisher", "sku"), "node agent");
105105
cmdlet.VirtualMachineSize = "small";
106+
cmdlet.MountConfiguration = new[] { new PSMountConfiguration(new PSAzureBlobFileSystemConfiguration("foo", "bar", "baz", AzureStorageAuthenticationKey.FromAccountKey("abc"))) };
106107

107108
PoolAddParameter requestParameters = null;
108109

@@ -142,6 +143,10 @@ public void NewBatchPoolParametersGetPassedToRequestTest()
142143
Assert.Equal(cmdlet.VirtualMachineConfiguration.ImageReference.Offer, requestParameters.VirtualMachineConfiguration.ImageReference.Offer);
143144
Assert.Equal(cmdlet.VirtualMachineConfiguration.ImageReference.Sku, requestParameters.VirtualMachineConfiguration.ImageReference.Sku);
144145
Assert.Equal(cmdlet.VirtualMachineSize, requestParameters.VmSize);
146+
Assert.Equal(cmdlet.MountConfiguration[0].AzureBlobFileSystemConfiguration.AccountName, requestParameters.MountConfiguration[0].AzureBlobFileSystemConfiguration.AccountName);
147+
Assert.Equal(cmdlet.MountConfiguration[0].AzureBlobFileSystemConfiguration.AccountKey, requestParameters.MountConfiguration[0].AzureBlobFileSystemConfiguration.AccountKey);
148+
Assert.Equal(cmdlet.MountConfiguration[0].AzureBlobFileSystemConfiguration.ContainerName, requestParameters.MountConfiguration[0].AzureBlobFileSystemConfiguration.ContainerName);
149+
Assert.Equal(cmdlet.MountConfiguration[0].AzureBlobFileSystemConfiguration.RelativeMountPath, requestParameters.MountConfiguration[0].AzureBlobFileSystemConfiguration.RelativeMountPath);
145150
}
146151

147152
[Fact]

src/Batch/Batch.Test/ScenarioTests/BatchAccountTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ public void TestBatchAccountEndToEnd()
3737

3838
[Fact]
3939
[Trait(Category.AcceptanceType, Category.CheckIn)]
40-
public void TestListNodeAgentSkus()
40+
public void TestGetBatchSupportedImages()
4141
{
42-
BatchController.NewInstance.RunPsTest(_logger, "Test-GetBatchNodeAgentSkus");
42+
BatchController.NewInstance.RunPsTest(_logger, "Test-GetBatchSupportedImage");
4343
}
4444
}
4545
}

src/Batch/Batch.Test/ScenarioTests/BatchAccountTests.ps1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,19 +98,19 @@ function Test-BatchAccountEndToEnd
9898

9999
<#
100100
.SYNOPSIS
101-
Tests getting a list of Batch node agent skus
101+
Tests getting a list of Batch supported images
102102
#>
103-
function Test-GetBatchNodeAgentSkus
103+
function Test-GetBatchSupportedImage
104104
{
105105
$context = New-Object Microsoft.Azure.Commands.Batch.Test.ScenarioTests.ScenarioTestContext
106106

107107
# Get the node agent skus
108-
$nodeAgentSkus = Get-AzBatchNodeAgentSku -BatchContext $context
108+
$supportedImages = Get-AzBatchSupportedImage -BatchContext $context
109109

110-
foreach($nodeAgentSku in $nodeAgentSkus)
110+
foreach($supportedImage in $supportedImages)
111111
{
112-
Assert-True { $nodeAgentSku.Id.StartsWith("batch.node") }
113-
Assert-True { $nodeAgentSku.OSType -in "linux","windows" }
114-
Assert-AreNotEqual $null $nodeAgentSku.VerifiedImageReferences
112+
Assert-True { $supportedImage.NodeAgentSkuId.StartsWith("batch.node") }
113+
Assert-True { $supportedImage.OSType -in "linux","windows" }
114+
Assert-AreNotEqual $null $supportedImage.VerificationType
115115
}
116116
}

src/Batch/Batch.Test/ScenarioTests/CertificateTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void TestCancelCertificateDelete()
5252
() =>
5353
{
5454
context = new ScenarioTestContext();
55-
thumbprint = ScenarioTestHelpers.AddTestCertificate(controller, context, BatchTestHelpers.TestCertificateFileName);
55+
thumbprint = ScenarioTestHelpers.AddTestCertificate(controller, context, BatchTestHelpers.TestCertificateFileName).ToLowerInvariant();
5656
CertificateReference certRef = new CertificateReference();
5757
certRef.StoreLocation = CertStoreLocation.CurrentUser;
5858
certRef.StoreName = "My";

src/Batch/Batch.Test/ScenarioTests/CertificateTests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,5 @@ function Test-TestCancelCertificateDelete
6767
$filter = "state eq 'active'"
6868
$cert = Get-AzBatchCertificate -Filter $filter -BatchContext $context
6969

70-
Assert-AreEqual $thumbprint $cert.Thumbprint
70+
Assert-AreEqual $thumbprint $cert.Thumbprint.ToLowerInvariant()
7171
}

0 commit comments

Comments
 (0)