Skip to content

Tests | Activate "ActiveIssue" tests #3304

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

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
232fefb
Use Assert.Throws instead of home-grown
MichelZ Nov 18, 2024
2f95c8a
Activate WeakRefTestYukonSpecific, it runs fine on Linux
MichelZ Nov 18, 2024
4aa1123
Activate IntegratedAuthenticationTest, it runs fine
MichelZ Nov 18, 2024
c97b74a
Activate LocalDBTest, make sure Local DB is present. They run fine
MichelZ Nov 18, 2024
ae33c5f
Activate reliability tests, they run fine
MichelZ Nov 18, 2024
6fcd405
Activate Credential Tests, they seem to work fine
MichelZ Nov 18, 2024
68b7e1a
Activate CommandCancel tests, add Conditions to existing issue
MichelZ Nov 18, 2024
372c4bd
Activate Udt tests, they seem to work fine
MichelZ Nov 18, 2024
a46ca19
Activate PacketNumberWraparound test, it works fine
MichelZ Nov 18, 2024
aefc7f2
Improve certificate tests by checking IsAdmin outside the constructor
MichelZ Nov 18, 2024
fbcb046
- Remove AsyncTest (why would Async be faster than Sync?)
MichelZ Nov 18, 2024
801d2f3
Fix grammatical errors
MichelZ Nov 18, 2024
04bce8e
Use Close instead of Dispose, as Dispose swallows the exception
MichelZ Nov 24, 2024
910688a
Remove comment about IPv6 & Cert as this now works in NET8+
MichelZ Nov 24, 2024
e44241e
Do not run XEvent test on azure
MichelZ Nov 24, 2024
0e3ad41
The rest of the tests run fine on Azure
MichelZ Nov 24, 2024
19340e4
Fix azure check
MichelZ Nov 24, 2024
76af285
Disable more tests for Azure
MichelZ Nov 25, 2024
178c7cf
Also disable named instances
MichelZ Nov 25, 2024
6c0204e
Remove ExectueXmlReaderTest on ARM
MichelZ Nov 25, 2024
0b106c5
Disable tests with proxy for azure
MichelZ Nov 25, 2024
7e2dc88
Add data ordering to queries
MichelZ Nov 27, 2024
d1a2347
Enable test on ARM
MichelZ Nov 27, 2024
2c7320d
Remove whitespace
MichelZ Nov 27, 2024
b5005bc
Restore newline
MichelZ Dec 3, 2024
1cca601
Removing duplicated method
benrr101 Apr 28, 2025
6fda8e2
Merge branch 'main' into dev/russellben/mz-enable-activeissue-tests
benrr101 Jul 10, 2025
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 @@ -26,4 +26,5 @@
<!-- References that only apply to netcore -->
<PackageReference Include="System.Configuration.ConfigurationManager" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ public static bool IsAzureSynapse
{
s_sqlServerEngineEdition ??= GetSqlServerProperty(TCPConnectionString, "EngineEdition");
}
_ = int.TryParse(s_sqlServerEngineEdition, out int engineEditon);
return engineEditon == 6;
_ = int.TryParse(s_sqlServerEngineEdition, out int engineEdition);
return engineEdition == 6;
}
}

Expand Down Expand Up @@ -233,6 +233,16 @@ static DataTestUtility()
}
}

public static IEnumerable<object[]> GetConnectionStringsWithEnclaveMemberData()
{
return GetConnectionStrings(true).Select(x => new object[] { x });
}

public static IEnumerable<object[]> GetConnectionStringsWithoutEnclaveMemberData()
{
return GetConnectionStrings(false).Select(x => new object[] { x });
}

public static IEnumerable<string> ConnectionStrings => GetConnectionStrings(withEnclave: true);

public static IEnumerable<string> GetConnectionStrings(bool withEnclave)
Expand Down Expand Up @@ -456,17 +466,17 @@ public static bool IsNotAzureServer()
return !AreConnStringsSetup() || !Utils.IsAzureSqlServer(new SqlConnectionStringBuilder(TCPConnectionString).DataSource);
}

public static bool IsNotNamedInstance()
{
return !AreConnStringsSetup() || !new SqlConnectionStringBuilder(TCPConnectionString).DataSource.Contains(@"\");
}

public static bool IsLocalHost()
{
SqlConnectionStringBuilder builder = new(DataTestUtility.TCPConnectionString);
return ParseDataSource(builder.DataSource, out string hostname, out _, out _) && string.Equals("localhost", hostname, StringComparison.OrdinalIgnoreCase);
}

public static bool IsNotNamedInstance()
{
return !AreConnStringsSetup() || !new SqlConnectionStringBuilder(TCPConnectionString).DataSource.Contains(@"\");
}

// Synapse: Always Encrypted is not supported with Azure Synapse.
// Ref: https://feedback.azure.com/forums/307516-azure-synapse-analytics/suggestions/17858869-support-always-encrypted-in-sql-data-warehouse
public static bool IsAKVSetupAvailable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
<Compile Include="SQL\AsyncTest\BeginExecAsyncTest.cs" />
<Compile Include="SQL\AsyncTest\BeginExecReaderAsyncTest.cs" />
<Compile Include="SQL\AsyncTest\XmlReaderAsyncTest.cs" />
<Compile Include="SQL\AsyncTest\AsyncTest.cs" />
<Compile Include="SQL\AsyncTest\AsyncCancelledConnectionsTest.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TestSet)' == '' OR '$(TestSet)' == '2'">
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

namespace Microsoft.Data.SqlClient.ManualTesting.Tests
{
[PlatformSpecific(TestPlatforms.Windows)]
public class CertificateTest : IDisposable
{
#region Private Fields
Expand Down Expand Up @@ -75,10 +76,11 @@ public CertificateTest()
SlashInstanceName = $"\\{InstanceName}";
}

Assert.True(DataTestUtility.IsAdmin, "CertificateTest class needs to be run in Admin mode.");

CreateValidCertificate(s_fullPathToPowershellScript);
_thumbprint = Environment.GetEnvironmentVariable(ThumbPrintEnvName, EnvironmentVariableTarget.Machine);
if (IsAdmin())
{
CreateValidCertificate(s_fullPathToPowershellScript);
_thumbprint = Environment.GetEnvironmentVariable(ThumbPrintEnvName, EnvironmentVariableTarget.Machine);
}
}

private static bool IsLocalHost()
Expand All @@ -91,17 +93,16 @@ private static bool IsLocalHost()
private static bool AreConnStringsSetup() => DataTestUtility.AreConnStringsSetup();
private static bool IsNotAzureServer() => DataTestUtility.IsNotAzureServer();
private static bool UseManagedSNIOnWindows() => DataTestUtility.UseManagedSNIOnWindows;
private static bool IsAdmin() => DataTestUtility.IsAdmin;

[ActiveIssue("31754")]
[ConditionalFact(nameof(AreConnStringsSetup), nameof(IsNotAzureServer), nameof(IsLocalHost))]
[PlatformSpecific(TestPlatforms.Windows)]
public void OpenningConnectionWithGoodCertificateTest()
[ConditionalFact(nameof(AreConnStringsSetup), nameof(IsNotAzureServer), nameof(IsLocalHost), nameof(IsAdmin))]
public void OpeningConnectionWithGoodCertificateTest()
{
SqlConnectionStringBuilder builder = new(DataTestUtility.TCPConnectionString);

// confirm that ForceEncryption is enabled
using SqlConnection notEncryptedConnection = new(builder.ConnectionString);
builder.Encrypt = SqlConnectionEncryptOption.Optional;
using SqlConnection notEncryptedConnection = new(builder.ConnectionString);
notEncryptedConnection.Open();
Assert.Equal(ConnectionState.Open, notEncryptedConnection.State);

Expand All @@ -122,9 +123,7 @@ public void OpenningConnectionWithGoodCertificateTest()

// Provided hostname in certificate are:
// localhost, FQDN, Loopback IPv4: 127.0.0.1, IPv6: ::1
[ActiveIssue("31754")]
[ConditionalFact(nameof(AreConnStringsSetup), nameof(IsNotAzureServer), nameof(IsLocalHost))]
[PlatformSpecific(TestPlatforms.Windows)]
[ConditionalFact(nameof(AreConnStringsSetup), nameof(IsNotAzureServer), nameof(IsLocalHost), nameof(IsAdmin))]
public void OpeningConnectionWitHNICTest()
{
// Mandatory
Expand All @@ -142,11 +141,6 @@ public void OpeningConnectionWitHNICTest()
connection.Open();
Assert.Equal(ConnectionState.Open, connection.State);

// Ipv6 however causes name mistmatch error
// In net6 Manged SNI does not check for SAN. Therefore Application using Net6 have to use FQDN as HNIC
// According to above no other hostname in certificate than FQDN will work in net6 which is same as SubjectName in case of RemoteCertificateNameMismatch
// Net7.0 the new API added by dotnet runtime will check SANS and then SubjectName

builder.DataSource = IPV6 + SlashInstanceName;
builder.HostNameInCertificate = Dns.GetHostEntry(Environment.MachineName).HostName;
builder.Encrypt = SqlConnectionEncryptOption.Mandatory;
Expand All @@ -165,9 +159,8 @@ public void OpeningConnectionWitHNICTest()
Assert.Equal(ConnectionState.Open, connection3.State);
}
}

[ConditionalFact(nameof(AreConnStringsSetup), nameof(UseManagedSNIOnWindows), nameof(IsNotAzureServer), nameof(IsLocalHost))]
[PlatformSpecific(TestPlatforms.Windows)]

[ConditionalFact(nameof(AreConnStringsSetup), nameof(UseManagedSNIOnWindows), nameof(IsNotAzureServer), nameof(IsLocalHost), nameof(IsAdmin))]
public void RemoteCertificateNameMismatchErrorTest()
{
SqlConnectionStringBuilder builder = new(DataTestUtility.TCPConnectionString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
using Microsoft.Data.SqlClient.TestUtilities;
using Xunit;

namespace Microsoft.Data.SqlClient.ManualTesting.Tests
Expand All @@ -23,15 +24,14 @@ public static void RunAllTestsForSingleServer_NP()
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
DataTestUtility.AssertThrowsWrapper<PlatformNotSupportedException>(() => RunAllTestsForSingleServer(DataTestUtility.NPConnectionString, true));
DataTestUtility.AssertThrowsWrapper<PlatformNotSupportedException>(() => RunAllTestsForSingleServer(DataTestUtility.NPConnectionString));
}
else
{
RunAllTestsForSingleServer(DataTestUtility.NPConnectionString, true);
RunAllTestsForSingleServer(DataTestUtility.NPConnectionString);
}
}

[ActiveIssue("5540")]
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
public static void RunAllTestsForSingleServer_TCP()
{
Expand Down Expand Up @@ -119,7 +119,34 @@ static async Task LocalCopyTo(Stream source, Stream destination, int bufferSize,
Assert.Fail($"input and output differ at index {index}, input={inputData[index]}, output={outputData[index]}");
}
}
}

[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer))]
[MemberData(nameof(DataTestUtility.GetConnectionStringsWithEnclaveMemberData), MemberType = typeof(DataTestUtility))]
public static void XEventsStreamingTest(string connectionString)
{
TestXEventsStreaming(connectionString);
}

[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsUsingNativeSNI), nameof(DataTestUtility.IsNotNamedInstance), nameof(DataTestUtility.IsNotAzureServer))]
[MemberData(nameof(DataTestUtility.GetConnectionStringsWithEnclaveMemberData), MemberType = typeof(DataTestUtility))]
public static void TestTimeoutDuringReadAsyncWithClosedReaderTest(string connectionString)
{
TimeoutDuringReadAsyncWithClosedReaderTest(connectionString);
}

[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotNamedInstance), nameof(DataTestUtility.IsNotAzureServer))]
[MemberData(nameof(DataTestUtility.GetConnectionStringsWithEnclaveMemberData), MemberType = typeof(DataTestUtility))]
public static void NonFatalTimeoutDuringReadTest(string connectionString)
{
NonFatalTimeoutDuringRead(connectionString);
}

[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
[MemberData(nameof(DataTestUtility.GetConnectionStringsWithEnclaveMemberData), MemberType = typeof(DataTestUtility))]
public static void XmlReaderTest(string connectionString)
{
ExecuteXmlReaderTest(connectionString);
}

private static byte[] CreateBinaryTable(SqlConnection connection, string tableName, int packetSize)
Expand Down Expand Up @@ -152,7 +179,7 @@ IF OBJECT_ID('dbo.{tableName}', 'U') IS NOT NULL
return data;
}

private static void RunAllTestsForSingleServer(string connectionString, bool usingNamePipes = false)
private static void RunAllTestsForSingleServer(string connectionString)
{
RowBuffer(connectionString);
InvalidRead(connectionString);
Expand All @@ -165,7 +192,6 @@ private static void RunAllTestsForSingleServer(string connectionString, bool usi
TimestampRead(connectionString);
OrphanReader(connectionString);
BufferSize(connectionString);
ExecuteXmlReaderTest(connectionString);
SequentialAccess(connectionString);
HasRowsTest(connectionString);
CloseConnection(connectionString);
Expand All @@ -178,17 +204,6 @@ private static void RunAllTestsForSingleServer(string connectionString, bool usi
ReadTextReader(connectionString);
StreamingBlobDataTypes(connectionString);
OutOfOrderGetChars(connectionString);
TestXEventsStreaming(connectionString);

// These tests fail with named pipes, since they try to do DNS lookups on named pipe paths.
if (!usingNamePipes)
{
if (DataTestUtility.IsUsingNativeSNI())
{
TimeoutDuringReadAsyncWithClosedReaderTest(connectionString);
}
NonFatalTimeoutDuringRead(connectionString);
}
}

private static void MultipleResults(string connectionString)
Expand Down Expand Up @@ -679,7 +694,7 @@ private static void ExecuteXmlReaderTest(string connectionString)
using (SqlConnection conn = new SqlConnection(connectionString))
{
conn.Open();
using (SqlCommand cmd = new SqlCommand("select employeeId, lastname, firstname from employees for xml auto", conn))
using (SqlCommand cmd = new SqlCommand("select employeeId, lastname, firstname from employees order by employeeId asc for xml auto", conn))
{
XmlReader xr;
using (xr = cmd.ExecuteXmlReader())
Expand Down Expand Up @@ -708,7 +723,7 @@ private static void ExecuteXmlReaderTest(string connectionString)
}

// use a big result to fill up the pipe and do a partial read
cmd.CommandText = "select * from orders for xml auto";
cmd.CommandText = "select * from orders order by orderid asc for xml auto";
string errorMessage;
using (xr = cmd.ExecuteXmlReader())
{
Expand Down Expand Up @@ -752,9 +767,9 @@ private static void ExecuteXmlReaderTest(string connectionString)

// multiple results
cmd.CommandText =
"select orderid from orders where orderid < 10253 for xml auto;" +
"select customerid from customers where customerid < 'ANTON' for xml auto;" +
"select employeeId from employees where employeeid < 3 for xml auto;";
"select orderid from orders where orderid < 10253 order by orderid asc for xml auto;" +
"select customerid from customers where customerid < 'ANTON' order by customerid asc for xml auto;" +
"select employeeId from employees where employeeid < 3 order by employeeid asc for xml auto;";
using (xr = cmd.ExecuteXmlReader())
{
string[] expectedResults =
Expand Down Expand Up @@ -893,7 +908,7 @@ private static void SequentialAccess(string connectionString)
}
}

using (SqlCommand cmd = new SqlCommand("select * from employees", conn))
using (SqlCommand cmd = new SqlCommand("select * from employees order by EmployeeID", conn))
{
// test sequential access with partial reads
using (reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess))
Expand Down Expand Up @@ -2030,7 +2045,7 @@ private static void NonFatalTimeoutDuringRead(string connectionString)

// Close will now observe the stored timeout error
string errorMessage = SystemDataResourceManager.Instance.SQL_Timeout_Execution;
DataTestUtility.AssertThrowsWrapper<SqlException>(reader.Dispose, errorMessage);
DataTestUtility.AssertThrowsWrapper<SqlException>(reader.Close, errorMessage);
}
}
}
Expand Down
Loading
Loading