Add Agent Job and Job Step request handlers (#635)

* Stage changes

* Fix update job request handler

* WIP

* Additional agent handler updates

* Setup agent job step create test

* Fix Step update handler
This commit is contained in:
Karl Burtram
2018-06-13 10:02:25 -07:00
committed by GitHub
parent 7c1f78a678
commit 8dda34c95a
52 changed files with 705 additions and 619 deletions

View File

@@ -10,6 +10,7 @@ using Microsoft.SqlTools.ServiceLayer.Agent;
using Microsoft.SqlTools.ServiceLayer.Agent.Contracts;
using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.ServiceLayer.Utility;
using Moq;
using Xunit;
@@ -20,68 +21,66 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
/// <summary>
/// TestHandleCreateAgentJobRequest
/// </summary>
//[Fact]
[Fact]
public async Task TestHandleCreateAgentJobRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
{
var createContext = new Mock<RequestContext<CreateAgentJobResult>>();
// setup
var service = new AgentService();
var connectionResult = await LiveConnectionHelper.InitLiveConnectionInfoAsync("master", queryTempFile.FilePath);
await service.HandleCreateAgentJobRequest(new CreateAgentJobParams
{
OwnerUri = connectionResult.ConnectionInfo.OwnerUri,
Job = new AgentJobInfo()
{
Name = "Test Job",
Owner = "sa",
Description = "Test job description",
CurrentExecutionStatus = 1,
LastRunOutcome = 1,
CurrentExecutionStep = "Step 1",
Enabled = false,
HasTarget = false,
HasSchedule = false,
HasStep = false,
Runnable = true,
Category = "Cateory 1",
CategoryId = 1,
CategoryType = 1,
LastRun = "today",
NextRun = "tomorrow",
JobId = Guid.NewGuid().ToString()
}
}, createContext.Object);
createContext.VerifyAll();
var job = AgentTestUtils.GetTestJobInfo();
await AgentTestUtils.DeleteAgentJob(service, connectionResult, job, verify: false);
// test
await AgentTestUtils.CreateAgentJob(service, connectionResult, job);
// cleanup
await AgentTestUtils.DeleteAgentJob(service, connectionResult, job, verify: false);
}
}
/// <summary>
/// TestHandleCreateAgentJobStepRequest
/// TestHandleUpdateAgentJobRequest
/// </summary>
//[Fact]
public async Task TestHandleCreateAgentJobStepRequest()
[Fact]
public async Task TestHandleUpdateAgentJobRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
{
var createContext = new Mock<RequestContext<CreateAgentJobStepResult>>();
// setup
var service = new AgentService();
var connectionResult = await LiveConnectionHelper.InitLiveConnectionInfoAsync("master", queryTempFile.FilePath);
await service.HandleCreateAgentJobStepRequest(new CreateAgentJobStepParams
{
OwnerUri = connectionResult.ConnectionInfo.OwnerUri,
Step = new AgentJobStepInfo()
{
// JobId = Guid.NewGuid().ToString(),
Script = @"c:\xplat\test.sql",
ScriptName = "Test Script",
var job = AgentTestUtils.GetTestJobInfo();
await AgentTestUtils.DeleteAgentJob(service, connectionResult, job, verify: false);
await AgentTestUtils.CreateAgentJob(service, connectionResult, job);
}
}, createContext.Object);
createContext.VerifyAll();
// test
await AgentTestUtils.UpdateAgentJob(service, connectionResult, job);
// cleanup
await AgentTestUtils.DeleteAgentJob(service, connectionResult, job, verify: false);
}
}
/// <summary>
/// TestHandleDeleteAgentJobRequest
/// </summary>
[Fact]
public async Task TestHandleDeleteAgentJobRequest()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
{
// setup
var service = new AgentService();
var connectionResult = await LiveConnectionHelper.InitLiveConnectionInfoAsync("master", queryTempFile.FilePath);
var job = AgentTestUtils.GetTestJobInfo();
await AgentTestUtils.DeleteAgentJob(service, connectionResult, job, verify: false);
await AgentTestUtils.CreateAgentJob(service, connectionResult, job);
// test
await AgentTestUtils.DeleteAgentJob(service, connectionResult, job, verify: false);
}
}
}
}