Skip to content
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 @@ -147,5 +147,4 @@ steps:
--blame-hang
--blame-hang-dump-type full
--blame-hang-timeout 10m
retryCountOnTaskFailure: ${{parameters.retryCountOnManualTests }}
continueOnError: true
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,4 @@ steps:
--blame-hang
--blame-hang-dump-type full
--blame-hang-timeout 10m
retryCountOnTaskFailure: ${{parameters.retryCountOnManualTests }}
continueOnError: true
2 changes: 0 additions & 2 deletions eng/pipelines/common/templates/steps/run-all-tests-step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ steps:
-p:Filter="category=flaky"
-p:CollectCodeCoverage=false
continueOnError: true
retryCountOnTaskFailure: ${{parameters.retryCountOnManualTests }}

- ${{ else }}: # Linux or macOS
- ${{if eq(parameters.referenceType, 'Project')}}:
Expand Down Expand Up @@ -350,4 +349,3 @@ steps:
verbosityRestore: Detailed
verbosityPack: Detailed
continueOnError: true
retryCountOnTaskFailure: ${{parameters.retryCountOnManualTests }}
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@
<Compile Include="SQL\ParameterTest\StePermutationSet.cs" />
<Compile Include="SQL\ParameterTest\SteTypeBoundaries.cs" />
<Compile Include="SQL\ParameterTest\StreamInputParam.cs" />
<Compile Include="SQL\ParameterTest\StreamInputParameterTests.cs" />
<Compile Include="SQL\ParameterTest\TvpColumnBoundariesTests.cs" />
<Compile Include="SQL\ParameterTest\TvpQueryHintsTests.cs" />
<Compile Include="SQL\ParameterTest\SqlVariantParameterTests.cs" />
<Compile Include="SQL\ParameterTest\DateTimeVariantTests.cs" />
<Compile Include="SQL\ParameterTest\OutputParameterTests.cs" />
<Compile Include="SQL\ParameterTest\TvpTest.cs" />
<Compile Include="SQL\SplitPacketTest\SplitPacketTest.cs" />
<Compile Include="SQL\SqlCommand\SqlCommandCancelTest.cs" />
Expand Down Expand Up @@ -237,14 +243,104 @@
<!-- @TODO: Move these into some folder or a resx or something -->
<Content Include="DDDataTypesTest_Data.xml"
CopyToOutputDirectory="PreserveNewest" />
<Content Include="SqlParameterTest_DebugMode.bsl"
CopyToOutputDirectory="PreserveNewest" />
<Content Include="SqlParameterTest_DebugMode_Azure.bsl"
CopyToOutputDirectory="PreserveNewest" />
<Content Include="SqlParameterTest_ReleaseMode.bsl"
CopyToOutputDirectory="PreserveNewest" />
<Content Include="SqlParameterTest_ReleaseMode_Azure.bsl"
CopyToOutputDirectory="PreserveNewest" />

<!-- Split baseline files for individual test groups -->
<Content Include="SQL\ParameterTest\StreamInputParameter_DebugMode.bsl">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>StreamInputParameter_DebugMode.bsl</Link>
</Content>
<Content Include="SQL\ParameterTest\StreamInputParameter_DebugMode_Azure.bsl">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>StreamInputParameter_DebugMode_Azure.bsl</Link>
</Content>
<Content Include="SQL\ParameterTest\StreamInputParameter_ReleaseMode.bsl">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>StreamInputParameter_ReleaseMode.bsl</Link>
</Content>
<Content Include="SQL\ParameterTest\StreamInputParameter_ReleaseMode_Azure.bsl">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>StreamInputParameter_ReleaseMode_Azure.bsl</Link>
</Content>
<Content Include="SQL\ParameterTest\TvpColumnBoundaries_DebugMode.bsl">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>TvpColumnBoundaries_DebugMode.bsl</Link>
</Content>
<Content Include="SQL\ParameterTest\TvpColumnBoundaries_DebugMode_Azure.bsl">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>TvpColumnBoundaries_DebugMode_Azure.bsl</Link>
</Content>
<Content Include="SQL\ParameterTest\TvpColumnBoundaries_ReleaseMode.bsl">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>TvpColumnBoundaries_ReleaseMode.bsl</Link>
</Content>
<Content Include="SQL\ParameterTest\TvpColumnBoundaries_ReleaseMode_Azure.bsl">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>TvpColumnBoundaries_ReleaseMode_Azure.bsl</Link>
</Content>
<Content Include="SQL\ParameterTest\TvpQueryHints_DebugMode.bsl">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>TvpQueryHints_DebugMode.bsl</Link>
</Content>
<Content Include="SQL\ParameterTest\TvpQueryHints_DebugMode_Azure.bsl">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>TvpQueryHints_DebugMode_Azure.bsl</Link>
</Content>
<Content Include="SQL\ParameterTest\TvpQueryHints_ReleaseMode.bsl">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>TvpQueryHints_ReleaseMode.bsl</Link>
</Content>
<Content Include="SQL\ParameterTest\TvpQueryHints_ReleaseMode_Azure.bsl">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>TvpQueryHints_ReleaseMode_Azure.bsl</Link>
</Content>
<Content Include="SQL\ParameterTest\SqlVariantParameter_DebugMode.bsl">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>SqlVariantParameter_DebugMode.bsl</Link>
</Content>
<Content Include="SQL\ParameterTest\SqlVariantParameter_DebugMode_Azure.bsl">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>SqlVariantParameter_DebugMode_Azure.bsl</Link>
</Content>
<Content Include="SQL\ParameterTest\SqlVariantParameter_ReleaseMode.bsl">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>SqlVariantParameter_ReleaseMode.bsl</Link>
</Content>
<Content Include="SQL\ParameterTest\SqlVariantParameter_ReleaseMode_Azure.bsl">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>SqlVariantParameter_ReleaseMode_Azure.bsl</Link>
</Content>
<Content Include="SQL\ParameterTest\DateTimeVariant_DebugMode.bsl">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>DateTimeVariant_DebugMode.bsl</Link>
</Content>
<Content Include="SQL\ParameterTest\DateTimeVariant_DebugMode_Azure.bsl">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>DateTimeVariant_DebugMode_Azure.bsl</Link>
</Content>
<Content Include="SQL\ParameterTest\DateTimeVariant_ReleaseMode.bsl">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>DateTimeVariant_ReleaseMode.bsl</Link>
</Content>
<Content Include="SQL\ParameterTest\DateTimeVariant_ReleaseMode_Azure.bsl">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>DateTimeVariant_ReleaseMode_Azure.bsl</Link>
</Content>
<Content Include="SQL\ParameterTest\OutputParameter_DebugMode.bsl">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>OutputParameter_DebugMode.bsl</Link>
</Content>
<Content Include="SQL\ParameterTest\OutputParameter_DebugMode_Azure.bsl">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>OutputParameter_DebugMode_Azure.bsl</Link>
</Content>
<Content Include="SQL\ParameterTest\OutputParameter_ReleaseMode.bsl">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>OutputParameter_ReleaseMode.bsl</Link>
</Content>
<Content Include="SQL\ParameterTest\OutputParameter_ReleaseMode_Azure.bsl">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>OutputParameter_ReleaseMode_Azure.bsl</Link>
</Content>
</ItemGroup>

<!-- Items to include in AE test set -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ private void CompareJsonFiles()
}
}

private void PrintJsonDataToFile(SqlConnection connection)
private void PrintJsonDataToFile(SqlConnection connection, string tableName)
{
DeleteFile(_outputFile);
using (SqlCommand command = new SqlCommand("SELECT [data] FROM [jsonTab]", connection))
using (SqlCommand command = new SqlCommand($"SELECT [data] FROM {tableName}", connection))
{
using (SqlDataReader reader = command.ExecuteReader(CommandBehavior.SequentialAccess))
{
Expand All @@ -99,10 +99,10 @@ private void PrintJsonDataToFile(SqlConnection connection)
}
}

private async Task PrintJsonDataToFileAsync(SqlConnection connection)
private async Task PrintJsonDataToFileAsync(SqlConnection connection, string tableName)
{
DeleteFile(_outputFile);
using (SqlCommand command = new SqlCommand("SELECT [data] FROM [jsonTab]", connection))
using (SqlCommand command = new SqlCommand($"SELECT [data] FROM {tableName}", connection))
{
using (SqlDataReader reader = await command.ExecuteReaderAsync(CommandBehavior.SequentialAccess))
{
Expand All @@ -129,9 +129,9 @@ private async Task PrintJsonDataToFileAsync(SqlConnection connection)
}
}

private void StreamJsonFileToServer(SqlConnection connection)
private void StreamJsonFileToServer(SqlConnection connection, string tableName)
{
using (SqlCommand cmd = new SqlCommand("INSERT INTO [jsonTab] (data) VALUES (@jsondata)", connection))
using (SqlCommand cmd = new SqlCommand($"INSERT INTO {tableName} (data) VALUES (@jsondata)", connection))
{
using (StreamReader jsonFile = File.OpenText(_jsonFile))
{
Expand All @@ -141,9 +141,9 @@ private void StreamJsonFileToServer(SqlConnection connection)
}
}

private async Task StreamJsonFileToServerAsync(SqlConnection connection)
private async Task StreamJsonFileToServerAsync(SqlConnection connection, string tableName)
{
using (SqlCommand cmd = new SqlCommand("INSERT INTO [jsonTab] (data) VALUES (@jsondata)", connection))
using (SqlCommand cmd = new SqlCommand($"INSERT INTO {tableName} (data) VALUES (@jsondata)", connection))
{
using (StreamReader jsonFile = File.OpenText(_jsonFile))
{
Expand All @@ -168,9 +168,10 @@ public void TestJsonStreaming()
using (SqlConnection connection = new SqlConnection(DataTestUtility.TCPConnectionString))
{
connection.Open();
DataTestUtility.CreateTable(connection, "jsonTab", "(data json)");
StreamJsonFileToServer(connection);
PrintJsonDataToFile(connection);
var tableName = DataTestUtility.GetLongName("jsonTab");
DataTestUtility.CreateTable(connection, tableName, "(data json)");
StreamJsonFileToServer(connection, tableName);
PrintJsonDataToFile(connection, tableName);
CompareJsonFiles();
DeleteFile(_jsonFile);
DeleteFile(_outputFile);
Expand All @@ -184,9 +185,10 @@ public async Task TestJsonStreamingAsync()
using (SqlConnection connection = new SqlConnection(DataTestUtility.TCPConnectionString))
{
await connection.OpenAsync();
DataTestUtility.CreateTable(connection, "jsonTab", "(data json)");
await StreamJsonFileToServerAsync(connection);
await PrintJsonDataToFileAsync(connection);
var tableName = DataTestUtility.GetLongName("jsonTab");
DataTestUtility.CreateTable(connection, tableName, "(data json)");
await StreamJsonFileToServerAsync(connection, tableName);
await PrintJsonDataToFileAsync(connection, tableName);
CompareJsonFiles();
DeleteFile(_jsonFile);
DeleteFile(_outputFile);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Globalization;
using System.IO;
using System.Text;
using System.Threading;
using Xunit;

namespace Microsoft.Data.SqlClient.ManualTesting.Tests
{
/// <summary>
/// Tests for DateTime variant parameters with different date/time types.
/// These tests run independently with their own baseline comparison.
/// </summary>
[Collection("ParameterBaselineTests")]
public class DateTimeVariantTests
{
private readonly string _connStr;

public DateTimeVariantTests()
{
_connStr = DataTestUtility.TCPConnectionString;
}

[Trait("Category", "flaky")]
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))]
public void DateTimeVariantParameterTest()
{
Assert.True(RunTestAndCompareWithBaseline());
}

private bool RunTestAndCompareWithBaseline()
{
CultureInfo previousCulture = Thread.CurrentThread.CurrentCulture;
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
try
{
string outputPath = "DateTimeVariant.out";
string baselinePath;
#if DEBUG
if (DataTestUtility.IsNotAzureServer() || DataTestUtility.IsManagedInstance)
{
baselinePath = "DateTimeVariant_DebugMode.bsl";
}
else
{
baselinePath = "DateTimeVariant_DebugMode_Azure.bsl";
}
#else
if (DataTestUtility.IsNotAzureServer() || DataTestUtility.IsManagedInstance)
{
baselinePath = "DateTimeVariant_ReleaseMode.bsl";
}
else
{
baselinePath = "DateTimeVariant_ReleaseMode_Azure.bsl";
}
#endif

var fstream = new FileStream(outputPath, FileMode.Create, FileAccess.Write, FileShare.Read);
var swriter = new StreamWriter(fstream, Encoding.UTF8);
var twriter = new TvpTest.CarriageReturnLineFeedReplacer(swriter);
Console.SetOut(twriter);

// Run Test
DateTimeVariantTest.TestAllDateTimeWithDataTypeAndVariant(_connStr);

Console.Out.Flush();
Console.Out.Dispose();

// Recover the standard output stream
StreamWriter standardOutput = new(Console.OpenStandardOutput());
standardOutput.AutoFlush = true;
Console.SetOut(standardOutput);

// Compare output file
var comparisonResult = FindDiffFromBaseline(baselinePath, outputPath);

if (string.IsNullOrEmpty(comparisonResult))
{
return true;
}

Console.WriteLine("DateTimeVariantParameterTest Failed!");
Console.WriteLine("Please compare baseline: {0} with output: {1}", Path.GetFullPath(baselinePath), Path.GetFullPath(outputPath));
Console.WriteLine("Comparison Results:");
Console.WriteLine(comparisonResult);
return false;
}
finally
{
Thread.CurrentThread.CurrentCulture = previousCulture;
}
}

private static string FindDiffFromBaseline(string baselinePath, string outputPath)
{
var expectedLines = File.ReadAllLines(baselinePath);
var outputLines = File.ReadAllLines(outputPath);

var comparisonSb = new StringBuilder();

var expectedLength = expectedLines.Length;
var outputLength = outputLines.Length;
var findDiffLength = Math.Min(expectedLength, outputLength);

for (var lineNo = 0; lineNo < findDiffLength; lineNo++)
{
if (!expectedLines[lineNo].Equals(outputLines[lineNo]))
{
comparisonSb.AppendFormat("** DIFF at line {0} \n", lineNo);
comparisonSb.AppendFormat("A : {0} \n", outputLines[lineNo]);
comparisonSb.AppendFormat("E : {0} \n", expectedLines[lineNo]);
}
}

var startIndex = findDiffLength - 1;
if (startIndex < 0)
{
startIndex = 0;
}

if (findDiffLength < expectedLength)
{
comparisonSb.AppendFormat("** MISSING \n");
for (var lineNo = startIndex; lineNo < expectedLength; lineNo++)
{
comparisonSb.AppendFormat("{0} : {1}", lineNo, expectedLines[lineNo]);
}
}
if (findDiffLength < outputLength)
{
comparisonSb.AppendFormat("** EXTRA \n");
for (var lineNo = startIndex; lineNo < outputLength; lineNo++)
{
comparisonSb.AppendFormat("{0} : {1}", lineNo, outputLines[lineNo]);
}
}

return comparisonSb.ToString();
}
}
}
Loading
Loading