mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 01:25:40 -05:00
* Initial SQL Agent WIP * Fix test build break * wip * wip2 * additonal SQL Agent history parsing code * Fix namespace sorting * Hook up agent\jobs method * Fix broken integration test build * Added handler for job history request (#586) * fixed agent service tests * added job history handler * code review refactoring * Turn off another failing test * Disable failing test * Feature/agent1 adbist (#592) * fixed agent service tests * added job history handler * code review refactoring * refactored code * small refactor * code review changes * Remove unused code * Remove unused test file * Feature/agent1 adbist (#593) * fixed agent service tests * added job history handler * code review refactoring * refactored code * small refactor * code review changes * changed constant casing * added handler for job actions * Reenable disabled test * cleaned up code
97 lines
3.6 KiB
C#
97 lines
3.6 KiB
C#
//
|
|
// Copyright (c) Microsoft. All rights reserved.
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
//
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.SqlClient;
|
|
using System.IO;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.SqlServer.Management.Smo;
|
|
using Microsoft.SqlServer.Management.XEvent;
|
|
using Microsoft.SqlTools.Hosting.Protocol;
|
|
using Microsoft.SqlTools.ServiceLayer.Agent;
|
|
using Microsoft.SqlTools.ServiceLayer.Agent.Contracts;
|
|
using Microsoft.SqlTools.ServiceLayer.Connection;
|
|
using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
|
|
using Microsoft.SqlTools.ServiceLayer.Profiler;
|
|
using Microsoft.SqlTools.ServiceLayer.Profiler.Contracts;
|
|
using Microsoft.SqlTools.ServiceLayer.Test.Common;
|
|
using Moq;
|
|
using Xunit;
|
|
|
|
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
|
|
{
|
|
public class AgentServiceTests
|
|
{
|
|
/// <summary>
|
|
/// Verify that a start profiling request starts a profiling session
|
|
/// </summary>
|
|
[Fact]
|
|
public async Task TestHandleAgentJobsRequest()
|
|
{
|
|
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
|
{
|
|
var connectionResult = await LiveConnectionHelper.InitLiveConnectionInfoAsync("master", queryTempFile.FilePath);
|
|
|
|
var requestParams = new AgentJobsParams()
|
|
{
|
|
OwnerUri = connectionResult.ConnectionInfo.OwnerUri
|
|
};
|
|
|
|
var requestContext = new Mock<RequestContext<AgentJobsResult>>();
|
|
|
|
AgentService service = new AgentService();
|
|
await service.HandleAgentJobsRequest(requestParams, requestContext.Object);
|
|
requestContext.VerifyAll();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Verify that a job history request returns the job history
|
|
/// </summary>
|
|
[Fact]
|
|
public async Task TestHandleJobHistoryRequests()
|
|
{
|
|
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
|
{
|
|
var connectionResult = await LiveConnectionHelper.InitLiveConnectionInfoAsync("master", queryTempFile.FilePath);
|
|
|
|
var requestParams = new AgentJobHistoryParams()
|
|
{
|
|
OwnerUri = connectionResult.ConnectionInfo.OwnerUri,
|
|
JobId = "e9420919-b8c2-4a3d-a26c-b7ffde5342cf"
|
|
};
|
|
|
|
var requestContext = new Mock<RequestContext<AgentJobHistoryResult>>();
|
|
|
|
AgentService service = new AgentService();
|
|
await service.HandleJobHistoryRequest(requestParams, requestContext.Object);
|
|
requestContext.VerifyAll();
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public async Task TestHandleAgentJobActionRequest()
|
|
{
|
|
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
|
|
{
|
|
var connectionResult = await LiveConnectionHelper.InitLiveConnectionInfoAsync("master", queryTempFile.FilePath);
|
|
|
|
var requestParams = new AgentJobActionParams()
|
|
{
|
|
OwnerUri = connectionResult.ConnectionInfo.OwnerUri,
|
|
JobName = "Agent history clean up: distribution"
|
|
};
|
|
|
|
var requestContext = new Mock<RequestContext<AgentJobActionResult>>();
|
|
|
|
AgentService service = new AgentService();
|
|
await service.HandleJobActionRequest(requestParams, requestContext.Object);
|
|
requestContext.VerifyAll();
|
|
}
|
|
}
|
|
}
|
|
} |