-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #342: Disable pipelining on MySQL/MariaDB connections if not ex…
…plicitly enabled (#346)
- Loading branch information
Showing
2 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
grate.unittests/Basic/Infrastructure/MariaDB/MariaDbDatabase_.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System.Data.Common; | ||
using System.Threading.Tasks; | ||
using FluentAssertions; | ||
using grate.Configuration; | ||
using grate.Migration; | ||
using grate.unittests.TestInfrastructure; | ||
using Microsoft.Data.SqlClient; | ||
using Microsoft.Extensions.Logging; | ||
using MySqlConnector; | ||
using NUnit.Framework; | ||
|
||
namespace grate.unittests.Basic.Infrastructure.MariaDB; | ||
|
||
// ReSharper disable once InconsistentNaming | ||
public class MariaDbDatabase_ | ||
{ | ||
[Test] | ||
public async Task Disables_pipelining_if_not_explicitly_set_in_connection_string() | ||
{ | ||
var connStr = "Server=dummy"; | ||
var cfg = new GrateConfiguration() { ConnectionString = connStr }; | ||
var mariaDb = new InspectableMariaDbDatabase(); | ||
await mariaDb.InitializeConnections(cfg); | ||
|
||
var conn = mariaDb.GetConnection(); | ||
var builder = new MySqlConnectionStringBuilder(conn.ConnectionString); | ||
builder.Pipelining.Should().BeFalse(); | ||
} | ||
|
||
[Test] | ||
public async Task Leaves_pipelining_as_configured_if_set_explicitly_in_connection_string() | ||
{ | ||
var connStr = "Server=dummy;Pipelining=true"; | ||
var cfg = new GrateConfiguration() { ConnectionString = connStr }; | ||
var mariaDb = new InspectableMariaDbDatabase(); | ||
await mariaDb.InitializeConnections(cfg); | ||
|
||
var conn = mariaDb.GetConnection(); | ||
var builder = new MySqlConnectionStringBuilder(conn.ConnectionString); | ||
builder.Pipelining.Should().BeTrue(); | ||
} | ||
|
||
private class InspectableMariaDbDatabase : MariaDbDatabase | ||
{ | ||
public InspectableMariaDbDatabase() : base(TestConfig.LogFactory.CreateLogger<InspectableMariaDbDatabase>()) | ||
{ | ||
} | ||
|
||
public DbConnection GetConnection() => base.Connection; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters