Skip to content

Commit 121e0a7

Browse files
committed
Support for Azure.Batch 8.0 and re-record tests
1 parent b5e089e commit 121e0a7

File tree

66 files changed

+5201
-4052
lines changed

Some content is hidden

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

66 files changed

+5201
-4052
lines changed

src/ResourceManager/AzureBatch/BatchModelGenerator/Program.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ public class Program
5050
{"Microsoft.Azure.Batch.ComputeNodeError", "PSComputeNodeError"},
5151
{"Microsoft.Azure.Batch.ComputeNodeInformation", "PSComputeNodeInformation"},
5252
{"Microsoft.Azure.Batch.ComputeNodeUser", "PSComputeNodeUser"},
53+
{"Microsoft.Azure.Batch.ContainerConfiguration", "PSContainerConfiguration"},
54+
{"Microsoft.Azure.Batch.ContainerRegistry", "PSContainerRegistry"},
55+
{"Microsoft.Azure.Batch.DataDisk", "PSDataDisk"},
5356
{"Microsoft.Azure.Batch.DeleteCertificateError", "PSDeleteCertificateError"},
5457
{"Microsoft.Azure.Batch.EnvironmentSetting", "PSEnvironmentSetting"},
5558
{"Microsoft.Azure.Batch.ExitConditions", "PSExitConditions"},
@@ -101,6 +104,8 @@ public class Program
101104
{"Microsoft.Azure.Batch.StartTaskInformation", "PSStartTaskInformation"},
102105
{"Microsoft.Azure.Batch.SubtaskInformation", "PSSubtaskInformation"},
103106
{"Microsoft.Azure.Batch.TaskConstraints", "PSTaskConstraints"},
107+
{"Microsoft.Azure.Batch.TaskContainerExecutionInformation", "PSTaskContainerExecutionInformation"},
108+
{"Microsoft.Azure.Batch.TaskContainerSettings", "PSTaskContainerSettings"},
104109
{"Microsoft.Azure.Batch.TaskDependencies", "PSTaskDependencies"},
105110
{"Microsoft.Azure.Batch.TaskExecutionInformation", "PSTaskExecutionInformation"},
106111
{"Microsoft.Azure.Batch.TaskInformation", "PSTaskInformation"},

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
<Reference Include="Hyak.Common">
4545
<HintPath>..\..\..\packages\Hyak.Common.1.0.3\lib\portable-net403+win+wpa81\Hyak.Common.dll</HintPath>
4646
</Reference>
47-
<Reference Include="Microsoft.Azure.Batch, Version=7.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
48-
<HintPath>..\..\..\packages\Azure.Batch.7.1.0\lib\net452\Microsoft.Azure.Batch.dll</HintPath>
47+
<Reference Include="Microsoft.Azure.Batch, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
48+
<HintPath>..\..\..\packages\Azure.Batch.8.0.0\lib\net452\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>
@@ -98,10 +98,10 @@
9898
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.28.3\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll</HintPath>
9999
</Reference>
100100
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
101-
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.8\lib\net452\Microsoft.Rest.ClientRuntime.dll</HintPath>
101+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.10\lib\net452\Microsoft.Rest.ClientRuntime.dll</HintPath>
102102
</Reference>
103103
<Reference Include="Microsoft.Rest.ClientRuntime.Azure, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
104-
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.3.3.7\lib\net452\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
104+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.3.3.10\lib\net452\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
105105
</Reference>
106106
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
107107
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.Authentication.2.2.9-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.Authentication.dll</HintPath>

src/ResourceManager/AzureBatch/Commands.Batch.Test/Pools/NewBatchPoolCommandTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public void NewBatchPoolParametersGetPassedToRequestTest()
100100
cmdlet.TargetDedicatedComputeNodes = 3;
101101
cmdlet.TargetLowPriorityComputeNodes = 2;
102102
cmdlet.TaskSchedulingPolicy = new PSTaskSchedulingPolicy(Azure.Batch.Common.ComputeNodeFillType.Spread);
103-
cmdlet.VirtualMachineConfiguration = new PSVirtualMachineConfiguration("node agent", new PSImageReference("offer", "publisher", "sku"));
103+
cmdlet.VirtualMachineConfiguration = new PSVirtualMachineConfiguration(new PSImageReference("offer", "publisher", "sku"), "node agent");
104104
cmdlet.VirtualMachineSize = "small";
105105

106106
PoolAddParameter requestParameters = null;
@@ -219,9 +219,12 @@ public void NewBatchPoolOSDiskGetsPassedToRequest()
219219
cmdlet.Id = "testPool";
220220
cmdlet.TargetDedicatedComputeNodes = 3;
221221

222-
List<string> imageUrls = new List<string>() { "https://image1.vhd", "https://image2.vhd" };
223222
Azure.Batch.Common.CachingType cachingType = Azure.Batch.Common.CachingType.ReadWrite;
224-
cmdlet.VirtualMachineConfiguration = new PSVirtualMachineConfiguration("node agent", osDisk: new PSOSDisk(imageUrls, cachingType));
223+
cmdlet.VirtualMachineConfiguration =
224+
new PSVirtualMachineConfiguration(new PSImageReference("offer", "publisher", "sku"), "node agent")
225+
{
226+
OSDisk = new PSOSDisk(cachingType)
227+
};
225228
PoolAddParameter requestParameters = null;
226229

227230
// Store the request parameters
@@ -237,9 +240,6 @@ public void NewBatchPoolOSDiskGetsPassedToRequest()
237240
cmdlet.ExecuteCmdlet();
238241

239242
// Verify the request parameters match the cmdlet parameters
240-
Assert.Equal(2, requestParameters.VirtualMachineConfiguration.OsDisk.ImageUris.Count);
241-
Assert.Equal(imageUrls[0], requestParameters.VirtualMachineConfiguration.OsDisk.ImageUris[0]);
242-
Assert.Equal(imageUrls[1], requestParameters.VirtualMachineConfiguration.OsDisk.ImageUris[1]);
243243
Assert.Equal(cachingType.ToString().ToLowerInvariant(),
244244
requestParameters.VirtualMachineConfiguration.OsDisk.Caching.ToString().ToLowerInvariant());
245245
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,6 @@ function Test-GetBatchNodeAgentSkus
105105
{
106106
Assert-True { $nodeAgentSku.Id.StartsWith("batch.node") }
107107
Assert-True { $nodeAgentSku.OSType -in "linux","windows" }
108-
Assert-AreNotEqual 0 $nodeAgentSku.VerifiedImageReferences.Count
108+
Assert-AreNotEqual $null $nodeAgentSku.VerifiedImageReferences
109109
}
110110
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ function IfJobSetsAutoFailure-ItCompletesWhenAnyTaskFails
162162
$paasConfiguration = New-Object Microsoft.Azure.Commands.Batch.Models.PSCloudServiceConfiguration -ArgumentList @($osFamily, $targetOSVersion)
163163

164164
$poolSpec = New-Object Microsoft.Azure.Commands.Batch.Models.PSPoolSpecification
165-
$poolSpec.TargetDedicated = $targetDedicated = 3
165+
$poolSpec.TargetDedicatedComputeNodes = $targetDedicated = 3
166166
$poolSpec.VirtualMachineSize = $vmSize = "small"
167167
$poolSpec.CloudServiceConfiguration = $paasConfiguration
168168
$autoPoolSpec = New-Object Microsoft.Azure.Commands.Batch.Models.PSAutoPoolSpecification

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ function Test-ResizeAndStopResizePool
8383

8484
# Get the initial TargetDedicated count
8585
$pool = Get-AzureBatchPool -Id $poolId -BatchContext $context
86-
$initialTargetDedicated = $pool.TargetDedicated
86+
$initialTargetDedicated = $pool.TargetDedicatedComputeNodes
8787

8888
$newTargetDedicated = $initialTargetDedicated + 1
89-
Start-AzureBatchPoolResize -Id $poolId -TargetDedicated $newTargetDedicated -BatchContext $context
89+
Start-AzureBatchPoolResize -Id $poolId -TargetDedicatedComputeNodes $newTargetDedicated -BatchContext $context
9090

91-
# Verify the TargetDedicated property was updated
91+
# Verify the TargetDedicatedComputeNodes property was updated
9292
$pool = Get-AzureBatchPool -Id $poolId -BatchContext $context
93-
Assert-AreEqual $newTargetDedicated $pool.TargetDedicated
93+
Assert-AreEqual $newTargetDedicated $pool.TargetDedicatedComputeNodes
9494

9595
# Stop the resize
9696
$pool | Stop-AzureBatchPoolResize -BatchContext $context
@@ -110,7 +110,7 @@ function Test-AutoScaleActions
110110

111111
$context = New-Object Microsoft.Azure.Commands.Batch.Test.ScenarioTests.ScenarioTestContext
112112

113-
$formula = '$TargetDedicated=0'
113+
$formula = '$TargetDedicatedNodes=0'
114114
$interval = ([TimeSpan]::FromMinutes(8))
115115

116116
# Verify pool starts with autoscale disabled
@@ -126,7 +126,7 @@ function Test-AutoScaleActions
126126
Assert-AreEqual $interval $pool.AutoScaleEvaluationInterval
127127

128128
# Try to evaluate a test formula
129-
$testFormula = '$TargetDedicated=1'
129+
$testFormula = '$TargetDedicatedNodes=1'
130130
$evalResult = Test-AzureBatchAutoScale $poolId $testFormula -BatchContext $context
131131

132132
# Verify that the evaluation result matches expectation

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

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,6 @@ public static void CreateTestPool(
177177
CertificateReference certReference = null,
178178
StartTask startTask = null)
179179
{
180-
BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);
181-
182180
PSCertificateReference[] certReferences = null;
183181
if (certReference != null)
184182
{
@@ -203,7 +201,26 @@ public static void CreateTestPool(
203201
InterComputeNodeCommunicationEnabled = true
204202
};
205203

206-
client.CreatePool(parameters);
204+
CreatePoolIfNotExists(controller, parameters);
205+
}
206+
207+
public static void CreatePoolIfNotExists(
208+
BatchController controller,
209+
NewPoolParameters poolParameters)
210+
{
211+
BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);
212+
213+
try
214+
{
215+
client.CreatePool(poolParameters);
216+
}
217+
catch (BatchException e)
218+
{
219+
if (e.RequestInformation.BatchError.Code != "PoolAlreadyExists")
220+
{
221+
throw;
222+
}
223+
}
207224
}
208225

209226
/// <summary>
@@ -362,8 +379,7 @@ public static void CreateTestTask(BatchController controller, BatchAccountContex
362379
PSMultiInstanceSettings multiInstanceSettings = null;
363380
if (numInstances > 1)
364381
{
365-
multiInstanceSettings = new PSMultiInstanceSettings(numInstances);
366-
multiInstanceSettings.CoordinationCommandLine = "cmd /c echo coordinating";
382+
multiInstanceSettings = new PSMultiInstanceSettings("cmd /c echo coordinating", numInstances);
367383
}
368384

369385
NewTaskParameters parameters = new NewTaskParameters(context, jobId, null, taskId)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ function Test-CreateTaskCollection
107107
$envSettings.Add($env2)
108108

109109
$numInstances = 3
110-
$multiInstanceSettings = New-Object Microsoft.Azure.Commands.Batch.Models.PSMultiInstanceSettings -ArgumentList @($numInstances)
111-
$multiInstanceSettings.CoordinationCommandLine = $coordinationCommandLine = "cmd /c echo coordinating"
110+
$multiInstanceSettings = New-Object Microsoft.Azure.Commands.Batch.Models.PSMultiInstanceSettings -ArgumentList @("cmd /c echo coordinating", $numInstances)
111+
$coordinationCommandLine = $multiInstanceSettings.CoordinationCommandLine
112112
$multiInstanceSettings.CommonResourceFiles = New-Object System.Collections.Generic.List``1[Microsoft.Azure.Commands.Batch.Models.PSResourceFile]
113113
$commonResourceBlob = "https://common.blob.core.windows.net/"
114114
$commonResourceFile = "common.exe"

0 commit comments

Comments
 (0)