Skip to content

Commit cc9860c

Browse files
merge with upstream
2 parents f31049d + 3730a9a commit cc9860c

File tree

142 files changed

+68462
-26425
lines changed

Some content is hidden

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

142 files changed

+68462
-26425
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@
4343
<Reference Include="Hyak.Common">
4444
<HintPath>..\..\..\packages\Hyak.Common.1.0.2\lib\portable-net403+win+wpa81\Hyak.Common.dll</HintPath>
4545
</Reference>
46-
<Reference Include="Microsoft.Azure.Batch, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
46+
<Reference Include="Microsoft.Azure.Batch, Version=2.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
4747
<SpecificVersion>False</SpecificVersion>
48-
<HintPath>..\..\..\packages\Azure.Batch.2.0.1\lib\net45\Microsoft.Azure.Batch.dll</HintPath>
48+
<HintPath>..\..\..\packages\Azure.Batch.2.0.2\lib\net45\Microsoft.Azure.Batch.dll</HintPath>
4949
</Reference>
5050
<Reference Include="Microsoft.Azure.Common">
5151
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.dll</HintPath>
@@ -64,7 +64,7 @@
6464
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
6565
</Reference>
6666
<Reference Include="Microsoft.Azure.Management.Batch">
67-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Batch.1.4.0\lib\net40\Microsoft.Azure.Management.Batch.dll</HintPath>
67+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Batch.1.5.0\lib\net40\Microsoft.Azure.Management.Batch.dll</HintPath>
6868
</Reference>
6969
<Reference Include="Microsoft.Azure.ResourceManager">
7070
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.7-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
@@ -216,10 +216,12 @@
216216
<Compile Include="ScenarioTests\JobTests.cs" />
217217
<Compile Include="ScenarioTests\PoolTests.cs" />
218218
<Compile Include="ScenarioTests\ScenarioTestHelpers.cs" />
219+
<Compile Include="ScenarioTests\SubscriptionTests.cs" />
219220
<Compile Include="ScenarioTests\TaskTests.cs" />
220221
<Compile Include="ScenarioTests\ComputeNodeUserTests.cs" />
221222
<Compile Include="ScenarioTests\ComputeNodeTests.cs" />
222223
<Compile Include="ScenarioTests\JobScheduleTests.cs" />
224+
<Compile Include="Subscriptions\GetBatchSubscriptionQuotasCommandTests.cs" />
223225
<Compile Include="Tasks\GetBatchTaskCommandTests.cs" />
224226
<Compile Include="Tasks\NewBatchTaskCommandTests.cs" />
225227
<Compile Include="Tasks\RemoveBatchTaskCommandTests.cs" />
@@ -270,6 +272,9 @@
270272
<None Include="ScenarioTests\PoolTests.ps1">
271273
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
272274
</None>
275+
<None Include="ScenarioTests\SubscriptionTests.ps1">
276+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
277+
</None>
273278
<None Include="ScenarioTests\TaskTests.ps1">
274279
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
275280
</None>
@@ -561,6 +566,9 @@
561566
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.PoolTests\TestUpdatePool.json">
562567
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
563568
</None>
569+
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.SubscriptionTests\TestGetSubscriptionQuotas.json">
570+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
571+
</None>
564572
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.TaskTests\TestCreateTask.json">
565573
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
566574
</None>

src/ResourceManager/AzureBatch/Commands.Batch.Test/ScenarioTests/BatchAccountTests.ps1

Lines changed: 76 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Tests creating new Batch account.
2828
function Test-CreatesNewBatchAccount
2929
{
3030
# Setup
31-
$account = Get-BatchAccountName
31+
$account = Get-BatchAccountName
3232
$resourceGroup = Get-ResourceGroupName
3333
$location = Get-BatchAccountProviderLocation
3434

@@ -41,11 +41,14 @@ function Test-CreatesNewBatchAccount
4141
$expected = Get-AzureRmBatchAccount -Name $account -ResourceGroupName $resourceGroup
4242

4343
# Assert
44-
Assert-AreEqual $expected.AccountName $actual.AccountName
44+
Assert-AreEqual $expected.AccountName $actual.AccountName
4545
Assert-AreEqual $expected.ResourceGroupName $actual.ResourceGroupName
46-
Assert-AreEqual $expected.Location $actual.Location
46+
Assert-AreEqual $expected.Location $actual.Location
4747
Assert-AreEqual $expected.Tags[0]["Name"] $actual.Tags[0]["Name"]
48-
Assert-AreEqual $expected.Tags[0]["Value"] $actual.Tags[0]["Value"]
48+
Assert-AreEqual $expected.Tags[0]["Value"] $actual.Tags[0]["Value"]
49+
Assert-True { $actual.CoreQuota -gt 0 }
50+
Assert-True { $actual.PoolQuota -gt 0 }
51+
Assert-True { $actual.ActiveJobAndJobScheduleQuota -gt 0 }
4952
}
5053
finally
5154
{
@@ -61,7 +64,7 @@ Tests creating an account that already exists throws
6164
function Test-CreateExistingBatchAccount
6265
{
6366
# Setup
64-
$account = Get-BatchAccountName
67+
$account = Get-BatchAccountName
6568
$resourceGroup = Get-ResourceGroupName
6669
$location = Get-BatchAccountProviderLocation
6770

@@ -88,36 +91,36 @@ Tests updating existing Batch account
8891
function Test-UpdatesExistingBatchAccount
8992
{
9093
# Setup
91-
$account = Get-BatchAccountName
94+
$account = Get-BatchAccountName
9295
$resourceGroup = Get-ResourceGroupName
9396
$location = Get-BatchAccountProviderLocation
9497

95-
$tagName1 = "testtag1"
96-
$tagValue1 = "testval1"
97-
$tagName2 = "testtag2"
98-
$tagValue2 = "testval2"
98+
$tagName1 = "testtag1"
99+
$tagValue1 = "testval1"
100+
$tagName2 = "testtag2"
101+
$tagValue2 = "testval2"
99102

100103
try
101104
{
102105
New-AzureRmResourceGroup -Name $resourceGroup -Location $location
103106

104-
#Test
107+
#Test
105108
$new = New-AzureRmBatchAccount -Name $account -ResourceGroupName $resourceGroup -Location $location -Tag @{Name = $tagName1; Value = $tagValue1}
106-
Assert-AreEqual 1 $new.Tags.Count
109+
Assert-AreEqual 1 $new.Tags.Count
107110

108-
# Update Tag
111+
# Update Tag
109112
$actual = Set-AzureRmBatchAccount -Name $account -ResourceGroupName $resourceGroup -Tag @{Name = $tagName2; Value = $tagValue2}
110113
$expected = Get-AzureRmBatchAccount -Name $account -ResourceGroupName $resourceGroup
111114

112115
# Assert
113-
Assert-AreEqual $expected.AccountName $actual.AccountName
116+
Assert-AreEqual $expected.AccountName $actual.AccountName
114117
Assert-AreEqual $expected.ResourceGroupName $actual.ResourceGroupName
115-
Assert-AreEqual $expected.Location $actual.Location
116-
Assert-AreEqual 1 $expected.Tags.Count
117-
Assert-AreEqual $tagName2 $expected.Tags[0]["Name"]
118-
Assert-AreEqual $tagValue2 $expected.Tags[0]["Value"]
118+
Assert-AreEqual $expected.Location $actual.Location
119+
Assert-AreEqual 1 $expected.Tags.Count
120+
Assert-AreEqual $tagName2 $expected.Tags[0]["Name"]
121+
Assert-AreEqual $tagValue2 $expected.Tags[0]["Value"]
119122
Assert-AreEqual $expected.Tags[0]["Name"] $actual.Tags[0]["Name"]
120-
Assert-AreEqual $expected.Tags[0]["Value"] $actual.Tags[0]["Value"]
123+
Assert-AreEqual $expected.Tags[0]["Value"] $actual.Tags[0]["Value"]
121124
}
122125
finally
123126
{
@@ -134,36 +137,36 @@ function Test-GetBatchAccountsUnderResourceGroups
134137
{
135138
# Setup
136139
$resourceGroup1 = Get-ResourceGroupName
137-
$resourceGroup2 = Get-ResourceGroupName
138-
$account11 = Get-BatchAccountName
139-
$account12 = Get-BatchAccountName
140-
$account21 = Get-BatchAccountName
140+
$resourceGroup2 = Get-ResourceGroupName
141+
$account11 = Get-BatchAccountName
142+
$account12 = Get-BatchAccountName
143+
$account21 = Get-BatchAccountName
141144
$location1 = Get-BatchAccountProviderLocation
142-
$location2 = Get-BatchAccountProviderLocation 1
143-
$location3 = Get-BatchAccountProviderLocation 2
145+
$location2 = Get-BatchAccountProviderLocation 4
146+
$location3 = Get-BatchAccountProviderLocation 7
144147

145148
try
146149
{
147150
New-AzureRmResourceGroup -Name $resourceGroup1 -Location $location1
148-
New-AzureRmResourceGroup -Name $resourceGroup2 -Location $location1
149-
New-AzureRmBatchAccount -Name $account11 -ResourceGroupName $resourceGroup1 -Location $location1
150-
New-AzureRmBatchAccount -Name $account12 -ResourceGroupName $resourceGroup1 -Location $location2
151-
New-AzureRmBatchAccount -Name $account21 -ResourceGroupName $resourceGroup2 -Location $location3
151+
New-AzureRmResourceGroup -Name $resourceGroup2 -Location $location1
152+
New-AzureRmBatchAccount -Name $account11 -ResourceGroupName $resourceGroup1 -Location $location1
153+
New-AzureRmBatchAccount -Name $account12 -ResourceGroupName $resourceGroup1 -Location $location2
154+
New-AzureRmBatchAccount -Name $account21 -ResourceGroupName $resourceGroup2 -Location $location3
152155

153156
# Test
154-
$allAccounts = Get-AzureRmBatchAccount | Where-Object {$_.ResourceGroupName -eq $resourceGroup1 -or $_.ResourceGroupName -eq $resourceGroup2}
155-
$resourceGroup1Accounts = Get-AzureRmBatchAccount -ResourceGroupName $resourceGroup1
157+
$allAccounts = Get-AzureRmBatchAccount | Where-Object {$_.ResourceGroupName -eq $resourceGroup1 -or $_.ResourceGroupName -eq $resourceGroup2}
158+
$resourceGroup1Accounts = Get-AzureRmBatchAccount -ResourceGroupName $resourceGroup1
156159

157-
# Assert
158-
Assert-AreEqual 3 $allAccounts.Count
159-
Assert-AreEqual 2 $resourceGroup1Accounts.Count
160-
Assert-AreEqual 2 ($resourceGroup1Accounts | Where-Object {$_.ResourceGroupName -eq $resourceGroup1}).Count
160+
# Assert
161+
Assert-AreEqual 3 $allAccounts.Count
162+
Assert-AreEqual 2 $resourceGroup1Accounts.Count
163+
Assert-AreEqual 2 ($resourceGroup1Accounts | Where-Object {$_.ResourceGroupName -eq $resourceGroup1}).Count
161164
}
162165
finally
163166
{
164167
# Cleanup
165-
Clean-BatchAccount $account11 $resourceGroup1
166-
Clean-BatchAccountAndResourceGroup $account12 $resourceGroup1
168+
Clean-BatchAccount $account11 $resourceGroup1
169+
Clean-BatchAccountAndResourceGroup $account12 $resourceGroup1
167170
Clean-BatchAccountAndResourceGroup $account21 $resourceGroup2
168171
}
169172
}
@@ -177,28 +180,28 @@ function Test-CreateAndRemoveBatchAccountViaPiping
177180
{
178181
# Setup
179182
$account1 = Get-BatchAccountName
180-
$account2 = Get-BatchAccountName
183+
$account2 = Get-BatchAccountName
181184
$resourceGroup = Get-ResourceGroupName
182185
$location1 = Get-BatchAccountProviderLocation
183-
$location2 = Get-BatchAccountProviderLocation 1
184-
185-
try
186-
{
187-
New-AzureRmResourceGroup -Name $resourceGroup -Location $location1
188-
189-
# Test
190-
New-AzureRmBatchAccount -Name $account1 -ResourceGroupName $resourceGroup -Location $location1
191-
New-AzureRmBatchAccount -Name $account2 -ResourceGroupName $resourceGroup -Location $location2
192-
Get-AzureRmBatchAccount | where {$_.AccountName -eq $account1 -or $_.AccountName -eq $account2} | Remove-AzureRmBatchAccount -Force
193-
194-
# Assert
195-
Assert-Throws { Get-AzureRmBatchAccount -Name $account1 }
196-
Assert-Throws { Get-AzureRmBatchAccount -Name $account2 }
197-
}
198-
finally
199-
{
200-
Clean-ResourceGroup $resourceGroup
201-
}
186+
$location2 = Get-BatchAccountProviderLocation 4
187+
188+
try
189+
{
190+
New-AzureRmResourceGroup -Name $resourceGroup -Location $location1
191+
192+
# Test
193+
New-AzureRmBatchAccount -Name $account1 -ResourceGroupName $resourceGroup -Location $location1
194+
New-AzureRmBatchAccount -Name $account2 -ResourceGroupName $resourceGroup -Location $location2
195+
Get-AzureRmBatchAccount | where {$_.AccountName -eq $account1 -or $_.AccountName -eq $account2} | Remove-AzureRmBatchAccount -Force
196+
197+
# Assert
198+
Assert-Throws { Get-AzureRmBatchAccount -Name $account1 }
199+
Assert-Throws { Get-AzureRmBatchAccount -Name $account2 }
200+
}
201+
finally
202+
{
203+
Clean-ResourceGroup $resourceGroup
204+
}
202205
}
203206

204207
<#
@@ -208,7 +211,7 @@ Tests getting/setting Batch account keys
208211
function Test-BatchAccountKeys
209212
{
210213
# Setup
211-
$account = Get-BatchAccountName
214+
$account = Get-BatchAccountName
212215
$resourceGroup = Get-ResourceGroupName
213216
$location = Get-BatchAccountProviderLocation
214217

@@ -218,25 +221,25 @@ function Test-BatchAccountKeys
218221

219222
# Test
220223
$new = New-AzureRmBatchAccount -Name $account -ResourceGroupName $resourceGroup -Location $location -Tag @{Name = "testtag"; Value = "testval"}
221-
$originalKeys = Get-AzureRmBatchAccountKeys -Name $account -ResourceGroupName $resourceGroup
222-
$originalPrimaryKey = $originalKeys.PrimaryAccountKey
223-
$originalSecondaryKey = $originalKeys.SecondaryAccountKey
224-
$newPrimary = New-AzureRmBatchAccountKey -Name $account -ResourceGroupName $resourceGroup -KeyType Primary
225-
$newSecondary = New-AzureRmBatchAccountKey -Name $account -ResourceGroupName $resourceGroup -KeyType Secondary
224+
$originalKeys = Get-AzureRmBatchAccountKeys -Name $account -ResourceGroupName $resourceGroup
225+
$originalPrimaryKey = $originalKeys.PrimaryAccountKey
226+
$originalSecondaryKey = $originalKeys.SecondaryAccountKey
227+
$newPrimary = New-AzureRmBatchAccountKey -Name $account -ResourceGroupName $resourceGroup -KeyType Primary
228+
$newSecondary = New-AzureRmBatchAccountKey -Name $account -ResourceGroupName $resourceGroup -KeyType Secondary
226229
$finalKeys = Get-AzureRmBatchAccountKeys -Name $account -ResourceGroupName $resourceGroup
227-
$getAccountResult = Get-AzureRmBatchAccount -Name $account -ResourceGroupName $resourceGroup
230+
$getAccountResult = Get-AzureRmBatchAccount -Name $account -ResourceGroupName $resourceGroup
228231

229232
# Assert
230-
Assert-AreEqual $null $new.PrimaryAccountKey
233+
Assert-AreEqual $null $new.PrimaryAccountKey
231234
Assert-AreEqual $null $new.SecondaryAccountKey
232-
Assert-AreEqual $originalSecondaryKey $newPrimary.SecondaryAccountKey
233-
Assert-AreEqual $newPrimary.PrimaryAccountKey $newSecondary.PrimaryAccountKey
234-
Assert-AreEqual $newPrimary.PrimaryAccountKey $finalKeys.PrimaryAccountKey
235-
Assert-AreEqual $newSecondary.SecondaryAccountKey $finalKeys.SecondaryAccountKey
236-
Assert-AreNotEqual $originalPrimaryKey $newPrimary.PrimaryAccountKey
237-
Assert-AreNotEqual $originalSecondaryKey $newSecondary.SecondaryAccountKey
238-
Assert-AreEqual $null $getAccountResult.PrimaryAccountKey
239-
Assert-AreEqual $null $getAccountResult.SecondaryAccountKey
235+
Assert-AreEqual $originalSecondaryKey $newPrimary.SecondaryAccountKey
236+
Assert-AreEqual $newPrimary.PrimaryAccountKey $newSecondary.PrimaryAccountKey
237+
Assert-AreEqual $newPrimary.PrimaryAccountKey $finalKeys.PrimaryAccountKey
238+
Assert-AreEqual $newSecondary.SecondaryAccountKey $finalKeys.SecondaryAccountKey
239+
Assert-AreNotEqual $originalPrimaryKey $newPrimary.PrimaryAccountKey
240+
Assert-AreNotEqual $originalSecondaryKey $newSecondary.SecondaryAccountKey
241+
Assert-AreEqual $null $getAccountResult.PrimaryAccountKey
242+
Assert-AreEqual $null $getAccountResult.SecondaryAccountKey
240243
}
241244
finally
242245
{

src/ResourceManager/AzureBatch/Commands.Batch.Test/ScenarioTests/Common.ps1

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,31 @@ Gets the location for the Batch account provider. Default to West US if none fou
3636
#>
3737
function Get-BatchAccountProviderLocation($index)
3838
{
39-
if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne [Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback)
40-
{
41-
$namespace = $provider.Split("/")[0]
42-
if($provider.Contains("/"))
43-
{
44-
$type = $provider.Substring($namespace.Length + 1)
45-
$location = Get-AzureRmResourceProvider -ProviderNamespace $namespace | where {$_.ResourceTypes[0].ResourceTypeName -eq $type}
39+
if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne [Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback)
40+
{
41+
$namespace = "Microsoft.Batch"
42+
$type = "batchAccounts"
43+
$r = Get-AzureRmResourceProvider -ProviderNamespace $namespace | where {$_.ResourceTypes[0].ResourceTypeName -eq $type}
44+
$location = $r.Locations
4645

47-
if ($location -eq $null)
48-
{
49-
return "West US"
50-
} else
51-
{
52-
return $location.Locations[0]
53-
}
54-
}
55-
56-
return "West US"
57-
}
46+
if ($location -eq $null)
47+
{
48+
return "West US"
49+
}
50+
else
51+
{
52+
if ($index -eq $null)
53+
{
54+
return "West US"
55+
}
56+
else
57+
{
58+
return $location[$index]
59+
}
60+
}
61+
}
5862

59-
return "WestUS"
63+
return "West US"
6064
}
6165

6266
<#
@@ -66,7 +70,7 @@ Cleans the created Batch account and resource group
6670
function Clean-BatchAccountAndResourceGroup($accountName,$resourceGroup)
6771
{
6872
Clean-BatchAccount $accountName $resourceGroup
69-
Clean-ResourceGroup $resourceGroup
73+
Clean-ResourceGroup $resourceGroup
7074
}
7175

7276
<#
@@ -76,7 +80,7 @@ Cleans the created Batch account
7680
function Clean-BatchAccount($accountName,$resourceGroup)
7781
{
7882
if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne [Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback)
79-
{
83+
{
8084
Remove-AzureRmBatchAccount -Name $accountName -ResourceGroupName $resourceGroup -Force
8185
}
8286
}
@@ -87,8 +91,8 @@ Cleans the created resource group
8791
#>
8892
function Clean-ResourceGroup($resourceGroup)
8993
{
90-
if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne [Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback)
91-
{
94+
if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne [Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback)
95+
{
9296
Remove-AzureRmResourceGroup -Name $resourceGroup -Force
9397
}
9498
}

src/ResourceManager/AzureBatch/Commands.Batch.Test/ScenarioTests/JobTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ public void TestGetJobById()
6363
public void TestListJobsByFilter()
6464
{
6565
BatchController controller = BatchController.NewInstance;
66-
string jobId1 = "testId1";
67-
string jobId2 = "testId2";
66+
string jobId1 = "filterTestId1";
67+
string jobId2 = "filterTestId2";
6868
string jobId3 = "thirdtestId";
69-
string state = "active";
69+
string prefix = "filterTest";
7070
int matches = 2;
7171
BatchAccountContext context = null;
7272
controller.RunPsTestWorkflow(
73-
() => { return new string[] { string.Format("Test-ListJobsByFilter '{0}' '{1}' '{2}'", accountName, state.ToString(), matches) }; },
73+
() => { return new string[] { string.Format("Test-ListJobsByFilter '{0}' '{1}' '{2}'", accountName, prefix, matches) }; },
7474
() =>
7575
{
7676
context = ScenarioTestHelpers.GetBatchAccountContextWithKeys(controller, accountName);

0 commit comments

Comments
 (0)