Skip to content

Commit 167774b

Browse files
committed
Merge pull request #56 from jasper-schneider/getvm
Get-AzureBatchVM and Get-AzureBatchVMFile
2 parents 3a00b46 + 439c2f8 commit 167774b

34 files changed

+5776
-33
lines changed

src/ResourceManager/Batch/Commands.Batch.Test/BatchTestHelpers.cs

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,19 @@ public static PSCloudWorkItem CreatePSCloudWorkItem()
125125
}
126126
}
127127

128+
/// <summary>
129+
/// Builds a PSCloudPool for testing
130+
/// </summary>
131+
public static PSCloudPool CreatePSCloudPool()
132+
{
133+
BatchAccountContext context = CreateBatchContextWithKeys();
134+
using (IPoolManager poolManager = context.BatchOMClient.OpenPoolManager())
135+
{
136+
ICloudPool pool = poolManager.CreatePool("testPool");
137+
return new PSCloudPool(pool);
138+
}
139+
}
140+
128141
/// <summary>
129142
/// Builds a GetPoolResponse object
130143
/// </summary>
@@ -163,6 +176,43 @@ public static ListPoolsResponse CreateListPoolsResponse(IEnumerable<string> pool
163176
return response;
164177
}
165178

179+
/// <summary>
180+
/// Builds a GetTVMResponse object
181+
/// </summary>
182+
public static GetTVMResponse CreateGetTVMResponse(string vmName)
183+
{
184+
GetTVMResponse response = new GetTVMResponse();
185+
SetProperty(response, "StatusCode", HttpStatusCode.OK);
186+
187+
TVM vm = new TVM();
188+
SetProperty(vm, "Name", vmName);
189+
SetProperty(response, "TVM", vm);
190+
191+
return response;
192+
}
193+
194+
/// <summary>
195+
/// Builds a ListTVMsResponse object
196+
/// </summary>
197+
public static ListTVMsResponse CreateListTVMsResponse(IEnumerable<string> vmNames)
198+
{
199+
ListTVMsResponse response = new ListTVMsResponse();
200+
SetProperty(response, "StatusCode", HttpStatusCode.OK);
201+
202+
List<TVM> vms = new List<TVM>();
203+
204+
foreach (string name in vmNames)
205+
{
206+
TVM vm = new TVM();
207+
SetProperty(vm, "Name", name);
208+
vms.Add(vm);
209+
}
210+
211+
SetProperty(response, "TVMs", vms);
212+
213+
return response;
214+
}
215+
166216
/// <summary>
167217
/// Builds a GetWorkItemResponse object
168218
/// </summary>
@@ -314,6 +364,44 @@ public static ListTaskFilesResponse CreateListTaskFilesResponse(IEnumerable<stri
314364
return response;
315365
}
316366

367+
/// <summary>
368+
/// Builds a GetTVMFilePropertiesResponse object
369+
/// </summary>
370+
public static GetTVMFilePropertiesResponse CreateGetTVMFilePropertiesResponse(string fileName)
371+
{
372+
GetTVMFilePropertiesResponse response = new GetTVMFilePropertiesResponse();
373+
SetProperty(response, "StatusCode", HttpStatusCode.OK);
374+
375+
Azure.Batch.Protocol.Entities.File file = new Azure.Batch.Protocol.Entities.File();
376+
SetProperty(file, "Name", fileName);
377+
378+
SetProperty(response, "File", file);
379+
380+
return response;
381+
}
382+
383+
/// <summary>
384+
/// Builds a ListTVMFilesResponse object
385+
/// </summary>
386+
public static ListTVMFilesResponse CreateListTVMFilesResponse(IEnumerable<string> fileNames)
387+
{
388+
ListTVMFilesResponse response = new ListTVMFilesResponse();
389+
SetProperty(response, "StatusCode", HttpStatusCode.OK);
390+
391+
List<Azure.Batch.Protocol.Entities.File> files = new List<Azure.Batch.Protocol.Entities.File>();
392+
393+
foreach (string name in fileNames)
394+
{
395+
Azure.Batch.Protocol.Entities.File file = new Azure.Batch.Protocol.Entities.File();
396+
SetProperty(file, "Name", name);
397+
files.Add(file);
398+
}
399+
400+
SetProperty(response, "Files", files);
401+
402+
return response;
403+
}
404+
317405
/// <summary>
318406
/// Uses Reflection to set a property value on an object. Can be used to bypass restricted set accessors.
319407
/// </summary>

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@
156156
<Compile Include="BatchTestHelpers.cs" />
157157
<Compile Include="Files\GetBatchTaskFileCommandTests.cs" />
158158
<Compile Include="Files\GetBatchTaskFileContentCommandTests.cs" />
159+
<Compile Include="Files\GetBatchVMFileCommandTests.cs" />
159160
<Compile Include="Jobs\GetBatchJobCommandTests.cs" />
160161
<Compile Include="Jobs\RemoveBatchJobCommandTests.cs" />
161162
<Compile Include="Models\BatchAccountContextTest.cs" />
@@ -170,10 +171,12 @@
170171
<Compile Include="ScenarioTests\PoolTests.cs" />
171172
<Compile Include="ScenarioTests\ScenarioTestHelpers.cs" />
172173
<Compile Include="ScenarioTests\TaskTests.cs" />
174+
<Compile Include="ScenarioTests\VMTests.cs" />
173175
<Compile Include="ScenarioTests\WorkItemTests.cs" />
174176
<Compile Include="Tasks\GetBatchTaskCommandTests.cs" />
175177
<Compile Include="Tasks\NewBatchTaskCommandTests.cs" />
176178
<Compile Include="Tasks\RemoveBatchTaskCommandTests.cs" />
179+
<Compile Include="VMs\GetBatchVMCommandTests.cs" />
177180
<Compile Include="WorkItems\GetBatchWorkItemCommandTests.cs" />
178181
<Compile Include="WorkItems\NewBatchWorkItemCommandTests.cs" />
179182
<Compile Include="WorkItems\RemoveBatchWorkItemCommandTests.cs" />
@@ -201,6 +204,9 @@
201204
<None Include="ScenarioTests\TaskTests.ps1">
202205
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
203206
</None>
207+
<None Include="ScenarioTests\VMTests.ps1">
208+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
209+
</None>
204210
<None Include="ScenarioTests\WorkItemTests.ps1">
205211
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
206212
</None>
@@ -234,9 +240,15 @@
234240
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.FileTests\TestGetTaskFileContentPipeline.json">
235241
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
236242
</None>
243+
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.FileTests\TestGetVMFileByName.json">
244+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
245+
</None>
237246
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.FileTests\TestListAllTaskFiles.json">
238247
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
239248
</None>
249+
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.FileTests\TestListAllVMFiles.json">
250+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
251+
</None>
240252
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.FileTests\TestListTaskFilePipeline.json">
241253
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
242254
</None>
@@ -249,6 +261,18 @@
249261
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.FileTests\TestListTaskFilesWithMaxCount.json">
250262
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
251263
</None>
264+
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.FileTests\TestListVMFilePipeline.json">
265+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
266+
</None>
267+
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.FileTests\TestListVMFilesByFilter.json">
268+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
269+
</None>
270+
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.FileTests\TestListVMFilesRecursive.json">
271+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
272+
</None>
273+
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.FileTests\TestListVMFilesWithMaxCount.json">
274+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
275+
</None>
252276
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.JobTests\TestDeleteJob.json">
253277
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
254278
</None>
@@ -321,6 +345,21 @@
321345
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.TaskTests\TestListTasksWithMaxCount.json">
322346
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
323347
</None>
348+
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.VMTests\TestGetVMByName.json">
349+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
350+
</None>
351+
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.VMTests\TestListAllVMs.json">
352+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
353+
</None>
354+
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.VMTests\TestListVMPipeline.json">
355+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
356+
</None>
357+
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.VMTests\TestListVMsByFilter.json">
358+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
359+
</None>
360+
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.VMTests\TestListVMsWithMaxCount.json">
361+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
362+
</None>
324363
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.WorkItemTests\TestDeleteWorkItem.json">
325364
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
326365
</None>

0 commit comments

Comments
 (0)