Skip to content

Update Batch RP API version #580

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 2 commits into from
Jul 9, 2015
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
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.0.19.2-preview\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Batch">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Batch.1.3.0-preview\lib\net40\Microsoft.Azure.Management.Batch.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Batch.1.4.0\lib\net40\Microsoft.Azure.Management.Batch.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.ResourceManager">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.1-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,17 @@ function Test-GetBatchAccountsUnderResourceGroups
$account11 = Get-BatchAccountName
$account12 = Get-BatchAccountName
$account21 = Get-BatchAccountName
$location = Get-BatchAccountProviderLocation
$location1 = Get-BatchAccountProviderLocation
$location2 = Get-BatchAccountProviderLocation 1
$location3 = Get-BatchAccountProviderLocation 2

try
{
New-AzureResourceGroup -Name $resourceGroup1 -Location $location
New-AzureResourceGroup -Name $resourceGroup2 -Location $location
New-AzureBatchAccount -Name $account11 -ResourceGroupName $resourceGroup1 -Location $location
New-AzureBatchAccount -Name $account12 -ResourceGroupName $resourceGroup1 -Location $location
New-AzureBatchAccount -Name $account21 -ResourceGroupName $resourceGroup2 -Location $location
New-AzureResourceGroup -Name $resourceGroup1 -Location $location1
New-AzureResourceGroup -Name $resourceGroup2 -Location $location1
New-AzureBatchAccount -Name $account11 -ResourceGroupName $resourceGroup1 -Location $location1
New-AzureBatchAccount -Name $account12 -ResourceGroupName $resourceGroup1 -Location $location2
New-AzureBatchAccount -Name $account21 -ResourceGroupName $resourceGroup2 -Location $location3

# Test
$allAccounts = Get-AzureBatchAccount | Where-Object {$_.ResourceGroupName -eq $resourceGroup1 -or $_.ResourceGroupName -eq $resourceGroup2}
Expand Down Expand Up @@ -177,15 +179,16 @@ function Test-CreateAndRemoveBatchAccountViaPiping
$account1 = Get-BatchAccountName
$account2 = Get-BatchAccountName
$resourceGroup = Get-ResourceGroupName
$location = Get-BatchAccountProviderLocation
$location1 = Get-BatchAccountProviderLocation
$location2 = Get-BatchAccountProviderLocation 1

try
{
New-AzureResourceGroup -Name $resourceGroup -Location $location
New-AzureResourceGroup -Name $resourceGroup -Location $location1

# Test
New-AzureBatchAccount -Name $account1 -ResourceGroupName $resourceGroup -Location $location
New-AzureBatchAccount -Name $account2 -ResourceGroupName $resourceGroup -Location $location
New-AzureBatchAccount -Name $account1 -ResourceGroupName $resourceGroup -Location $location1
New-AzureBatchAccount -Name $account2 -ResourceGroupName $resourceGroup -Location $location2
Get-AzureBatchAccount | where {$_.AccountName -eq $account1 -or $_.AccountName -eq $account2} | Remove-AzureBatchAccount -Force

# Assert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function Get-ResourceGroupName
.SYNOPSIS
Gets the location for the Batch account provider. Default to West US if none found.
#>
function Get-BatchAccountProviderLocation
function Get-BatchAccountProviderLocation($index)
{
$location = Get-AzureLocation | where {$_.Name -eq "Microsoft.Batch/batchAccounts"}
if ($location -eq $null)
Expand All @@ -43,7 +43,14 @@ function Get-BatchAccountProviderLocation
}
else
{
$location.Locations[0]
if ($index -eq $null)
{
$location.Locations[0]
}
else
{
$location.Locations[$index]
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,11 @@ namespace Microsoft.Azure.Commands.Batch.Test.ScenarioTests
{
public class FileTests
{
// NOTE: To save time on VM allocation when recording, these tests assume the following:
// - A Batch account named 'filetests' exists under the subscription being used for recording.
// - The following commands were run to create a pool, and all 3 VMs are allocated:
// $context = Get-AzureBatchAccountKeys "filetests"
// $startTask = New-Object Microsoft.Azure.Commands.Batch.Models.PSStartTask
// $startTask.CommandLine = "cmd /c echo hello"
// New-AzureBatchPool -Name "testPool" -VMSize "small" -OSFamily "4" -TargetOSVersion "*" -TargetDedicated 3 -StartTask $startTask -BatchContext $context

private const string accountName = "filetests";
private const string poolName = "testPool";
private const string vmName = "tvm-1900272697_1-20150331t200107z"; // Use the following command to get a VM name: (Get-AzureBatchVM -PoolName "testPool" -BatchContext $context)[0].Name
private const string startTaskStdOutName = "startup\\stdout.txt";
private const string startTaskStdOutContent = "hello";
private const string accountName = ScenarioTestHelpers.SharedAccount;
private const string poolName = ScenarioTestHelpers.SharedPool;
private const string vmName = ScenarioTestHelpers.SharedPoolVM;
private const string startTaskStdOutName = ScenarioTestHelpers.SharedPoolStartTaskStdOut;
private const string startTaskStdOutContent = ScenarioTestHelpers.SharedPoolStartTaskStdOutContent;

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,52 +26,36 @@ namespace Microsoft.Azure.Commands.Batch.Test.ScenarioTests
{
public class JobTests
{
private const string accountName = ScenarioTestHelpers.SharedAccount;
private const string poolName = ScenarioTestHelpers.SharedPool;

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetJobRequiredParameters()
{
BatchController controller = BatchController.NewInstance;
string resourceGroupName = "test-get-job-params";
string accountName = "testgetjobparams";
string location = "eastus";
BatchAccountContext context = null;
controller.RunPsTestWorkflow(
() => { return new string[] { string.Format("Test-GetJobRequiredParameters '{0}'", accountName) }; },
() =>
{
context = ScenarioTestHelpers.CreateTestAccountAndResourceGroup(controller, resourceGroupName, accountName, location);
},
() =>
{
ScenarioTestHelpers.CleanupTestAccount(controller, resourceGroupName, accountName);
},
TestUtilities.GetCallingClass(),
TestUtilities.GetCurrentMethodName());
controller.RunPsTest(string.Format("Test-GetJobRequiredParameters '{0}'", accountName));
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetJobByName()
{
BatchController controller = BatchController.NewInstance;
string resourceGroupName = "test-get-job";
string accountName = "testgetjob";
string location = "eastus";
string workItemName = "testName";
string jobName = null;
BatchAccountContext context = null;
controller.RunPsTestWorkflow(
() => { return new string[] { string.Format("Test-GetJobByName '{0}' '{1}' '{2}'", accountName, workItemName, jobName) }; },
() =>
{
context = ScenarioTestHelpers.CreateTestAccountAndResourceGroup(controller, resourceGroupName, accountName, location);
context = ScenarioTestHelpers.GetBatchAccountContextWithKeys(controller, accountName);
ScenarioTestHelpers.CreateTestWorkItem(controller, context, workItemName);
jobName = ScenarioTestHelpers.WaitForRecentJob(controller, context, workItemName);
},
() =>
{
ScenarioTestHelpers.DeleteWorkItem(controller, context, workItemName);
ScenarioTestHelpers.CleanupTestAccount(controller, resourceGroupName, accountName);
},
TestUtilities.GetCallingClass(),
TestUtilities.GetCurrentMethodName());
Expand All @@ -82,9 +66,6 @@ public void TestGetJobByName()
public void TestListJobsByFilter()
{
BatchController controller = BatchController.NewInstance;
string resourceGroupName = "test-list-job-filter";
string accountName = "testlistjobfilter";
string location = "eastus";
string workItemName = "testWorkItem";
string state = "active";
int matches = 1;
Expand All @@ -94,7 +75,7 @@ public void TestListJobsByFilter()
() =>
{
TimeSpan recurrence = TimeSpan.FromMinutes(1);
context = ScenarioTestHelpers.CreateTestAccountAndResourceGroup(controller, resourceGroupName, accountName, location);
context = ScenarioTestHelpers.GetBatchAccountContextWithKeys(controller, accountName);
ScenarioTestHelpers.CreateTestWorkItem(controller, context, workItemName, recurrence);
string jobName = ScenarioTestHelpers.WaitForRecentJob(controller, context, workItemName);
ScenarioTestHelpers.TerminateJob(context, workItemName, jobName);
Expand All @@ -103,7 +84,6 @@ public void TestListJobsByFilter()
() =>
{
ScenarioTestHelpers.DeleteWorkItem(controller, context, workItemName);
ScenarioTestHelpers.CleanupTestAccount(controller, resourceGroupName, accountName);
},
TestUtilities.GetCallingClass(),
TestUtilities.GetCurrentMethodName());
Expand All @@ -114,9 +94,6 @@ public void TestListJobsByFilter()
public void TestListJobsWithMaxCount()
{
BatchController controller = BatchController.NewInstance;
string resourceGroupName = "test-list-job-maxcount";
string accountName = "testlistjobmaxcount";
string location = "eastus";
string workItemName = "testWorkItem";
int maxCount = 1;
BatchAccountContext context = null;
Expand All @@ -125,7 +102,7 @@ public void TestListJobsWithMaxCount()
() =>
{
TimeSpan recurrence = TimeSpan.FromMinutes(1);
context = ScenarioTestHelpers.CreateTestAccountAndResourceGroup(controller, resourceGroupName, accountName, location);
context = ScenarioTestHelpers.GetBatchAccountContextWithKeys(controller, accountName);
ScenarioTestHelpers.CreateTestWorkItem(controller, context, workItemName, recurrence);
string jobName = ScenarioTestHelpers.WaitForRecentJob(controller, context, workItemName);
ScenarioTestHelpers.TerminateJob(context, workItemName, jobName);
Expand All @@ -134,7 +111,6 @@ public void TestListJobsWithMaxCount()
() =>
{
ScenarioTestHelpers.DeleteWorkItem(controller, context, workItemName);
ScenarioTestHelpers.CleanupTestAccount(controller, resourceGroupName, accountName);
},
TestUtilities.GetCallingClass(),
TestUtilities.GetCurrentMethodName());
Expand All @@ -145,9 +121,6 @@ public void TestListJobsWithMaxCount()
public void TestListAllJobs()
{
BatchController controller = BatchController.NewInstance;
string resourceGroupName = "test-list-job";
string accountName = "testlistjob";
string location = "eastus";
string workItemName = "testWorkItem";
int count = 2;
BatchAccountContext context = null;
Expand All @@ -156,7 +129,7 @@ public void TestListAllJobs()
() =>
{
TimeSpan recurrence = TimeSpan.FromMinutes(1);
context = ScenarioTestHelpers.CreateTestAccountAndResourceGroup(controller, resourceGroupName, accountName, location);
context = ScenarioTestHelpers.GetBatchAccountContextWithKeys(controller, accountName);
ScenarioTestHelpers.CreateTestWorkItem(controller, context, workItemName, recurrence);
string jobName = ScenarioTestHelpers.WaitForRecentJob(controller, context, workItemName);
ScenarioTestHelpers.TerminateJob(context, workItemName, jobName);
Expand All @@ -165,7 +138,6 @@ public void TestListAllJobs()
() =>
{
ScenarioTestHelpers.DeleteWorkItem(controller, context, workItemName);
ScenarioTestHelpers.CleanupTestAccount(controller, resourceGroupName, accountName);
},
TestUtilities.GetCallingClass(),
TestUtilities.GetCurrentMethodName());
Expand All @@ -176,9 +148,6 @@ public void TestListAllJobs()
public void TestListJobPipeline()
{
BatchController controller = BatchController.NewInstance;
string resourceGroupName = "test-list-job-pipe";
string accountName = "testlistjobpipe";
string location = "eastus";
string workItemName = "testWorkItem";
string jobName = null;

Expand All @@ -187,14 +156,13 @@ public void TestListJobPipeline()
() => { return new string[] { string.Format("Test-ListJobPipeline '{0}' '{1}' '{2}'", accountName, workItemName, jobName) }; },
() =>
{
context = ScenarioTestHelpers.CreateTestAccountAndResourceGroup(controller, resourceGroupName, accountName, location);
context = ScenarioTestHelpers.GetBatchAccountContextWithKeys(controller, accountName);
ScenarioTestHelpers.CreateTestWorkItem(controller, context, workItemName);
jobName = ScenarioTestHelpers.WaitForRecentJob(controller, context, workItemName);
},
() =>
{
ScenarioTestHelpers.DeleteWorkItem(controller, context, workItemName);
ScenarioTestHelpers.CleanupTestAccount(controller, resourceGroupName, accountName);
},
TestUtilities.GetCallingClass(),
TestUtilities.GetCurrentMethodName());
Expand All @@ -205,9 +173,6 @@ public void TestListJobPipeline()
public void TestDeleteJob()
{
BatchController controller = BatchController.NewInstance;
string resourceGroupName = "test-delete-job";
string accountName = "testdeletejob";
string location = "eastus";
string workItemName = "testWorkItem";
string jobName = null;

Expand All @@ -216,14 +181,13 @@ public void TestDeleteJob()
() => { return new string[] { string.Format("Test-DeleteJob '{0}' '{1}' '{2}' '0'", accountName, workItemName, jobName) }; },
() =>
{
context = ScenarioTestHelpers.CreateTestAccountAndResourceGroup(controller, resourceGroupName, accountName, location);
context = ScenarioTestHelpers.GetBatchAccountContextWithKeys(controller, accountName);
ScenarioTestHelpers.CreateTestWorkItem(controller, context, workItemName);
jobName = ScenarioTestHelpers.WaitForRecentJob(controller, context, workItemName);
},
() =>
{
ScenarioTestHelpers.DeleteWorkItem(controller, context, workItemName);
ScenarioTestHelpers.CleanupTestAccount(controller, resourceGroupName, accountName);
},
TestUtilities.GetCallingClass(),
TestUtilities.GetCurrentMethodName());
Expand All @@ -234,9 +198,6 @@ public void TestDeleteJob()
public void TestDeleteJobPipeline()
{
BatchController controller = BatchController.NewInstance;
string resourceGroupName = "test-delete-job-pipe";
string accountName = "testdeletejobpipe";
string location = "eastus";
string workItemName = "testWorkItem";
string jobName = null;

Expand All @@ -245,14 +206,13 @@ public void TestDeleteJobPipeline()
() => { return new string[] { string.Format("Test-DeleteJob '{0}' '{1}' '{2}' '1'", accountName, workItemName, jobName) }; },
() =>
{
context = ScenarioTestHelpers.CreateTestAccountAndResourceGroup(controller, resourceGroupName, accountName, location);
context = ScenarioTestHelpers.GetBatchAccountContextWithKeys(controller, accountName);
ScenarioTestHelpers.CreateTestWorkItem(controller, context, workItemName);
jobName = ScenarioTestHelpers.WaitForRecentJob(controller, context, workItemName);
},
() =>
{
ScenarioTestHelpers.DeleteWorkItem(controller, context, workItemName);
ScenarioTestHelpers.CleanupTestAccount(controller, resourceGroupName, accountName);
},
TestUtilities.GetCallingClass(),
TestUtilities.GetCurrentMethodName());
Expand Down
Loading