Skip to content

Commit 6ba4694

Browse files
Tests | Fix issues with Azure Synapse (#1099)
1 parent 89e15c4 commit 6ba4694

File tree

8 files changed

+225
-99
lines changed

8 files changed

+225
-99
lines changed

src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/AsyncTest/AsyncTimeoutTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ public enum AsyncAPI
2525
ExecuteXmlReaderAsync
2626
}
2727

28-
[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
28+
// Synapse: WAITFOR DELAY not supported [Parse error at line: 1, column: 1: Incorrect syntax near 'WAITFOR'.]
29+
[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))]
2930
[ClassData(typeof(AsyncTimeoutTestVariations))]
3031
public static void TestDelayedAsyncTimeout(AsyncAPI api, string commonObj, int delayPeriod, bool marsEnabled) =>
3132
RunTest(api, commonObj, delayPeriod, marsEnabled);

src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/DataReaderTest/DataReaderTest.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public static void CheckSparseColumnBit()
136136
}
137137

138138
// Synapse: Statement 'Drop Database' is not supported in this version of SQL Server.
139-
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer))]
139+
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer), nameof(DataTestUtility.IsNotAzureSynapse))]
140140
public static void CollatedDataReaderTest()
141141
{
142142
var databaseName = DataTestUtility.GetUniqueName("DB");
@@ -293,7 +293,7 @@ first_name varchar(100) null,
293293
Assert.Contains("user_id", names, StringComparer.Ordinal);
294294
}
295295

296-
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
296+
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))]
297297
public static void CheckNullRowVersionIsBDNull()
298298
{
299299
lock (s_rowVersionLock)
@@ -323,7 +323,8 @@ public static void CheckNullRowVersionIsBDNull()
323323
}
324324
}
325325

326-
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
326+
// Synapse: Cannot find data type 'rowversion'.
327+
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))]
327328
public static void CheckLegacyNullRowVersionIsEmptyArray()
328329
{
329330
lock (s_rowVersionLock)

src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/RandomStressTest/SqlRandomTypeInfoCollection.cs

Lines changed: 57 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
namespace Microsoft.Data.SqlClient.ManualTesting.Tests
1111
{
1212
/// <summary>
13-
/// Defines a collection of types to be used by the test. Tests can start with CreateSql2005Collection or
13+
/// Defines a collection of types to be used by the test. Tests start with
1414
/// CreateSql2008Collection and add/remove types, as needed.
1515
/// </summary>
1616
public sealed class SqlRandomTypeInfoCollection : System.Collections.ObjectModel.KeyedCollection<SqlDbType, SqlRandomTypeInfo>
1717
{
18-
private static readonly SqlRandomTypeInfo[] s_sql2005Types =
18+
private static readonly SqlRandomTypeInfo[] s_sql2008Types =
1919
{
2020
// var types
2121
new SqlVarBinaryTypeInfo(),
@@ -67,11 +67,62 @@ public sealed class SqlRandomTypeInfoCollection : System.Collections.ObjectModel
6767

6868
// xml
6969
new SqlXmlTypeInfo(),
70+
71+
// date/time types
72+
new SqlDateTypeInfo(),
73+
new SqlDateTime2TypeInfo(),
74+
new SqlDateTimeOffsetTypeInfo(),
75+
new SqlTimeTypeInfo(),
7076
};
7177

72-
// types added in SQL 2008
73-
private static readonly SqlRandomTypeInfo[] s_newInSql2008Types =
78+
private static readonly SqlRandomTypeInfo[] s_sqlSynapseTypes =
7479
{
80+
// var types
81+
new SqlVarBinaryTypeInfo(),
82+
new SqlVarCharTypeInfo(),
83+
new SqlNVarCharTypeInfo(),
84+
85+
// integer data types
86+
new SqlBigIntTypeInfo(),
87+
new SqlIntTypeInfo(),
88+
new SqlSmallIntTypeInfo(),
89+
new SqlTinyIntTypeInfo(),
90+
91+
// fixed length blobs
92+
new SqlCharTypeInfo(),
93+
new SqlNCharTypeInfo(),
94+
new SqlBinaryTypeInfo(),
95+
96+
// large blobs
97+
new SqlImageTypeInfo(),
98+
99+
// bit
100+
new SqlBitTypeInfo(),
101+
102+
// decimal
103+
new SqlDecimalTypeInfo(),
104+
105+
// money types
106+
new SqlMoneyTypeInfo(),
107+
new SqlSmallMoneyTypeInfo(),
108+
109+
// float types
110+
new SqRealTypeInfo(),
111+
new SqFloatTypeInfo(),
112+
113+
// typestamp (== rowversion)
114+
new SqlRowVersionTypeInfo(),
115+
116+
// unique identifier (== guid)
117+
new SqlUniqueIdentifierTypeInfo(),
118+
119+
// date/time types
120+
new SqlDateTimeTypeInfo(),
121+
new SqlSmallDateTimeTypeInfo(),
122+
123+
// variant
124+
new SqlVariantTypeInfo(),
125+
75126
// date/time types
76127
new SqlDateTypeInfo(),
77128
new SqlDateTime2TypeInfo(),
@@ -152,19 +203,11 @@ public void AddRange(SqlRandomTypeInfo[] types)
152203
}
153204

154205
/// <summary>
155-
/// creates a collection of types supported in SQL 2005
156-
/// </summary>
157-
public static SqlRandomTypeInfoCollection CreateSql2005Collection()
158-
{
159-
return new SqlRandomTypeInfoCollection(s_sql2005Types);
160-
}
161-
162-
/// <summary>
163-
/// creates a collection of types supported in SQL 2005 and 2008
206+
/// creates a collection of types supported in SQL 2008+
164207
/// </summary>
165208
public static SqlRandomTypeInfoCollection CreateSql2008Collection()
166209
{
167-
return new SqlRandomTypeInfoCollection(s_sql2005Types, s_newInSql2008Types);
210+
return DataTestUtility.IsNotAzureSynapse() ? new SqlRandomTypeInfoCollection(s_sql2008Types) : new SqlRandomTypeInfoCollection(s_sqlSynapseTypes);
168211
}
169212

170213
/// <summary>

src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/RandomStressTest/SqlRandomTypesForSqlServer.cs

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,49 @@ internal sealed class SqlVariantTypeInfo : SqlRandomTypeInfo
13151315
new SqlSmallDateTimeTypeInfo(),
13161316
};
13171317

1318+
private static readonly SqlRandomTypeInfo[] s_variantSubTypesSynapse =
1319+
{
1320+
// var types
1321+
new SqlVarBinaryTypeInfo(),
1322+
new SqlVarCharTypeInfo(),
1323+
new SqlNVarCharTypeInfo(),
1324+
1325+
// integer data types
1326+
new SqlBigIntTypeInfo(),
1327+
new SqlIntTypeInfo(),
1328+
new SqlSmallIntTypeInfo(),
1329+
new SqlTinyIntTypeInfo(),
1330+
1331+
// fixed length blobs
1332+
new SqlCharTypeInfo(),
1333+
new SqlNCharTypeInfo(),
1334+
new SqlBinaryTypeInfo(),
1335+
1336+
// large blobs
1337+
new SqlImageTypeInfo(),
1338+
1339+
// bit
1340+
new SqlBitTypeInfo(),
1341+
1342+
// decimal
1343+
new SqlDecimalTypeInfo(),
1344+
1345+
// money types
1346+
new SqlMoneyTypeInfo(),
1347+
new SqlSmallMoneyTypeInfo(),
1348+
1349+
// float types
1350+
new SqRealTypeInfo(),
1351+
new SqFloatTypeInfo(),
1352+
1353+
// unique identifier (== guid)
1354+
new SqlUniqueIdentifierTypeInfo(),
1355+
1356+
// date/time types
1357+
new SqlDateTimeTypeInfo(),
1358+
new SqlSmallDateTimeTypeInfo(),
1359+
};
1360+
13181361
public SqlVariantTypeInfo()
13191362
: base(SqlDbType.Variant)
13201363
{
@@ -1338,7 +1381,8 @@ private static bool IsUnicodeType(SqlDbType t)
13381381

13391382
protected override object CreateRandomValueInternal(SqlRandomizer rand, SqlRandomTableColumn columnInfo)
13401383
{
1341-
SqlRandomTypeInfo subType = s_variantSubTypes[rand.NextIntInclusive(0, maxValueInclusive: s_variantSubTypes.Length - 1)];
1384+
SqlRandomTypeInfo subType = DataTestUtility.IsNotAzureSynapse() ? s_variantSubTypes[rand.NextIntInclusive(0, maxValueInclusive: s_variantSubTypes.Length - 1)] : s_variantSubTypesSynapse[rand.NextIntInclusive(0, maxValueInclusive: s_variantSubTypesSynapse.Length - 1)];
1385+
13421386
object val = subType.CreateRandomValue(rand, new SqlRandomTableColumn(subType, SqlRandomColumnOptions.None, 8000));
13431387
char[] cval = val as char[];
13441388
if (cval != null)

0 commit comments

Comments
 (0)