Skip to content

[Batch] 2020-05-01 API Release #12103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Batch/Batch.Test/Batch.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Batch" Version="13.0.0" />
<PackageReference Include="Microsoft.Azure.Management.Batch" Version="10.0.0" />
<PackageReference Include="Microsoft.Azure.Management.Batch" Version="11.0.0" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.0" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="19.21.1-preview" />
</ItemGroup>
Expand Down
19 changes: 19 additions & 0 deletions src/Batch/Batch.Test/BatchAccounts/GetBatchAccountCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,24 @@ public void GetBatchAccountTest()

commandRuntimeMock.Verify(r => r.WriteObject(expected), Times.Once());
}


[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
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));
BatchAccountContext expected = BatchAccountContext.ConvertAccountResourceToNewAccountContext(accountResource, null);
batchClientMock.Setup(b => b.GetAccount(resourceGroup, accountName)).Returns(expected);

cmdlet.AccountName = accountName;
cmdlet.ResourceGroupName = resourceGroup;

cmdlet.ExecuteCmdlet();

commandRuntimeMock.Verify(r => r.WriteObject(expected), Times.Once());
}
}
}
8 changes: 5 additions & 3 deletions src/Batch/Batch.Test/BatchTestHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public static BatchAccount CreateAccountResource(
Hashtable tags = null,
string storageId = null,
bool dedicatedCoreQuotaPerVMFamilyEnforced = false,
IList<VirtualMachineFamilyCoreQuota> machineFamilyQuotas = null)
IList<VirtualMachineFamilyCoreQuota> machineFamilyQuotas = null,
BatchAccountIdentity identity = null)
{
string tenantUrlEnding = "batch-test.windows-int.net";
string endpoint = string.Format("{0}.{1}", accountName, tenantUrlEnding);
Expand All @@ -79,7 +80,8 @@ public static BatchAccount CreateAccountResource(
autoStorage: new AutoStorageProperties() { StorageAccountId = storageId },
tags: tags == null ? null : TagsConversionHelper.CreateTagDictionary(tags, true),
dedicatedCoreQuotaPerVMFamilyEnforced: dedicatedCoreQuotaPerVMFamilyEnforced,
dedicatedCoreQuotaPerVMFamily: machineFamilyQuotas);
dedicatedCoreQuotaPerVMFamily: machineFamilyQuotas,
identity: identity ?? new BatchAccountIdentity(ResourceIdentityType.None));

return resource;
}
Expand Down Expand Up @@ -710,7 +712,7 @@ public static AzureOperationResponse<
{
var response = new AzureOperationResponse<ProxyModels.TaskCounts, ProxyModels.JobGetTaskCountsHeaders>();
response.Response = new HttpResponseMessage(HttpStatusCode.OK);

ProxyModels.TaskCounts taskCounts = new ProxyModels.TaskCounts();
taskCounts.Active = active;
taskCounts.Running = running;
Expand Down
7 changes: 7 additions & 0 deletions src/Batch/Batch.Test/ScenarioTests/BatchAccountTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,12 @@ public void TestCreateNewBatchAccountWithNoPublicIp()
{
BatchController.NewInstance.RunPsTest(_logger, "Test-CreateNewBatchAccountWithNoPublicIp");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateNewBatchAccountWithSystemIdentity()
{
BatchController.NewInstance.RunPsTest(_logger, "Test-CreateNewBatchAccountWithSystemIdentity");
}
}
}
32 changes: 30 additions & 2 deletions src/Batch/Batch.Test/ScenarioTests/BatchAccountTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function Test-BatchAccountEndToEnd
$accountName = Get-BatchAccountName
$resourceGroup = Get-ResourceGroupName

try
try
{
$location = Get-BatchAccountProviderLocation
$tagName = "tag1"
Expand All @@ -43,12 +43,13 @@ function Test-BatchAccountEndToEnd

# Verify the properties match expectations
Assert-AreEqual $accountName $createdAccount.AccountName
Assert-AreEqual $resourceGroup $createdAccount.ResourceGroupName
Assert-AreEqual $resourceGroup $createdAccount.ResourceGroupName
Assert-AreEqual $location $createdAccount.Location
Assert-AreEqual 1 $createdAccount.Tags.Count
Assert-AreEqual $tagValue $createdAccount.Tags[$tagName]
Assert-True { $createdAccount.PoolQuota -gt 0 }
Assert-True { $createdAccount.ActiveJobAndJobScheduleQuota -gt 0 }
Assert-AreEqual "None" $createdAccount.Identity.Type

# Update the Batch account
$newTagName = "tag2"
Expand Down Expand Up @@ -145,4 +146,31 @@ function Test-CreateNewBatchAccountWithNoPublicIp
{
Remove-AzResourceGroup $resourceGroup
}
}

<#
.SYNOPSIS
Tests creating an account with identity set to Microsoft.KeyVault
#>
function Test-CreateNewBatchAccountWithSystemIdentity
{
# Setup
$accountName = Get-BatchAccountName
$resourceGroup = Get-ResourceGroupName

try
{
$location = Get-BatchAccountProviderLocation
# Create a Batch account
New-AzResourceGroup -Name $resourceGroup -Location $location
$createdAccount = New-AzBatchAccount -Name $accountName -ResourceGroupName $resourceGroup -Location $location -IdentityType "SystemAssigned"

Assert-AreEqual $createdAccount.Identity.Type "SystemAssigned"
Assert-NotNull $createdAccount.Identity.TenantId
Assert-NotNull $createdAccount.Identity.PrincipalId
}
finally
{
Remove-AzResourceGroup $resourceGroup
}
}
10 changes: 5 additions & 5 deletions src/Batch/Batch.Test/ScenarioTests/Common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ function Get-BatchAccountProviderLocation($index)
$location = $r.Locations

if ($location -eq $null)
{
{
return "westus"
}
else
{
}
else
{
if ($index -eq $null)
{
return "westus"
Expand All @@ -82,7 +82,7 @@ function Get-BatchAccountProviderLocation($index)
{
return $location[$index]
}
}
}
}

return "westus"
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading