Skip to content

Commit d98850b

Browse files
authored
[Batch] 2020-05-01 API Release (#12103)
* update to mgmt ver 11 * update changelog, fix test * update docs * simplify Identity pararm type, rerecord * reference network csproj in sln * update
1 parent 43ae2ac commit d98850b

File tree

45 files changed

+17811
-12688
lines changed

Some content is hidden

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

45 files changed

+17811
-12688
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<ItemGroup>
1717
<PackageReference Include="Microsoft.Azure.Batch" Version="13.0.0" />
18-
<PackageReference Include="Microsoft.Azure.Management.Batch" Version="10.0.0" />
18+
<PackageReference Include="Microsoft.Azure.Management.Batch" Version="11.0.0" />
1919
<PackageReference Include="WindowsAzure.Storage" Version="9.3.0" />
2020
<PackageReference Include="Microsoft.Azure.Management.Network" Version="19.21.1-preview" />
2121
</ItemGroup>

src/Batch/Batch.Test/BatchAccounts/GetBatchAccountCommandTests.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,24 @@ public void GetBatchAccountTest()
8484

8585
commandRuntimeMock.Verify(r => r.WriteObject(expected), Times.Once());
8686
}
87+
88+
89+
[Fact]
90+
[Trait(Category.AcceptanceType, Category.CheckIn)]
91+
public void GetBatchAccount_IdentityTest()
92+
{
93+
string accountName = "account01";
94+
string resourceGroup = "resourceGroup";
95+
BatchAccount accountResource = BatchTestHelpers.CreateAccountResource(accountName, resourceGroup, identity: new BatchAccountIdentity(ResourceIdentityType.None, string.Empty, string.Empty));
96+
BatchAccountContext expected = BatchAccountContext.ConvertAccountResourceToNewAccountContext(accountResource, null);
97+
batchClientMock.Setup(b => b.GetAccount(resourceGroup, accountName)).Returns(expected);
98+
99+
cmdlet.AccountName = accountName;
100+
cmdlet.ResourceGroupName = resourceGroup;
101+
102+
cmdlet.ExecuteCmdlet();
103+
104+
commandRuntimeMock.Verify(r => r.WriteObject(expected), Times.Once());
105+
}
87106
}
88107
}

src/Batch/Batch.Test/BatchTestHelpers.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ public static BatchAccount CreateAccountResource(
5555
Hashtable tags = null,
5656
string storageId = null,
5757
bool dedicatedCoreQuotaPerVMFamilyEnforced = false,
58-
IList<VirtualMachineFamilyCoreQuota> machineFamilyQuotas = null)
58+
IList<VirtualMachineFamilyCoreQuota> machineFamilyQuotas = null,
59+
BatchAccountIdentity identity = null)
5960
{
6061
string tenantUrlEnding = "batch-test.windows-int.net";
6162
string endpoint = string.Format("{0}.{1}", accountName, tenantUrlEnding);
@@ -79,7 +80,8 @@ public static BatchAccount CreateAccountResource(
7980
autoStorage: new AutoStorageProperties() { StorageAccountId = storageId },
8081
tags: tags == null ? null : TagsConversionHelper.CreateTagDictionary(tags, true),
8182
dedicatedCoreQuotaPerVMFamilyEnforced: dedicatedCoreQuotaPerVMFamilyEnforced,
82-
dedicatedCoreQuotaPerVMFamily: machineFamilyQuotas);
83+
dedicatedCoreQuotaPerVMFamily: machineFamilyQuotas,
84+
identity: identity ?? new BatchAccountIdentity(ResourceIdentityType.None));
8385

8486
return resource;
8587
}
@@ -710,7 +712,7 @@ public static AzureOperationResponse<
710712
{
711713
var response = new AzureOperationResponse<ProxyModels.TaskCounts, ProxyModels.JobGetTaskCountsHeaders>();
712714
response.Response = new HttpResponseMessage(HttpStatusCode.OK);
713-
715+
714716
ProxyModels.TaskCounts taskCounts = new ProxyModels.TaskCounts();
715717
taskCounts.Active = active;
716718
taskCounts.Running = running;

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,12 @@ public void TestCreateNewBatchAccountWithNoPublicIp()
4848
{
4949
BatchController.NewInstance.RunPsTest(_logger, "Test-CreateNewBatchAccountWithNoPublicIp");
5050
}
51+
52+
[Fact]
53+
[Trait(Category.AcceptanceType, Category.CheckIn)]
54+
public void TestCreateNewBatchAccountWithSystemIdentity()
55+
{
56+
BatchController.NewInstance.RunPsTest(_logger, "Test-CreateNewBatchAccountWithSystemIdentity");
57+
}
5158
}
5259
}

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

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function Test-BatchAccountEndToEnd
3131
$accountName = Get-BatchAccountName
3232
$resourceGroup = Get-ResourceGroupName
3333

34-
try
34+
try
3535
{
3636
$location = Get-BatchAccountProviderLocation
3737
$tagName = "tag1"
@@ -43,12 +43,13 @@ function Test-BatchAccountEndToEnd
4343

4444
# Verify the properties match expectations
4545
Assert-AreEqual $accountName $createdAccount.AccountName
46-
Assert-AreEqual $resourceGroup $createdAccount.ResourceGroupName
46+
Assert-AreEqual $resourceGroup $createdAccount.ResourceGroupName
4747
Assert-AreEqual $location $createdAccount.Location
4848
Assert-AreEqual 1 $createdAccount.Tags.Count
4949
Assert-AreEqual $tagValue $createdAccount.Tags[$tagName]
5050
Assert-True { $createdAccount.PoolQuota -gt 0 }
5151
Assert-True { $createdAccount.ActiveJobAndJobScheduleQuota -gt 0 }
52+
Assert-AreEqual "None" $createdAccount.Identity.Type
5253

5354
# Update the Batch account
5455
$newTagName = "tag2"
@@ -145,4 +146,31 @@ function Test-CreateNewBatchAccountWithNoPublicIp
145146
{
146147
Remove-AzResourceGroup $resourceGroup
147148
}
149+
}
150+
151+
<#
152+
.SYNOPSIS
153+
Tests creating an account with identity set to Microsoft.KeyVault
154+
#>
155+
function Test-CreateNewBatchAccountWithSystemIdentity
156+
{
157+
# Setup
158+
$accountName = Get-BatchAccountName
159+
$resourceGroup = Get-ResourceGroupName
160+
161+
try
162+
{
163+
$location = Get-BatchAccountProviderLocation
164+
# Create a Batch account
165+
New-AzResourceGroup -Name $resourceGroup -Location $location
166+
$createdAccount = New-AzBatchAccount -Name $accountName -ResourceGroupName $resourceGroup -Location $location -IdentityType "SystemAssigned"
167+
168+
Assert-AreEqual $createdAccount.Identity.Type "SystemAssigned"
169+
Assert-NotNull $createdAccount.Identity.TenantId
170+
Assert-NotNull $createdAccount.Identity.PrincipalId
171+
}
172+
finally
173+
{
174+
Remove-AzResourceGroup $resourceGroup
175+
}
148176
}

src/Batch/Batch.Test/ScenarioTests/Common.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ function Get-BatchAccountProviderLocation($index)
6969
$location = $r.Locations
7070

7171
if ($location -eq $null)
72-
{
72+
{
7373
return "westus"
74-
}
75-
else
76-
{
74+
}
75+
else
76+
{
7777
if ($index -eq $null)
7878
{
7979
return "westus"
@@ -82,7 +82,7 @@ function Get-BatchAccountProviderLocation($index)
8282
{
8383
return $location[$index]
8484
}
85-
}
85+
}
8686
}
8787

8888
return "westus"

src/Batch/Batch.Test/SessionRecords/Microsoft.Azure.Commands.Batch.Test.ScenarioTests.BatchAccountTests/TestBatchAccountEndToEnd.json

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

src/Batch/Batch.Test/SessionRecords/Microsoft.Azure.Commands.Batch.Test.ScenarioTests.BatchAccountTests/TestCreateNewBatchAccountWithNoPublicIp.json

Lines changed: 13754 additions & 286 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)