Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Refactor Test TDS Servers. Expand functional testing of connection pooling and transient failures.#3488

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
mdaigle wants to merge9 commits intodotnet:main
base:main
Choose a base branch
Loading
frommdaigle:dev/mdaigle/failover-tds-server
Draft
Show file tree
Hide file tree
Changes from1 commit
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
PrevPrevious commit
NextNext commit
Remove duplicate server start code from ManualTests
  • Loading branch information
@mdaigle
mdaigle committedJul 17, 2025
commit522abba1bcc8d27cf114460824f897c1c4097828
Original file line numberDiff line numberDiff line change
Expand Up@@ -300,7 +300,6 @@
<Compile Include="SQL\VectorTest\VectorTypeBackwardCompatibilityTests.cs" />
<Compile Include="SQL\VectorTest\NativeVectorFloat32Tests.cs" />
<Compile Include="SQL\SqlCommand\SqlCommandStoredProcTest.cs" />
<Compile Include="TracingTests\TestTdsServer.cs" />
<Compile Include="XUnitAssemblyAttributes.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,6 +12,7 @@
using System.ServiceProcess;
using System.Text;
using Microsoft.Data.SqlClient.ManualTesting.Tests.DataCommon;
using Microsoft.SqlServer.TDS.Servers;
using Microsoft.Win32;
using Xunit;

Expand DownExpand Up@@ -129,18 +130,23 @@ private void ConnectionTest(ConnectionTestParameters connectionTestParameters)
string userId = string.IsNullOrWhiteSpace(builder.UserID) ? "user" : builder.UserID;
string password = string.IsNullOrWhiteSpace(builder.Password) ? "password" : builder.Password;

using TestTdsServer server = TestTdsServer.StartTestServer(enableFedAuth: false, enableLog: false, connectionTimeout: 15,
methodName: "",
#if NET9_0_OR_GREATER
X509CertificateLoader.LoadPkcs12FromFile(s_fullPathToPfx, "nopassword", X509KeyStorageFlags.UserKeySet),
#else
new X509Certificate2(s_fullPathToPfx, "nopassword", X509KeyStorageFlags.UserKeySet),
#endif
encryptionProtocols: connectionTestParameters.EncryptionProtocols,
encryptionType: connectionTestParameters.TdsEncryptionType);

builder = new(server.ConnectionString)
using GenericTDSServer server = new GenericTDSServer(new TDSServerArguments
{
#if NET9_0_OR_GREATER
EncryptionCertificate = X509CertificateLoader.LoadPkcs12FromFile(s_fullPathToPfx, "nopassword", X509KeyStorageFlags.UserKeySet),
#else
EncryptionCertificate = new X509Certificate2(s_fullPathToPfx, "nopassword", X509KeyStorageFlags.UserKeySet),
#endif
EncryptionProtocols = connectionTestParameters.EncryptionProtocols,
Encryption = connectionTestParameters.TdsEncryptionType,
});

server.Start();

builder = new()
{
DataSource = $"localhost,{server.EndPoint.Port}",
ConnectTimeout = 15,
UserID = userId,
Password = password,
TrustServerCertificate = connectionTestParameters.TrustServerCertificate,
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.

using System;
using Microsoft.SqlServer.TDS.Servers;
using Xunit;

namespace Microsoft.Data.SqlClient.ManualTesting.Tests
Expand All@@ -23,8 +24,13 @@ public class ConnectionExceptionTest
[ConditionalFact(nameof(IsNotKerberos))]
public void TestConnectionStateWithErrorClass20()
{
using TestTdsServer server = TestTdsServer.StartTestServer();
using SqlConnection conn = new(server.ConnectionString);
using GenericTDSServer server = new GenericTDSServer();
server.Start();
using SqlConnection conn = new(
new SqlConnectionStringBuilder
{
DataSource = $"localhost,{server.EndPoint.Port}",
}.ConnectionString);

conn.Open();
SqlCommand cmd = conn.CreateCommand();
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -483,7 +483,7 @@ public void ConnectionOpenAsyncErrorTest()
}).Dispose();
}

private static void CollectStatisticsDiagnostics(Action<string> sqlOperation,bool enableServerLogging = false,[CallerMemberName] string methodName = "")
private static void CollectStatisticsDiagnostics(Action<string> sqlOperation, [CallerMemberName] string methodName = "")
{
bool statsLogged = false;
bool operationHasError = false;
Expand DownExpand Up@@ -670,10 +670,18 @@ private static void CollectStatisticsDiagnostics(Action<string> sqlOperation, bo
{

Console.WriteLine(string.Format("Test: {0} Enabled Listeners", methodName));
using (var server = TestTdsServer.StartServerWithQueryEngine(new DiagnosticsQueryEngine(), enableLog: enableServerLogging, methodName: methodName))

using (var server = new GenericTDSServer(new DiagnosticsQueryEngine(), new TDSServerArguments()))
{
server.Start(methodName);
Console.WriteLine(string.Format("Test: {0} Started Server", methodName));
sqlOperation(server.ConnectionString);

var connectionString = new SqlConnectionStringBuilder
{
DataSource = $"localhost,{server.EndPoint.Port}",
}.ConnectionString;

sqlOperation(connectionString);

Console.WriteLine(string.Format("Test: {0} SqlOperation Successful", methodName));

Expand DownExpand Up@@ -859,11 +867,16 @@ private static async Task CollectStatisticsDiagnosticsAsync(Func<string, Task> s
using (DiagnosticListener.AllListeners.Subscribe(diagnosticListenerObserver))
{
Console.WriteLine(string.Format("Test: {0} Enabled Listeners", methodName));
using (var server =TestTdsServer.StartServerWithQueryEngine(new DiagnosticsQueryEngine(),methodName: methodName))
using (var server =new GenericTDSServer(new DiagnosticsQueryEngine(),new TDSServerArguments()))
{
server.Start(methodName);
Console.WriteLine(string.Format("Test: {0} Started Server", methodName));

await sqlOperation(server.ConnectionString);
var connectionString = new SqlConnectionStringBuilder
{
DataSource = $"localhost,{server.EndPoint.Port}",
}.ConnectionString;
await sqlOperation(connectionString);

Console.WriteLine(string.Format("Test: {0} SqlOperation Successful", methodName));

Expand Down
View file
Open in desktop

This file was deleted.


[8]ページ先頭

©2009-2025 Movatter.jp