Skip to content

Commit 45df21e

Browse files
authored
Merge pull request #492 from bgrainger/mysqldata8
Update baseline tests to MySql.Data 8.0.11.
2 parents 6ab9d52 + dd0b53a commit 45df21e

File tree

10 files changed

+50
-76
lines changed

10 files changed

+50
-76
lines changed

tests/MySqlConnector.Tests/MySqlConnectionStringBuilderTests.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ public class MySqlConnectionStringBuilderTests
1010
public void Defaults()
1111
{
1212
var csb = new MySqlConnectionStringBuilder();
13-
#if !BASELINE
1413
Assert.False(csb.AllowPublicKeyRetrieval);
15-
#endif
1614
Assert.False(csb.AllowUserVariables);
1715
Assert.True(csb.AutoEnlist);
1816
Assert.Null(csb.CertificateFile);
@@ -51,7 +49,11 @@ public void Defaults()
5149
#if !BASELINE
5250
Assert.Null(csb.ServerRsaPublicKeyFile);
5351
#endif
52+
#if !BASELINE
5453
Assert.Equal(MySqlSslMode.Preferred, csb.SslMode);
54+
#else
55+
Assert.Equal(MySqlSslMode.Required, csb.SslMode);
56+
#endif
5557
Assert.True(csb.TreatTinyAsBoolean);
5658
Assert.False(csb.UseCompression);
5759
Assert.Equal("", csb.UserID);
@@ -69,6 +71,7 @@ public void ParseConnectionString()
6971
{
7072
ConnectionString = "Data Source=db-server;" +
7173
"Initial Catalog=schema_name;" +
74+
"allowpublickeyretrieval = true;" +
7275
"Allow User Variables=true;" +
7376
"auto enlist=False;" +
7477
"certificate file=file.pfx;" +
@@ -89,7 +92,6 @@ public void ParseConnectionString()
8992
"forcesynchronous=true;" +
9093
"ignore command transaction=true;" +
9194
"ca certificate file=ca.pem;" +
92-
"allow public key retrieval = true;" +
9395
"server rsa public key file=rsa.pem;" +
9496
"load balance=random;" +
9597
#endif
@@ -106,6 +108,7 @@ public void ParseConnectionString()
106108
"Uid=username;" +
107109
"useaffectedrows=false"
108110
};
111+
Assert.True(csb.AllowPublicKeyRetrieval);
109112
Assert.True(csb.AllowUserVariables);
110113
Assert.False(csb.AutoEnlist);
111114
Assert.Equal("file.pfx", csb.CertificateFile);
@@ -126,7 +129,6 @@ public void ParseConnectionString()
126129
Assert.True(csb.ForceSynchronous);
127130
Assert.True(csb.IgnoreCommandTransaction);
128131
Assert.Equal("ca.pem", csb.CACertificateFile);
129-
Assert.True(csb.AllowPublicKeyRetrieval);
130132
Assert.Equal("rsa.pem", csb.ServerRsaPublicKeyFile);
131133
Assert.Equal(MySqlLoadBalance.Random, csb.LoadBalance);
132134
#endif

tests/MySqlConnector.Tests/MySqlConnector.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
</ItemGroup>
3434

3535
<ItemGroup Condition=" '$(Configuration)' == 'Baseline' ">
36-
<PackageReference Include="MySql.Data" Version="6.9.9" />
36+
<PackageReference Include="MySql.Data" Version="8.0.11" />
3737
<Compile Remove="ConnectionTests.cs;FakeMySqlServer.cs;FakeMySqlServerConnection.cs;LoadBalancerTests.cs;NormalizeTests.cs;StatementPreparerTests.cs;TypeMapperTests.cs;Utf8Tests.cs" />
3838
</ItemGroup>
3939

tests/SideBySide/CommandTimeoutTests.cs

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ namespace SideBySide
99
{
1010
public class CommandTimeoutTests : IClassFixture<DatabaseFixture>, IDisposable
1111
{
12+
#if BASELINE
13+
const string c_timeoutMessage = "fatal error";
14+
#else
15+
const string c_timeoutMessage = "timeout";
16+
#endif
17+
1218
public CommandTimeoutTests(DatabaseFixture database)
1319
{
1420
m_database = database;
@@ -73,17 +79,12 @@ public void CommandTimeoutWithSleepSync()
7379
catch (MySqlException ex)
7480
{
7581
sw.Stop();
76-
Assert.Contains("timeout", ex.Message, StringComparison.OrdinalIgnoreCase);
77-
#if !BASELINE
78-
// https://bugs.mysql.com/bug.php?id=86009
82+
Assert.Contains(c_timeoutMessage, ex.Message, StringComparison.OrdinalIgnoreCase);
7983
TestUtilities.AssertDuration(sw, cmd.CommandTimeout * 1000 - 100, 500);
80-
#endif
8184
}
8285
}
8386

84-
#if !BASELINE
8587
Assert.Equal(ConnectionState.Closed, m_connection.State);
86-
#endif
8788
}
8889

8990
[Fact]
@@ -104,17 +105,12 @@ public async Task CommandTimeoutWithSleepAsync()
104105
catch (MySqlException ex)
105106
{
106107
sw.Stop();
107-
Assert.Contains("timeout", ex.Message, StringComparison.OrdinalIgnoreCase);
108-
#if !BASELINE
109-
// https://bugs.mysql.com/bug.php?id=86009
108+
Assert.Contains(c_timeoutMessage, ex.Message, StringComparison.OrdinalIgnoreCase);
110109
TestUtilities.AssertDuration(sw, cmd.CommandTimeout * 1000 - 100, 500);
111-
#endif
112110
}
113111
}
114112

115-
#if !BASELINE
116113
Assert.Equal(ConnectionState.Closed, m_connection.State);
117-
#endif
118114
}
119115

120116
[SkippableFact(Baseline = "https://bugs.mysql.com/bug.php?id=87307")]
@@ -154,9 +150,7 @@ public void MultipleCommandTimeoutWithSleepSync()
154150
}
155151
}
156152

157-
#if !BASELINE
158153
Assert.Equal(ConnectionState.Closed, m_connection.State);
159-
#endif
160154
}
161155

162156
[SkippableFact(Baseline = "https://bugs.mysql.com/bug.php?id=87307")]
@@ -195,9 +189,7 @@ public async Task MultipleCommandTimeoutWithSleepAsync()
195189
}
196190
}
197191

198-
#if !BASELINE
199192
Assert.Equal(ConnectionState.Closed, m_connection.State);
200-
#endif
201193
}
202194

203195
[SkippableFact(Baseline = "https://bugs.mysql.com/bug.php?id=88124")]
@@ -264,17 +256,12 @@ public void TransactionCommandTimeoutWithSleepSync()
264256
catch (MySqlException ex)
265257
{
266258
sw.Stop();
267-
Assert.Contains("timeout", ex.Message, StringComparison.OrdinalIgnoreCase);
268-
#if !BASELINE
269-
// https://bugs.mysql.com/bug.php?id=86009
259+
Assert.Contains(c_timeoutMessage, ex.Message, StringComparison.OrdinalIgnoreCase);
270260
TestUtilities.AssertDuration(sw, cmd.CommandTimeout * 1000 - 100, 500);
271-
#endif
272261
}
273262
}
274263

275-
#if !BASELINE
276264
Assert.Equal(ConnectionState.Closed, m_connection.State);
277-
#endif
278265
}
279266

280267
[Fact]
@@ -296,17 +283,11 @@ public async Task TransactionCommandTimeoutWithSleepAsync()
296283
catch (MySqlException ex)
297284
{
298285
sw.Stop();
299-
Assert.Contains("timeout", ex.Message, StringComparison.OrdinalIgnoreCase);
300-
#if !BASELINE
301-
// https://bugs.mysql.com/bug.php?id=86009
302-
TestUtilities.AssertDuration(sw, cmd.CommandTimeout * 1000 - 100, 500);
303-
#endif
286+
Assert.Contains(c_timeoutMessage, ex.Message, StringComparison.OrdinalIgnoreCase);
304287
}
305288
}
306289

307-
#if !BASELINE
308290
Assert.Equal(ConnectionState.Closed, m_connection.State);
309-
#endif
310291
}
311292

312293
readonly DatabaseFixture m_database;

tests/SideBySide/ConnectAsync.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -270,19 +270,13 @@ public async Task Sha256WithoutSecureConnection()
270270
{
271271
var csb = AppConfig.CreateSha256ConnectionStringBuilder();
272272
csb.SslMode = MySqlSslMode.None;
273-
#if !BASELINE
274273
csb.AllowPublicKeyRetrieval = true;
275-
#endif
276274
using (var connection = new MySqlConnection(csb.ConnectionString))
277275
{
278-
#if BASELINE
279-
await Assert.ThrowsAsync<NotImplementedException>(() => connection.OpenAsync());
280-
#else
281276
if (AppConfig.SupportedFeatures.HasFlag(ServerFeatures.RsaEncryption))
282277
await connection.OpenAsync();
283278
else
284279
await Assert.ThrowsAsync<MySqlException>(() => connection.OpenAsync());
285-
#endif
286280
}
287281
}
288282

@@ -299,16 +293,10 @@ public async Task CachingSha2WithoutSecureConnection()
299293
{
300294
var csb = AppConfig.CreateCachingSha2ConnectionStringBuilder();
301295
csb.SslMode = MySqlSslMode.None;
302-
#if !BASELINE
303296
csb.AllowPublicKeyRetrieval = true;
304-
#endif
305297
using (var connection = new MySqlConnection(csb.ConnectionString))
306298
{
307-
#if BASELINE
308-
await Assert.ThrowsAsync<NotImplementedException>(() => connection.OpenAsync());
309-
#else
310299
await connection.OpenAsync();
311-
#endif
312300
}
313301
}
314302

tests/SideBySide/ConnectSync.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,12 +367,10 @@ public void Sha256WithoutSecureConnection()
367367
{
368368
var csb = AppConfig.CreateSha256ConnectionStringBuilder();
369369
csb.SslMode = MySqlSslMode.None;
370-
#if !BASELINE
371370
csb.AllowPublicKeyRetrieval = true;
372-
#endif
373371
using (var connection = new MySqlConnection(csb.ConnectionString))
374372
{
375-
#if BASELINE || NET45
373+
#if NET45
376374
Assert.Throws<NotImplementedException>(() => connection.Open());
377375
#else
378376
if (AppConfig.SupportedFeatures.HasFlag(ServerFeatures.RsaEncryption))

tests/SideBySide/DataTypes.cs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -812,17 +812,9 @@ public void GetSchemaTable(string column, string table, MySqlDbType mySqlDbType,
812812
DoGetSchemaTable(column, table, mySqlDbType, columnSize, dataType, flags, precision, scale);
813813

814814
[Theory]
815-
[InlineData("`decimal-type` decimal(10,0) NOT NULL", "decimal-type", MySqlDbType.NewDecimal, 11, typeof(decimal), "", 10, 0
816-
#if BASELINE
817-
, Skip = "https://bugs.mysql.com/bug.php?id=88058"
818-
#endif
819-
)]
815+
[InlineData("`decimal-type` decimal(10,0) NOT NULL", "decimal-type", MySqlDbType.NewDecimal, 11, typeof(decimal), "", 10, 0)]
820816
[InlineData("`decimal-type` decimal(10,1) NOT NULL", "decimal-type", MySqlDbType.NewDecimal, 12, typeof(decimal), "", 10, 1)]
821-
[InlineData("`decimal-type` decimal(10,0) UNSIGNED NOT NULL", "decimal-type", MySqlDbType.NewDecimal, 10, typeof(decimal), "", 10, 0
822-
#if BASELINE
823-
, Skip = "https://bugs.mysql.com/bug.php?id=88058"
824-
#endif
825-
)]
817+
[InlineData("`decimal-type` decimal(10,0) UNSIGNED NOT NULL", "decimal-type", MySqlDbType.NewDecimal, 10, typeof(decimal), "", 10, 0)]
826818
[InlineData("`decimal-type` decimal(10,1) UNSIGNED NOT NULL", "decimal-type", MySqlDbType.NewDecimal, 11, typeof(decimal), "", 10, 1)]
827819
[InlineData("`decimal-type` decimal(65,30) NOT NULL", "decimal-type", MySqlDbType.NewDecimal, 67, typeof(decimal), "", 65, 30)]
828820
[InlineData("`decimal-type` decimal(1,1) NOT NULL", "decimal-type", MySqlDbType.NewDecimal, 3, typeof(decimal), "", 1, 1)]
@@ -861,18 +853,13 @@ private void DoGetSchemaTable(string column, string table, MySqlDbType mySqlDbTy
861853
Assert.Equal(ordinal, schema["ColumnOrdinal"]);
862854
Assert.Equal(dataType, schema["DataType"]);
863855
#if BASELINE
864-
// https://bugs.mysql.com/bug.php?id=87868, https://bugs.mysql.com/bug.php?id=87876
865-
if (!column.EndsWith("blob", StringComparison.OrdinalIgnoreCase) && column != "text" && dataType != typeof(Guid) && columnSize != int.MaxValue)
856+
// https://bugs.mysql.com/bug.php?id=87876
857+
if (columnSize != int.MaxValue)
866858
Assert.Equal(columnSize, schema["ColumnSize"]);
867859
#else
868860
Assert.Equal(columnSize, schema["ColumnSize"]);
869861
#endif
870-
#if BASELINE
871-
// https://bugs.mysql.com/bug.php?id=87876
872-
Assert.Equal(isLong && columnSize != int.MaxValue, schema["IsLong"]);
873-
#else
874862
Assert.Equal(isLong, schema["IsLong"]);
875-
#endif
876863
Assert.Equal(isAutoIncrement, schema["IsAutoIncrement"]);
877864
Assert.Equal(isKey, schema["IsKey"]);
878865
Assert.Equal(allowDbNull, schema["AllowDBNull"]);

tests/SideBySide/ParameterTests.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ public void ConstructorSimple()
8181
Assert.Equal(0, parameter.Precision);
8282
Assert.Equal(0, parameter.Scale);
8383
Assert.Equal(0, parameter.Size);
84-
#if !NETCOREAPP1_1_2
84+
#if BASELINE
85+
Assert.Equal(DataRowVersion.Default, parameter.SourceVersion);
86+
#elif !NETCOREAPP1_1_2
8587
Assert.Equal(DataRowVersion.Current, parameter.SourceVersion);
8688
#endif
8789
}
@@ -99,7 +101,9 @@ public void ConstructorNameValue()
99101
Assert.Equal(0, parameter.Precision);
100102
Assert.Equal(0, parameter.Scale);
101103
Assert.Equal(0, parameter.Size);
102-
#if !NETCOREAPP1_1_2
104+
#if BASELINE
105+
Assert.Equal(DataRowVersion.Default, parameter.SourceVersion);
106+
#elif !NETCOREAPP1_1_2
103107
Assert.Equal(DataRowVersion.Current, parameter.SourceVersion);
104108
#endif
105109
#if BASELINE
@@ -122,7 +126,9 @@ public void ConstructorNameType()
122126
Assert.Equal(0, parameter.Precision);
123127
Assert.Equal(0, parameter.Scale);
124128
Assert.Equal(0, parameter.Size);
125-
#if !NETCOREAPP1_1_2
129+
#if BASELINE
130+
Assert.Equal(DataRowVersion.Default, parameter.SourceVersion);
131+
#elif !NETCOREAPP1_1_2
126132
Assert.Equal(DataRowVersion.Current, parameter.SourceVersion);
127133
#endif
128134
#if BASELINE
@@ -145,7 +151,9 @@ public void ConstructorNameTypeSize()
145151
Assert.Equal(0, parameter.Precision);
146152
Assert.Equal(0, parameter.Scale);
147153
Assert.Equal(4, parameter.Size);
148-
#if !NETCOREAPP1_1_2
154+
#if BASELINE
155+
Assert.Equal(DataRowVersion.Default, parameter.SourceVersion);
156+
#elif !NETCOREAPP1_1_2
149157
Assert.Equal(DataRowVersion.Current, parameter.SourceVersion);
150158
#endif
151159
#if BASELINE
@@ -168,7 +176,9 @@ public void ConstructorNameTypeSizeSourceColumn()
168176
Assert.Equal(0, parameter.Precision);
169177
Assert.Equal(0, parameter.Scale);
170178
Assert.Equal(4, parameter.Size);
171-
#if !NETCOREAPP1_1_2
179+
#if BASELINE
180+
Assert.Equal(DataRowVersion.Default, parameter.SourceVersion);
181+
#elif !NETCOREAPP1_1_2
172182
Assert.Equal(DataRowVersion.Current, parameter.SourceVersion);
173183
#endif
174184
Assert.Equal("source", parameter.SourceColumn);

tests/SideBySide/SideBySide.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
</ItemGroup>
4242

4343
<ItemGroup Condition=" '$(Configuration)' == 'Baseline' ">
44-
<PackageReference Include="MySql.Data" Version="6.9.9" />
44+
<PackageReference Include="MySql.Data" Version="8.0.11" />
4545
</ItemGroup>
4646

4747
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.1.2' ">

tests/SideBySide/SslTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public SslTests(DatabaseFixture database)
1313
m_database = database;
1414
}
1515

16+
#if !BASELINE
1617
[SkippableFact(ConfigSettings.RequiresSsl)]
1718
public async Task ConnectSslPreferred()
1819
{
@@ -25,18 +26,17 @@ public async Task ConnectSslPreferred()
2526
using (var cmd = connection.CreateCommand())
2627
{
2728
await connection.OpenAsync();
28-
#if !BASELINE
2929
Assert.True(connection.SslIsEncrypted);
3030
Assert.True(connection.SslIsSigned);
3131
Assert.True(connection.SslIsAuthenticated);
3232
Assert.False(connection.SslIsMutuallyAuthenticated);
33-
#endif
3433
cmd.CommandText = "SHOW SESSION STATUS LIKE 'Ssl_version'";
3534
var sslVersion = (string)await cmd.ExecuteScalarAsync();
3635
Assert.False(string.IsNullOrWhiteSpace(sslVersion));
3736
}
3837
}
3938
}
39+
#endif
4040

4141
[SkippableTheory(ConfigSettings.RequiresSsl | ConfigSettings.KnownClientCertificate)]
4242
[InlineData("ssl-client.pfx", null, null)]

tests/SideBySide/TestUtilities.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,19 @@ public static string GetSkipReason(ServerFeatures serverFeatures, ConfigSettings
4141
return null;
4242

4343
var csb = AppConfig.CreateConnectionStringBuilder();
44-
if (configSettings.HasFlag(ConfigSettings.RequiresSsl) && (csb.SslMode == MySqlSslMode.None || csb.SslMode == MySqlSslMode.Preferred))
44+
if (configSettings.HasFlag(ConfigSettings.RequiresSsl) && (csb.SslMode == MySqlSslMode.None
45+
#if !BASELINE
46+
|| csb.SslMode == MySqlSslMode.Preferred
47+
#endif
48+
))
4549
return "Requires SslMode=Required or higher in connection string";
4650

4751
if (configSettings.HasFlag(ConfigSettings.TrustedHost) &&
48-
(csb.SslMode == MySqlSslMode.None || csb.SslMode == MySqlSslMode.Preferred || csb.SslMode == MySqlSslMode.Required))
52+
(csb.SslMode == MySqlSslMode.None ||
53+
#if !BASELINE
54+
csb.SslMode == MySqlSslMode.Preferred ||
55+
#endif
56+
csb.SslMode == MySqlSslMode.Required))
4957
{
5058
return "Requires SslMode=VerifyCA or higher in connection string";
5159
}

0 commit comments

Comments
 (0)