Skip to content

huangpf PR: dev <- Azure:dev #618

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 29 commits into from
Sep 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0d95464
Merge remote-tracking branch 'refs/remotes/Azure/dev' into dev
matthew-rollitt Jul 18, 2016
337fe18
Merge remote-tracking branch 'Azure/dev' into dev
matthew-rollitt Aug 26, 2016
e27ca50
Fix the progress for ARM cmdlets
gandhiniraj Sep 14, 2016
ea99bb5
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
gandhiniraj Sep 14, 2016
977bf17
Merge remote-tracking branch 'Azure/dev' into dev
matthew-rollitt Sep 15, 2016
e4494f2
BUG: "UpdateAndActivate" should be "UploadAndActivate"
matthew-rollitt Sep 15, 2016
fc47e87
Squashed Task-packages into feature/batch-integration-sept-2016
matthew-rollitt Sep 15, 2016
f15b081
Merged feature/job-autocomplete into feature/batch-integration-sept
matthew-rollitt Sep 15, 2016
9f30526
Squashed hotfix/batch-tests-fixup into feature/batch-integration-sept…
matthew-rollitt Sep 15, 2016
cadd870
Squashed hotfix/reactive-task into feature/batch-integration-sept-2016
matthew-rollitt Sep 15, 2016
4cc95fd
general clean up and slns updated to vs2015
matthew-rollitt Sep 16, 2016
f4a288f
Update api-version to use default constant resources api-version for …
vivsriaus Sep 16, 2016
4c7501f
Removed an unneeded test.
matthew-rollitt Sep 16, 2016
12751ee
Remove app.config.
matthew-rollitt Sep 16, 2016
9b58000
IfJobSetsAutoFailure_ItCompletesWhenAnyTaskFails.json wasn't copying …
matthew-rollitt Sep 16, 2016
bccb77d
[no work #] change all tests to remove ResourceGroup as final step
Sep 19, 2016
cbd368f
Merge branch 'dev' of https://github.com/Azure/azure-powershell into …
vivsriaus Sep 19, 2016
14151cf
a few code review changes: reverted package.config and switched sleep…
matthew-rollitt Sep 20, 2016
dc39d37
Enable needs to have the ShouldProcess on the reactiveAzureBatchTask …
matthew-rollitt Sep 21, 2016
8700bd2
[no workItem#] update Commands.Dns helpfile
Sep 21, 2016
e8cc41b
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
Sep 21, 2016
06c98bf
Merge remote-tracking branch 'Azure/dev' into feature/batch-integrati…
matthew-rollitt Sep 21, 2016
7581c7e
Merge branch 'dev' of https://github.com/Azure/azure-powershell into …
vivsriaus Sep 21, 2016
e8d13a2
Updated the method summary
gandhiniraj Sep 21, 2016
69728ec
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
gandhiniraj Sep 21, 2016
e1fce16
Merge pull request #2952 from matthew-rollitt/feature/batch-integrati…
cormacpayne Sep 21, 2016
f3976b9
Merge pull request #2941 from gandhiniraj/dev
cormacpayne Sep 22, 2016
9b0504f
Merge pull request #2951 from vivsriaus/FixResourcesPs1
markcowl Sep 22, 2016
308e601
Merge pull request #2986 from corinajacobson/updates
cormacpayne Sep 22, 2016
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
4 changes: 2 additions & 2 deletions src/ResourceManager/AzureBatch/AzureBatch.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.40629.0
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{95C16AED-FD57-42A0-86C3-2CF4300A4817}"
EndProject
Expand Down
2 changes: 1 addition & 1 deletion src/ResourceManager/AzureBatch/AzureRM.Batch.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ CmdletsToExport = '*'
VariablesToExport = '*'

# Aliases to export from this module
AliasesToExport = @()
AliasesToExport = @('Reactivate-AzureBatchTask')

# List of all modules packaged with this module
ModuleList = @()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.40629.0
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BatchModelGenerator", "BatchModelGenerator.csproj", "{374701E4-539A-459A-9A00-B04E51652997}"
EndProject
Expand Down
20 changes: 10 additions & 10 deletions src/ResourceManager/AzureBatch/BatchModelGenerator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public class Program

private static readonly Dictionary<string, string> OMtoPSClassMappings = new Dictionary<string, string>()
{
{"Microsoft.Azure.Batch.NodeAgentSku", "PSNodeAgentSku"},
{"Microsoft.Azure.Batch.ImageReference", "PSImageReference"},
{"Microsoft.Azure.Batch.AffinityInformation", "PSAffinityInformation"},
{"Microsoft.Azure.Batch.AutoPoolSpecification", "PSAutoPoolSpecification"},
{"Microsoft.Azure.Batch.AutoScaleRun", "PSAutoScaleRun"},
{"Microsoft.Azure.Batch.AutoScaleRunError", "PSAutoScaleRunError"},
{"Microsoft.Azure.Batch.ApplicationPackageReference", "PSApplicationPackageReference"},
{"Microsoft.Azure.Batch.Certificate", "PSCertificate"},
{"Microsoft.Azure.Batch.CertificateReference", "PSCertificateReference"},
{"Microsoft.Azure.Batch.CloudJob", "PSCloudJob"},
Expand All @@ -49,7 +49,12 @@ public class Program
{"Microsoft.Azure.Batch.ComputeNodeUser", "PSComputeNodeUser"},
{"Microsoft.Azure.Batch.DeleteCertificateError", "PSDeleteCertificateError"},
{"Microsoft.Azure.Batch.EnvironmentSetting", "PSEnvironmentSetting"},
{"Microsoft.Azure.Batch.ExitConditions", "PSExitConditions"},
{"Microsoft.Azure.Batch.ExitCodeRangeMapping", "PSExitCodeRangeMapping"},
{"Microsoft.Azure.Batch.ExitCodeMapping", "PSExitCodeMapping"},
{"Microsoft.Azure.Batch.ExitOptions", "PSExitOptions"},
{"Microsoft.Azure.Batch.FileProperties", "PSFileProperties"},
{"Microsoft.Azure.Batch.ImageReference", "PSImageReference"},
{"Microsoft.Azure.Batch.RemoteLoginSettings", "PSRemoteLoginSettings"},
{"Microsoft.Azure.Batch.JobConstraints", "PSJobConstraints"},
{"Microsoft.Azure.Batch.JobExecutionInformation", "PSJobExecutionInformation"},
Expand All @@ -67,6 +72,8 @@ public class Program
{"Microsoft.Azure.Batch.MetadataItem", "PSMetadataItem"},
{"Microsoft.Azure.Batch.MultiInstanceSettings", "PSMultiInstanceSettings"},
{"Microsoft.Azure.Batch.NameValuePair", "PSNameValuePair"},
{"Microsoft.Azure.Batch.NetworkConfiguration", "PSNetworkConfiguration"},
{"Microsoft.Azure.Batch.NodeAgentSku", "PSNodeAgentSku"},
{"Microsoft.Azure.Batch.NodeFile", "PSNodeFile"},
{"Microsoft.Azure.Batch.PoolInformation", "PSPoolInformation"},
{"Microsoft.Azure.Batch.PoolSpecification", "PSPoolSpecification"},
Expand All @@ -81,23 +88,16 @@ public class Program
{"Microsoft.Azure.Batch.StartTaskInformation", "PSStartTaskInformation"},
{"Microsoft.Azure.Batch.SubtaskInformation", "PSSubtaskInformation"},
{"Microsoft.Azure.Batch.TaskConstraints", "PSTaskConstraints"},
{"Microsoft.Azure.Batch.TaskDependencies", "PSTaskDependencies"},
{"Microsoft.Azure.Batch.TaskExecutionInformation", "PSTaskExecutionInformation"},
{"Microsoft.Azure.Batch.TaskInformation", "PSTaskInformation"},
{"Microsoft.Azure.Batch.TaskIdRange", "PSTaskIdRange"},
{"Microsoft.Azure.Batch.TaskSchedulingError", "PSTaskSchedulingError"},
{"Microsoft.Azure.Batch.TaskSchedulingPolicy", "PSTaskSchedulingPolicy"},
{"Microsoft.Azure.Batch.TaskStatistics", "PSTaskStatistics"},
{"Microsoft.Azure.Batch.UsageStatistics", "PSUsageStatistics"},
{"Microsoft.Azure.Batch.AffinityInformation", "PSAffinityInformation"},
{"Microsoft.Azure.Batch.VirtualMachineConfiguration", "PSVirtualMachineConfiguration"},
{"Microsoft.Azure.Batch.WindowsConfiguration", "PSWindowsConfiguration"},
{"Microsoft.Azure.Batch.ApplicationPackageReference", "PSApplicationPackageReference"},
{"Microsoft.Azure.Batch.TaskDependencies", "PSTaskDependencies"},
{"Microsoft.Azure.Batch.NetworkConfiguration", "PSNetworkConfiguration"},
{"Microsoft.Azure.Batch.ExitConditions", "PSExitConditions"},
{"Microsoft.Azure.Batch.ExitOptions", "PSExitOptions"},
{"Microsoft.Azure.Batch.ExitCodeRangeMapping", "PSExitCodeRangeMapping"},
{"Microsoft.Azure.Batch.ExitCodeMapping", "PSExitCodeMapping"},
};


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,19 @@ public static RequestInterceptor CreateFakeGetFileAndPropertiesFromComputeNodeRe
return response;
}

/// <summary>
/// Builds a CloudJobGetResponse object
/// </summary>
public static AzureOperationResponse<ProxyModels.CloudJob, ProxyModels.JobGetHeaders> CreateCloudJobGetResponse(ProxyModels.CloudJob job)
{
var response = new AzureOperationResponse<ProxyModels.CloudJob, ProxyModels.JobGetHeaders>
{
Response = new HttpResponseMessage(HttpStatusCode.OK),
Body = job
};
return response;
}

/// <summary>
/// Builds a CloudJobListResponse object
/// </summary>
Expand Down Expand Up @@ -620,6 +633,16 @@ public static RequestInterceptor CreateFakeGetFileAndPropertiesFromComputeNodeRe

return response;
}
/// <summary>
/// Builds a CloudTaskGetResponse object
/// </summary>
public static AzureOperationResponse<ProxyModels.CloudTask, ProxyModels.TaskGetHeaders> CreateCloudTaskGetResponse(ProxyModels.CloudTask task)
{
var response = new AzureOperationResponse<ProxyModels.CloudTask, ProxyModels.TaskGetHeaders>();
response.Response = new HttpResponseMessage(HttpStatusCode.OK);
response.Body = task;
return response;
}

/// <summary>
/// Builds a CloudTaskListResponse object
Expand Down Expand Up @@ -798,25 +821,22 @@ public static RequestInterceptor CreateFakeGetFileAndPropertiesFromComputeNodeRe
/// <summary>
/// Fabricates a CloudJob that's in the bound state
/// </summary>
public static CloudJob CreateFakeBoundJob(BatchAccountContext context)
public static CloudJob CreateFakeBoundJob(BatchAccountContext context, ProxyModels.CloudJob cloudJob)
{
string jobId = "testJob";

RequestInterceptor interceptor = new RequestInterceptor((baseRequest) =>
{
JobGetBatchRequest request = (JobGetBatchRequest)baseRequest;

request.ServiceRequestFunc = (cancellationToken) =>
{
var response = new AzureOperationResponse<ProxyModels.CloudJob, ProxyModels.JobGetHeaders>();
response.Body = new ProxyModels.CloudJob(id: jobId, poolInfo: new ProxyModels.PoolInformation());
var response = new AzureOperationResponse<ProxyModels.CloudJob, ProxyModels.JobGetHeaders> { Body = cloudJob };

Task<AzureOperationResponse<ProxyModels.CloudJob, ProxyModels.JobGetHeaders>> task = Task.FromResult(response);
return task;
};
});

return context.BatchOMClient.JobOperations.GetJob(jobId, additionalBehaviors: new BatchClientBehavior[] { interceptor });
return context.BatchOMClient.JobOperations.GetJob(cloudJob.Id, additionalBehaviors: new BatchClientBehavior[] { interceptor });
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@
<Reference Include="Hyak.Common">
<HintPath>..\..\..\packages\Hyak.Common.1.0.3\lib\portable-net403+win+wpa81\Hyak.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Batch, Version=5.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Azure.Batch.5.0.0\lib\net45\Microsoft.Azure.Batch.dll</HintPath>
<Reference Include="Microsoft.Azure.Batch, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Azure.Batch.5.1.0\lib\net45\Microsoft.Azure.Batch.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Common">
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.dll</HintPath>
Expand Down Expand Up @@ -270,6 +272,7 @@
<Compile Include="JobSchedules\NewBatchJobScheduleCommandTests.cs" />
<Compile Include="JobSchedules\RemoveBatchJobScheduleCommandTests.cs" />
<Compile Include="Tasks\SetBatchTaskCommandTests.cs" />
<Compile Include="Tasks\EnableBatchTaskCommandTests.cs" />
<Compile Include="Tasks\StopBatchTaskCommandTests.cs" />
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -526,6 +529,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.JobScheduleTests\TestUpdateJobSchedule.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.JobTests\IfJobSetsAutoFailure_ItCompletesWhenAnyTaskFails.json" >
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Batch.Test.ScenarioTests.JobTests\TestDeleteJob.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -713,4 +719,4 @@
<WCFMetadata Include="Service References\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using System.Linq;
using System.Management.Automation;
using System.Threading.Tasks;
using Microsoft.Azure.Batch.Common;
using Xunit;
using BatchClient = Microsoft.Azure.Commands.Batch.Models.BatchClient;
using ProxyModels = Microsoft.Azure.Batch.Protocol.Models;
Expand Down Expand Up @@ -58,7 +59,15 @@ public void GetBatchJobTest()
cmdlet.Filter = null;

// Build a CloudJob instead of querying the service on a Get CloudJob call
AzureOperationResponse<ProxyModels.CloudJob, ProxyModels.JobGetHeaders> response = BatchTestHelpers.CreateCloudJobGetResponse(cmdlet.Id);
ProxyModels.CloudJob job = new ProxyModels.CloudJob
{
Id = cmdlet.Id,
OnAllTasksComplete = ProxyModels.OnAllTasksComplete.TerminateJob,
OnTaskFailure = ProxyModels.OnTaskFailure.PerformExitOptionsJobAction
};

AzureOperationResponse<ProxyModels.CloudJob, ProxyModels.JobGetHeaders> response = BatchTestHelpers.CreateCloudJobGetResponse(job);

RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<
ProxyModels.JobGetOptions,
AzureOperationResponse<ProxyModels.CloudJob, ProxyModels.JobGetHeaders>>(response);
Expand All @@ -74,6 +83,8 @@ public void GetBatchJobTest()
// Verify that the cmdlet wrote the job returned from the OM to the pipeline
Assert.Equal(1, pipeline.Count);
Assert.Equal(cmdlet.Id, pipeline[0].Id);
Assert.Equal(OnTaskFailure.PerformExitOptionsJobAction, pipeline[0].OnTaskFailure);
Assert.Equal(OnAllTasksComplete.TerminateJob, pipeline[0].OnAllTasksComplete);
}

[Fact]
Expand Down Expand Up @@ -229,5 +240,53 @@ public void ListJobsMaxCountTest()

Assert.Equal(idsOfConstructedJobs.Length, pipeline.Count);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void WhenGettingAJobFromTheService_ApplicationPackageReferencesAreMapped()
{
// Setup cmdlet to get a Job by id

BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
cmdlet.BatchContext = context;
cmdlet.Id = "job-1";
cmdlet.Filter = null;

// Build a CloudJob instead of querying the service on a Get CloudJob call
string applicationId = "foo";
string applicationVersion = "beta";
ProxyModels.CloudJob cloudTask = new ProxyModels.CloudJob
{
Id = "job-1",
JobManagerTask = new ProxyModels.JobManagerTask
{
ApplicationPackageReferences = new[]
{
new ProxyModels.ApplicationPackageReference(applicationId, applicationVersion)
}
}
};

AzureOperationResponse<ProxyModels.CloudJob, ProxyModels.JobGetHeaders> response = BatchTestHelpers.CreateCloudJobGetResponse(cloudTask);

RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<ProxyModels.JobGetOptions,
AzureOperationResponse<ProxyModels.CloudJob, ProxyModels.JobGetHeaders>>(response);

cmdlet.AdditionalBehaviors = new List<BatchClientBehavior> { interceptor };

// Setup the cmdlet to write pipeline output to a list that can be examined later
var pipeline = new List<PSCloudJob>();
commandRuntimeMock.Setup(r => r.WriteObject(It.IsAny<PSCloudJob>())).Callback<object>(t => pipeline.Add((PSCloudJob)t));

cmdlet.ExecuteCmdlet();

// Verify that the cmdlet wrote the task returned from the OM to the pipeline
Assert.Equal(1, pipeline.Count);
Assert.Equal(cmdlet.Id, pipeline[0].Id);

var psApplicationPackageReference = pipeline[0].JobManagerTask.ApplicationPackageReferences.First();
Assert.Equal(applicationId, psApplicationPackageReference.ApplicationId);
Assert.Equal(applicationVersion, psApplicationPackageReference.Version);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
using Microsoft.Azure.Batch;
using Microsoft.Azure.Batch.Protocol;
using Microsoft.Azure.Batch.Protocol.Models;
using Microsoft.Azure.Commands.Batch.Models;
using Microsoft.Rest.Azure;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Moq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using Xunit;
using BatchClient = Microsoft.Azure.Commands.Batch.Models.BatchClient;
Expand Down Expand Up @@ -55,9 +57,49 @@ public void NewBatchJobParametersTest()
Assert.Throws<ArgumentNullException>(() => cmdlet.ExecuteCmdlet());

cmdlet.Id = "testJob";
cmdlet.OnAllTasksComplete = Azure.Batch.Common.OnAllTasksComplete.TerminateJob;
cmdlet.OnTaskFailure = Azure.Batch.Common.OnTaskFailure.PerformExitOptionsJobAction;

// Don't go to the service on an Add CloudJob call
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<JobAddParameter, JobAddOptions, AzureOperationHeaderResponse<JobAddHeaders>>();
var interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<JobAddParameter, JobAddOptions, AzureOperationHeaderResponse<JobAddHeaders>>(
new AzureOperationHeaderResponse<JobAddHeaders>(),
request =>
{
Assert.Equal(request.Parameters.OnAllTasksComplete, OnAllTasksComplete.TerminateJob);
Assert.Equal(request.Parameters.OnTaskFailure, OnTaskFailure.PerformExitOptionsJobAction);
});

cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };

// Verify no exceptions when required parameters are set
cmdlet.ExecuteCmdlet();
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void ApplicationPackageReferencesAreSentToService()
{
BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
cmdlet.BatchContext = context;
cmdlet.Id = "job-id";
string applicationId = "foo";
string applicationVersion = "beta";

cmdlet.JobManagerTask = new PSJobManagerTask { ApplicationPackageReferences = new[]
{
new PSApplicationPackageReference { ApplicationId = applicationId, Version = applicationVersion} ,
}};

// Don't go to the service on an Add CloudJob call
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<JobAddParameter, JobAddOptions, AzureOperationHeaderResponse<JobAddHeaders>>(
new AzureOperationHeaderResponse<JobAddHeaders>(),
request =>
{
var applicationPackageReference = request.Parameters.JobManagerTask.ApplicationPackageReferences.First();
Assert.Equal(applicationId, applicationPackageReference.ApplicationId);
Assert.Equal(applicationVersion, applicationPackageReference.Version);
});

cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };

// Verify no exceptions when required parameters are set
Expand Down
Loading