mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-29 01:25:41 -05:00
Adding External Streaming Job I/O validation to DacFxService (#1106)
* checkpoint * Not having cake, nor eating it * Working * Swapping external dll for nupkg * Extracting statement out of full TSQL * Improving error message * Fixing filename capitalization * Reverting csproj changes * Adding updated sr.cs file * VS lost tracking on strings file? * PR feedback * resx additions * More updated string files * Swapped nuget for dll * Revert "Swapped nuget for dll" This reverts commit 6013f3fadf58ebc7e3590a46811d9fd9fc3eaa4a. * Bumped netcore version to pull in support for extern aliasing nugets
This commit is contained in:
@@ -62,6 +62,24 @@ AS
|
||||
RETURN 0
|
||||
";
|
||||
|
||||
private string dacpacsFolder = Path.Combine("..", "..", "..", "DacFx", "Dacpacs");
|
||||
|
||||
private string goodCreateStreamingJob = @"EXEC sys.sp_create_streaming_job @NAME = 'myJob', @STATEMENT = 'INSERT INTO SqlOutputStream SELECT
|
||||
timeCreated,
|
||||
machine.temperature as machine_temperature,
|
||||
machine.pressure as machine_pressure,
|
||||
ambient.temperature as ambient_temperature,
|
||||
ambient.humidity as ambient_humidity
|
||||
FROM EdgeHubInputStream'";
|
||||
|
||||
private string missingCreateBothStreamingJob = @$"EXEC sys.sp_create_streaming_job @NAME = 'myJob', @STATEMENT = 'INSERT INTO MissingSqlOutputStream SELECT
|
||||
timeCreated,
|
||||
machine.temperature as machine_temperature,
|
||||
machine.pressure as machine_pressure,
|
||||
ambient.temperature as ambient_temperature,
|
||||
ambient.humidity as ambient_humidity
|
||||
FROM MissingEdgeHubInputStream'";
|
||||
|
||||
private LiveConnectionHelper.TestConnectionResult GetLiveAutoCompleteTestObjects()
|
||||
{
|
||||
var result = LiveConnectionHelper.InitLiveConnectionInfo();
|
||||
@@ -754,6 +772,56 @@ RETURN 0
|
||||
dacfxRequestContext.VerifyAll();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verify that streaming job
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Test]
|
||||
public async Task ValidateStreamingJob()
|
||||
{
|
||||
var dacfxRequestContext = new Mock<RequestContext<ValidateStreamingJobResult>>();
|
||||
DacFxService service = new DacFxService();
|
||||
|
||||
ValidateStreamingJobResult expectedResult;
|
||||
|
||||
// Positive case: both input and output are present
|
||||
|
||||
expectedResult = new ValidateStreamingJobResult() { Success = true };
|
||||
dacfxRequestContext.Setup((RequestContext<ValidateStreamingJobResult> x) => x.SendResult(It.Is<ValidateStreamingJobResult>((result) => ValidateStreamingJobErrors(expectedResult, result) == true))).Returns(Task.FromResult(new object()));
|
||||
|
||||
ValidateStreamingJobParams parameters = new ValidateStreamingJobParams()
|
||||
{
|
||||
PackageFilePath = Path.Combine(dacpacsFolder, "StreamingJobTestDb.dacpac"),
|
||||
CreateStreamingJobTsql = goodCreateStreamingJob
|
||||
};
|
||||
|
||||
await service.HandleValidateStreamingJobRequest(parameters, dacfxRequestContext.Object);
|
||||
dacfxRequestContext.VerifyAll();
|
||||
|
||||
// Negative case: input and output streams are both missing from model
|
||||
|
||||
const string errorMessage = @"Validation for external streaming job 'myJob' failed:
|
||||
Streaming query statement contains a reference to missing input stream 'MissingEdgeHubInputStream'. You must add it to the database model.
|
||||
Streaming query statement contains a reference to missing output stream 'MissingSqlOutputStream'. You must add it to the database model.";
|
||||
expectedResult = new ValidateStreamingJobResult() { Success = false, ErrorMessage = errorMessage };
|
||||
dacfxRequestContext.Setup((RequestContext<ValidateStreamingJobResult> x) => x.SendResult(It.Is<ValidateStreamingJobResult>((result) => ValidateStreamingJobErrors(expectedResult, result)))).Returns(Task.FromResult(new object()));
|
||||
|
||||
parameters = new ValidateStreamingJobParams()
|
||||
{
|
||||
PackageFilePath = Path.Combine(dacpacsFolder, "StreamingJobTestDb.dacpac"),
|
||||
CreateStreamingJobTsql = missingCreateBothStreamingJob
|
||||
};
|
||||
|
||||
await service.HandleValidateStreamingJobRequest(parameters, dacfxRequestContext.Object);
|
||||
dacfxRequestContext.VerifyAll();
|
||||
}
|
||||
|
||||
private bool ValidateStreamingJobErrors(ValidateStreamingJobResult expected, ValidateStreamingJobResult actual)
|
||||
{
|
||||
return expected.Success == actual.Success
|
||||
&& expected.ErrorMessage == actual.ErrorMessage;
|
||||
}
|
||||
|
||||
private bool ValidateOptions(DeploymentOptions expected, DeploymentOptions actual)
|
||||
{
|
||||
System.Reflection.PropertyInfo[] deploymentOptionsProperties = expected.GetType().GetProperties();
|
||||
Binary file not shown.
@@ -17,9 +17,9 @@
|
||||
<ProjectReference Include="../Microsoft.SqlTools.Test.CompletionExtension/Microsoft.SqlTools.Test.CompletionExtension.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Moq" />
|
||||
<PackageReference Include="System.Net.Http"/>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" />
|
||||
<PackageReference Include="Moq" />
|
||||
<PackageReference Include="System.Net.Http" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" />
|
||||
<PackageReference Include="nunit" />
|
||||
<PackageReference Include="nunit3testadapter" />
|
||||
<PackageReference Include="nunit.console" />
|
||||
@@ -33,9 +33,12 @@
|
||||
<ItemGroup>
|
||||
<Content Remove=".\Agent\NotebookResources\TestNotebook.ipynb" />
|
||||
<EmbeddedResource Include=".\Agent\NotebookResources\TestNotebook.ipynb" />
|
||||
<Content Include="..\..\src\Microsoft.SqlTools.ServiceLayer\Migration\Metadata\**">
|
||||
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<Content Include="..\..\src\Microsoft.SqlTools.ServiceLayer\Migration\Metadata\**">
|
||||
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="DacFx\Dacpacs\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user