From 33beae138d9e6b87b617fffb81eaecba57f593e6 Mon Sep 17 00:00:00 2001 From: Krzysztof Nozderko Date: Tue, 23 Apr 2024 13:34:44 +0000 Subject: [PATCH] ignore almost all --- .../IntegrationTests/EasyLoggingIT.cs | 25 +-- .../IntegrationTests/MaxLobSizeIT.cs | 1 + .../IntegrationTests/SFBindTestIT.cs | 81 +++++----- .../IntegrationTests/SFDbAdaptorIT.cs | 1 + .../IntegrationTests/SFDbDataReaderIT.cs | 149 +++++++++--------- .../IntegrationTests/SFDbFactoryIT.cs | 1 + .../IntegrationTests/SFDbTransactionIT.cs | 15 +- .../IntegrationTests/SFMultiStatementsIT.cs | 5 +- .../IntegrationTests/SFReusableChunkTest.cs | 33 ++-- .../IntegrationTests/SFStatementTypeTest.cs | 1 + 10 files changed, 161 insertions(+), 151 deletions(-) diff --git a/Snowflake.Data.Tests/IntegrationTests/EasyLoggingIT.cs b/Snowflake.Data.Tests/IntegrationTests/EasyLoggingIT.cs index 595fbb65d..ace515272 100644 --- a/Snowflake.Data.Tests/IntegrationTests/EasyLoggingIT.cs +++ b/Snowflake.Data.Tests/IntegrationTests/EasyLoggingIT.cs @@ -12,6 +12,7 @@ namespace Snowflake.Data.Tests.IntegrationTests { [TestFixture, NonParallelizable] + [Ignore("debugging")] // !!! public class EasyLoggingIT: SFBaseTest { private static readonly string s_workingDirectory = Path.Combine(Path.GetTempPath(), "easy_logging_test_configs_", Path.GetRandomFileName()); @@ -24,7 +25,7 @@ public static void BeforeAll() Directory.CreateDirectory(s_workingDirectory); } } - + [OneTimeTearDown] public static void AfterAll() { @@ -36,7 +37,7 @@ public static void AfterEach() { EasyLoggingStarter.Instance.Reset(EasyLoggingLogLevel.Warn); } - + [Test] public void TestEnableEasyLogging() { @@ -48,7 +49,7 @@ public void TestEnableEasyLogging() // act conn.Open(); - + // assert Assert.IsTrue(EasyLoggerManager.HasEasyLoggingAppender()); } @@ -65,13 +66,13 @@ public void TestFailToEnableEasyLoggingForWrongConfiguration() // act var thrown = Assert.Throws(() => conn.Open()); - + // assert Assert.That(thrown.Message, Does.Contain("Connection string is invalid: Unable to connect")); Assert.IsFalse(EasyLoggerManager.HasEasyLoggingAppender()); } } - + [Test] public void TestFailToEnableEasyLoggingWhenConfigHasWrongPermissions() { @@ -79,17 +80,17 @@ public void TestFailToEnableEasyLoggingWhenConfigHasWrongPermissions() { Assert.Ignore("skip test on Windows"); } - + // arrange var configFilePath = CreateConfigTempFile(s_workingDirectory, Config("WARN", s_workingDirectory)); Syscall.chmod(configFilePath, FilePermissions.S_IRUSR | FilePermissions.S_IWUSR | FilePermissions.S_IWGRP); using (IDbConnection conn = new SnowflakeDbConnection()) { conn.ConnectionString = ConnectionString + $"CLIENT_CONFIG_FILE={configFilePath}"; - + // act var thrown = Assert.Throws(() => conn.Open()); - + // assert Assert.That(thrown.Message, Does.Contain("Connection string is invalid: Unable to connect")); Assert.IsFalse(EasyLoggerManager.HasEasyLoggingAppender()); @@ -103,16 +104,16 @@ public void TestFailToEnableEasyLoggingWhenLogDirectoryNotAccessible() { Assert.Ignore("skip test on Windows"); } - + // arrange var configFilePath = CreateConfigTempFile(s_workingDirectory, Config("WARN", "/")); using (IDbConnection conn = new SnowflakeDbConnection()) { conn.ConnectionString = ConnectionString + $"CLIENT_CONFIG_FILE={configFilePath}"; - + // act var thrown = Assert.Throws(() => conn.Open()); - + // assert Assert.That(thrown.Message, Does.Contain("Connection string is invalid: Unable to connect")); Assert.That(thrown.InnerException.Message, Does.Contain("Failed to create logs directory")); @@ -121,4 +122,4 @@ public void TestFailToEnableEasyLoggingWhenLogDirectoryNotAccessible() } } -} \ No newline at end of file +} diff --git a/Snowflake.Data.Tests/IntegrationTests/MaxLobSizeIT.cs b/Snowflake.Data.Tests/IntegrationTests/MaxLobSizeIT.cs index 6a8bcce51..54a9a8af6 100644 --- a/Snowflake.Data.Tests/IntegrationTests/MaxLobSizeIT.cs +++ b/Snowflake.Data.Tests/IntegrationTests/MaxLobSizeIT.cs @@ -17,6 +17,7 @@ namespace Snowflake.Data.Tests.IntegrationTests [TestFixture(ResultFormat.ARROW)] [TestFixture(ResultFormat.JSON)] [Parallelizable(ParallelScope.Children)] + [Ignore("debugging")] // !!! class MaxLobSizeIT : SFBaseTest { private readonly ResultFormat _resultFormat; diff --git a/Snowflake.Data.Tests/IntegrationTests/SFBindTestIT.cs b/Snowflake.Data.Tests/IntegrationTests/SFBindTestIT.cs index 00a1857a2..43a44692f 100755 --- a/Snowflake.Data.Tests/IntegrationTests/SFBindTestIT.cs +++ b/Snowflake.Data.Tests/IntegrationTests/SFBindTestIT.cs @@ -19,7 +19,8 @@ namespace Snowflake.Data.Tests.IntegrationTests { - [TestFixture] + [TestFixture] + [Ignore("debugging")] // !!! class SFBindTestIT : SFBaseTest { private static readonly SFLogger s_logger = SFLoggerFactory.GetLogger(); @@ -27,12 +28,12 @@ class SFBindTestIT : SFBaseTest [Test] public void TestArrayBind() { - + using (IDbConnection conn = new SnowflakeDbConnection()) { conn.ConnectionString = ConnectionString; conn.Open(); - + CreateOrReplaceTable(conn, TableName, new [] { "cola INTEGER", @@ -208,7 +209,7 @@ public void TestBindValue() { dbConnection.ConnectionString = ConnectionString; dbConnection.Open(); - + CreateOrReplaceTable(dbConnection, TableName, new[] { "intData NUMBER", @@ -222,7 +223,7 @@ public void TestBindValue() "dateTimeData DATETIME", "dateTimeWithTimeZone TIMESTAMP_TZ" }); - + foreach (DbType type in Enum.GetValues(typeof(DbType))) { bool isTypeSupported = true; @@ -299,7 +300,7 @@ public void TestBindValue() param.Value = Encoding.UTF8.GetBytes("BinaryData"); break; default: - // Not supported + // Not supported colName = "stringData"; isTypeSupported = false; break; @@ -381,7 +382,7 @@ public void TestBindValueWithSFDataType() "unsupportedType VARCHAR" }; } - + CreateOrReplaceTable(dbConnection, TableName, columns); using (IDbCommand command = dbConnection.CreateCommand()) @@ -437,7 +438,7 @@ public void TestBindValueWithSFDataType() Assert.AreEqual(1, rowsInserted); } // DB rejects query if param type is VARIANT, OBJECT or ARRAY - else if (!type.Equals(SFDataType.VARIANT) && + else if (!type.Equals(SFDataType.VARIANT) && !type.Equals(SFDataType.OBJECT) && !type.Equals(SFDataType.ARRAY)) { @@ -492,7 +493,7 @@ public void TestParameterCollection() p2.ParameterName = "2"; p1.DbType = DbType.Int16; p2.Value = 2; - + var p3 = cmd.CreateParameter(); p2.ParameterName = "2"; @@ -507,7 +508,7 @@ public void TestParameterCollection() ((SnowflakeDbParameterCollection)cmd.Parameters).AddRange(parameters); Assert.Throws( () => { cmd.Parameters.CopyTo(parameters, 5); }); - + Assert.AreEqual(3, cmd.Parameters.Count); Assert.IsTrue(cmd.Parameters.Contains(p2)); Assert.IsTrue(cmd.Parameters.Contains("2")); @@ -518,7 +519,7 @@ public void TestParameterCollection() Assert.AreEqual(2, cmd.Parameters.Count); Assert.AreSame(p1, cmd.Parameters[0]); - cmd.Parameters.RemoveAt(0); + cmd.Parameters.RemoveAt(0); Assert.AreSame(p3, cmd.Parameters[0]); cmd.Parameters.Clear(); @@ -536,7 +537,7 @@ public void TestPutArrayBind() { conn.ConnectionString = ConnectionString; conn.Open(); - + CreateOrReplaceTable(conn, TableName, new [] { "cola INTEGER", @@ -544,7 +545,7 @@ public void TestPutArrayBind() "colc DATE", "cold TIME", "cole TIMESTAMP_NTZ", - "colf TIMESTAMP_TZ" + "colf TIMESTAMP_TZ" }); using (IDbCommand cmd = conn.CreateCommand()) @@ -579,7 +580,7 @@ public void TestPutArrayBind() p2.DbType = DbType.String; p2.Value = arrstring.ToArray(); cmd.Parameters.Add(p2); - + DateTime date1 = DateTime.ParseExact("2000-01-01 00:00:00.0000000", "yyyy-MM-dd HH:mm:ss.fffffff", CultureInfo.InvariantCulture); DateTime date2 = DateTime.ParseExact("2020-05-11 23:59:59.9999999", "yyyy-MM-dd HH:mm:ss.fffffff", CultureInfo.InvariantCulture); DateTime date3 = DateTime.ParseExact("2021-07-22 23:59:59.9999999", "yyyy-MM-dd HH:mm:ss.fffffff", CultureInfo.InvariantCulture); @@ -645,7 +646,7 @@ public void TestPutArrayBind() p6.DbType = DbType.DateTimeOffset; p6.Value = arrTz.ToArray(); cmd.Parameters.Add(p6); - + var count = cmd.ExecuteNonQuery(); Assert.AreEqual(total * 3, count); @@ -657,18 +658,18 @@ public void TestPutArrayBind() conn.Close(); } } - + [Test] public void TestPutArrayBindWorkDespiteOtTypeNameHandlingAuto() { JsonConvert.DefaultSettings = () => new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto }; - + using (IDbConnection conn = new SnowflakeDbConnection(ConnectionString)) { conn.Open(); - + CreateOrReplaceTable(conn, TableName, new [] { "cola REAL", @@ -682,7 +683,7 @@ public void TestPutArrayBindWorkDespiteOtTypeNameHandlingAuto() cmd.CommandText = insertCommand; var total = 250; - + List arrdouble = new List(); List arrstring = new List(); List arrint = new List(); @@ -691,11 +692,11 @@ public void TestPutArrayBindWorkDespiteOtTypeNameHandlingAuto() arrdouble.Add(i * 10 + 1); arrdouble.Add(i * 10 + 2); arrdouble.Add(i * 10 + 3); - + arrstring.Add("stra"+i); arrstring.Add("strb"+i); arrstring.Add("strc"+i); - + arrint.Add(i * 10 + 1); arrint.Add(i * 10 + 2); arrint.Add(i * 10 + 3); @@ -705,13 +706,13 @@ public void TestPutArrayBindWorkDespiteOtTypeNameHandlingAuto() p1.DbType = DbType.Double; p1.Value = arrdouble.ToArray(); cmd.Parameters.Add(p1); - + var p2 = cmd.CreateParameter(); p2.ParameterName = "2"; p2.DbType = DbType.String; p2.Value = arrstring.ToArray(); cmd.Parameters.Add(p2); - + var p3 = cmd.CreateParameter(); p3.ParameterName = "3"; p3.DbType = DbType.Int32; @@ -737,7 +738,7 @@ public void TestPutArrayIntegerBind() { conn.ConnectionString = ConnectionString; conn.Open(); - + CreateOrReplaceTable(conn, TableName, new [] { "cola INTEGER" @@ -835,7 +836,7 @@ public void TestExplicitDbTypeAssignmentForArrayValue() conn.Close(); } } - + private const string FormatYmd = "yyyy/MM/dd"; private const string FormatHms = "HH\\:mm\\:ss"; private const string FormatHmsf = "HH\\:mm\\:ss\\.fff"; @@ -869,7 +870,7 @@ public void TestExplicitDbTypeAssignmentForArrayValue() [TestCase(ResultFormat.ARROW, SFTableType.Hybrid, SFDataType.TIMESTAMP_NTZ, 6, DbType.DateTime, FormatYmdHms, null)] [TestCase(ResultFormat.ARROW, SFTableType.Hybrid, SFDataType.TIMESTAMP_TZ, 6, DbType.DateTimeOffset, FormatYmdHmsZ, null)] [TestCase(ResultFormat.ARROW, SFTableType.Hybrid, SFDataType.TIMESTAMP_LTZ, 6, DbType.DateTimeOffset, FormatYmdHmsZ, null)] - // ICEBERG Tables; require env variables: ICEBERG_EXTERNAL_VOLUME, ICEBERG_CATALOG, ICEBERG_BASE_LOCATION. + // ICEBERG Tables; require env variables: ICEBERG_EXTERNAL_VOLUME, ICEBERG_CATALOG, ICEBERG_BASE_LOCATION. [TestCase(ResultFormat.JSON, SFTableType.Iceberg, SFDataType.DATE, null, DbType.Date, FormatYmd, null)] [TestCase(ResultFormat.JSON, SFTableType.Iceberg, SFDataType.TIME, null, DbType.Time, FormatHms, null)] [TestCase(ResultFormat.JSON, SFTableType.Iceberg, SFDataType.TIME, 6, DbType.Time, FormatHmsf, null)] @@ -897,7 +898,7 @@ public void TestDateTimeBinding(ResultFormat resultFormat, SFTableType tableType var smallBatchRowCount = 2; var bigBatchRowCount = bindingThreshold / 2; s_logger.Info(testCase); - + using (IDbConnection conn = new SnowflakeDbConnection(ConnectionString)) { conn.Open(); @@ -906,13 +907,13 @@ public void TestDateTimeBinding(ResultFormat resultFormat, SFTableType tableType if (!timeZone.IsNullOrEmpty()) // Driver ignores this setting and relies on local environment timezone conn.ExecuteNonQuery($"alter session set TIMEZONE = '{timeZone}'"); - CreateOrReplaceTable(conn, - TableName, - tableType.TableDDLCreationPrefix(), + CreateOrReplaceTable(conn, + TableName, + tableType.TableDDLCreationPrefix(), new[] { "id number(10,0) not null primary key", // necessary only for HYBRID tables - $"ts {columnWithPrecision}" - }, + $"ts {columnWithPrecision}" + }, tableType.TableDDLCreationFlags()); // Act+Assert @@ -938,7 +939,7 @@ public void TestDateTimeBinding(ResultFormat resultFormat, SFTableType tableType Assert.AreEqual(1+smallBatchRowCount+bigBatchRowCount, row); } } - + private void InsertSingleRecord(IDbConnection conn, string sqlInsert, DbType binding, int identifier, ExpectedTimestampWrapper ts) { using (var insert = conn.CreateCommand(sqlInsert)) @@ -958,7 +959,7 @@ private void InsertSingleRecord(IDbConnection conn, string sqlInsert, DbType bin // Act s_logger.Info(sqlInsert); var rowsAffected = insert.ExecuteNonQuery(); - + // Assert Assert.AreEqual(1, rowsAffected); Assert.IsNull(((SnowflakeDbCommand)insert).GetBindStage()); @@ -980,11 +981,11 @@ private void InsertMultipleRecords(IDbConnection conn, string sqlInsert, DbType { insert.Add("2", binding, Enumerable.Repeat(ts.GetDateTime(), rowsCount).ToArray()); } - + // Act s_logger.Debug(sqlInsert); var rowsAffected = insert.ExecuteNonQuery(); - + // Assert Assert.AreEqual(rowsCount, rowsAffected); if (shouldUseBinding) @@ -993,11 +994,11 @@ private void InsertMultipleRecords(IDbConnection conn, string sqlInsert, DbType Assert.IsNull(((SnowflakeDbCommand)insert).GetBindStage()); } } - - private static string ColumnTypeWithPrecision(SFDataType columnType, Int32? columnPrecision) + + private static string ColumnTypeWithPrecision(SFDataType columnType, Int32? columnPrecision) => columnPrecision != null ? $"{columnType}({columnPrecision})" : $"{columnType}"; } - + class ExpectedTimestampWrapper { private readonly SFDataType _columnType; @@ -1051,7 +1052,7 @@ internal void AssertEqual(object actual, string comparisonFormat, string faultMe internal DateTime GetDateTime() => _expectedDateTime ?? throw new Exception($"Column {_columnType} is not matching the expected value type {typeof(DateTime)}"); internal DateTimeOffset GetDateTimeOffset() => _expectedDateTimeOffset ?? throw new Exception($"Column {_columnType} is not matching the expected value type {typeof(DateTime)}"); - + internal static bool IsOffsetType(SFDataType type) => type == SFDataType.TIMESTAMP_LTZ || type == SFDataType.TIMESTAMP_TZ; } } diff --git a/Snowflake.Data.Tests/IntegrationTests/SFDbAdaptorIT.cs b/Snowflake.Data.Tests/IntegrationTests/SFDbAdaptorIT.cs index 4f71b9b1e..8dc184c16 100755 --- a/Snowflake.Data.Tests/IntegrationTests/SFDbAdaptorIT.cs +++ b/Snowflake.Data.Tests/IntegrationTests/SFDbAdaptorIT.cs @@ -10,6 +10,7 @@ namespace Snowflake.Data.Tests.IntegrationTests using System.Runtime.InteropServices; [TestFixture] + [Ignore("debugging")] // !!! class SFDbAdaptorIT : SFBaseTest { private IDbDataAdapter _adapter; diff --git a/Snowflake.Data.Tests/IntegrationTests/SFDbDataReaderIT.cs b/Snowflake.Data.Tests/IntegrationTests/SFDbDataReaderIT.cs index b0e555185..dd12a319f 100755 --- a/Snowflake.Data.Tests/IntegrationTests/SFDbDataReaderIT.cs +++ b/Snowflake.Data.Tests/IntegrationTests/SFDbDataReaderIT.cs @@ -17,17 +17,18 @@ namespace Snowflake.Data.Tests.IntegrationTests { [TestFixture(ResultFormat.ARROW)] [TestFixture(ResultFormat.JSON)] + [Ignore("debugging")] // !!! class SFDbDataReaderIT : SFBaseTest { protected override string TestName => base.TestName + _resultFormat; - + private readonly ResultFormat _resultFormat; - + public SFDbDataReaderIT(ResultFormat resultFormat) { _resultFormat = resultFormat; } - + private void ValidateResultFormat(IDataReader reader) { Assert.AreEqual(_resultFormat, ((SnowflakeDbDataReader)reader).ResultFormat); @@ -39,7 +40,7 @@ public void TestRecordsAffected() using (var conn = CreateAndOpenConnection()) { CreateOrReplaceTable(conn, TableName, new []{"cola NUMBER"}); - + IDbCommand cmd = conn.CreateCommand(); string insertCommand = $"insert into {TableName} values (1),(1),(1)"; @@ -67,7 +68,7 @@ public void TestGetNumber() using (var conn = CreateAndOpenConnection()) { CreateOrReplaceTable(conn, TableName, new []{"cola NUMBER"}); - + IDbCommand cmd = conn.CreateCommand(); int numInt = 10000; @@ -114,7 +115,7 @@ public void TestGetNumber() Assert.IsFalse(reader.Read()); reader.Close(); - + CloseConnection(conn); } @@ -152,9 +153,9 @@ public void TestGetDouble() cmd.CommandText = $"select * from {TableName}"; IDataReader reader = cmd.ExecuteReader(); - + ValidateResultFormat(reader); - + Assert.IsTrue(reader.Read()); Assert.AreEqual(numFloat, reader.GetFloat(0)); Assert.AreEqual((decimal)numFloat, reader.GetDecimal(0)); @@ -235,7 +236,7 @@ public void TestGetTime(string inputTimeStr, int? precision) [TestCase("11:22:33.4455667")] [TestCase("23:59:59.9999999")] [TestCase("16:20:00.6666666")] - [TestCase("00:00:00.0000000")] + [TestCase("00:00:00.0000000")] [TestCase("00:00:00")] [TestCase("23:59:59.1")] [TestCase("23:59:59.12")] @@ -284,7 +285,7 @@ public void TestGetTimeSpan(string inputTimeStr) Assert.AreEqual(dateTimeTime.Minute, timeSpanTime.Minutes); Assert.AreEqual(dateTimeTime.Second, timeSpanTime.Seconds); Assert.AreEqual(dateTimeTime.Millisecond, timeSpanTime.Milliseconds); - + CloseConnection(conn); } } @@ -336,7 +337,7 @@ public void TestGetTimeSpanError() IDataReader reader = cmd.ExecuteReader(); ValidateResultFormat(reader); - + Assert.IsTrue(reader.Read()); // All types except TIME fail conversion when calling GetTimeSpan @@ -344,19 +345,19 @@ public void TestGetTimeSpanError() { try { - + ((SnowflakeDbDataReader)reader).GetTimeSpan(i); Assert.Fail("Data should not be converted to TIME"); } catch (SnowflakeDbException e) { - Assert.AreEqual(270003, e.ErrorCode); + Assert.AreEqual(270003, e.ErrorCode); } } // Null value // Null value can not be converted to TimeSpan because it is a non-nullable type - + try { ((SnowflakeDbDataReader)reader).GetTimeSpan(12); @@ -371,7 +372,7 @@ public void TestGetTimeSpanError() TimeSpan timeSpanTime = ((SnowflakeDbDataReader)reader).GetTimeSpan(13); reader.Close(); - + CloseConnection(conn); } } @@ -425,9 +426,9 @@ private void TestGetDateAndOrTime(string inputTimeStr, int? precision, SFDataTyp cmd.CommandText = $"select * from {TableName}"; IDataReader reader = cmd.ExecuteReader(); - + ValidateResultFormat(reader); - + Assert.IsTrue(reader.Read()); // For time, we getDateTime on the column and ignore date part @@ -495,9 +496,9 @@ public void TestGetTimestampTZ(int timezoneOffsetInHours) using (var conn = CreateAndOpenConnection()) { CreateOrReplaceTable(conn, TableName, new []{"cola TIMESTAMP_TZ"}); - + DateTimeOffset now = DateTimeOffset.Now.ToOffset(TimeSpan.FromHours(timezoneOffsetInHours)); - + IDbCommand cmd = conn.CreateCommand(); string insertCommand = $"insert into {TableName} values (?)"; @@ -514,9 +515,9 @@ public void TestGetTimestampTZ(int timezoneOffsetInHours) cmd.CommandText = $"select * from {TableName}"; IDataReader reader = cmd.ExecuteReader(); - + ValidateResultFormat(reader); - + Assert.IsTrue(reader.Read()); DateTimeOffset dtOffset = (DateTimeOffset)reader.GetValue(0); reader.Close(); @@ -535,9 +536,9 @@ public void TestGetTimestampLTZ() using (var conn = CreateAndOpenConnection()) { CreateOrReplaceTable(conn, TableName, new []{"cola TIMESTAMP_LTZ"}); - + DateTimeOffset now = DateTimeOffset.Now; - + IDbCommand cmd = conn.CreateCommand(); string insertCommand = $"insert into {TableName} values (?)"; @@ -555,9 +556,9 @@ public void TestGetTimestampLTZ() cmd.CommandText = $"select * from {TableName}"; IDataReader reader = cmd.ExecuteReader(); - + ValidateResultFormat(reader); - + Assert.IsTrue(reader.Read()); DateTimeOffset dtOffset = (DateTimeOffset)reader.GetValue(0); reader.Close(); @@ -592,9 +593,9 @@ public void TestGetBoolean([Values]bool value) cmd.CommandText = $"select * from {TableName}"; IDataReader reader = cmd.ExecuteReader(); - + ValidateResultFormat(reader); - + Assert.IsTrue(reader.Read()); Assert.AreEqual(value, reader.GetBoolean(0)); reader.Close(); @@ -655,18 +656,18 @@ public void TestGetBinary() "col2 VARCHAR(50)", "col3 DOUBLE" }); - + byte[] testBytes = Encoding.UTF8.GetBytes("TEST_GET_BINARAY"); string testChars = "TEST_GET_CHARS"; double testDouble = 1.2345678; string insertCommand = $"insert into {TableName} values (?, '{testChars}',{testDouble.ToString()})"; IDbCommand cmd = conn.CreateCommand(); cmd.CommandText = insertCommand; - + var p1 = cmd.CreateParameter(); p1.ParameterName = "1"; p1.DbType = DbType.Binary; - p1.Value = testBytes; + p1.Value = testBytes; cmd.Parameters.Add(p1); var count = cmd.ExecuteNonQuery(); @@ -674,9 +675,9 @@ public void TestGetBinary() cmd.CommandText = $"select * from {TableName}"; IDataReader reader = cmd.ExecuteReader(); - + ValidateResultFormat(reader); - + Assert.IsTrue(reader.Read()); // Auto type conversion Assert.IsTrue(testBytes.SequenceEqual((byte[])reader.GetValue(0))); @@ -714,7 +715,7 @@ public void TestGetBinary() Assert.AreEqual(read, toReadLength); Assert.IsTrue(testSubBytes.SequenceEqual(sub)); - // Read subset 'GET_BINARAY' from actual 'TEST_GET_BINARAY' data + // Read subset 'GET_BINARAY' from actual 'TEST_GET_BINARAY' data // and copy inside existing buffer replacing Xs toReadLength = 11; byte[] testSubBytesWithTargetOffset = Encoding.UTF8.GetBytes("OFFSET GET_BINARAY EXTRA"); @@ -731,7 +732,7 @@ public void TestGetBinary() //** Invalid data offsets **/ try { - // Data offset > data length + // Data offset > data length reader.GetBytes(0, 25, sub, 7, toReadLength); Assert.Fail(); } @@ -754,7 +755,7 @@ public void TestGetBinary() //** Invalid buffer offsets **// try { - // Buffer offset > buffer length + // Buffer offset > buffer length reader.GetBytes(0, 6, sub, 25, toReadLength); Assert.Fail(); } @@ -775,7 +776,7 @@ public void TestGetBinary() } //** Null buffer **// - // If null, this method returns the size required of the array in order to fit all + // If null, this method returns the size required of the array in order to fit all // of the specified data. read = reader.GetBytes(0, 6, null, 0, toReadLength); Assert.AreEqual(testBytes.Length, read); @@ -828,7 +829,7 @@ public void TestGetChars() "col2 BINARY", "col3 DOUBLE" }); - + string testChars = "TEST_GET_CHARS"; byte[] testBytes = Encoding.UTF8.GetBytes("TEST_GET_BINARY"); double testDouble = 1.2345678; @@ -849,7 +850,7 @@ public void TestGetChars() IDataReader reader = cmd.ExecuteReader(); ValidateResultFormat(reader); - + Assert.IsTrue(reader.Read()); // Auto type conversion Assert.IsTrue(testChars.Equals(reader.GetValue(0))); @@ -889,7 +890,7 @@ public void TestGetChars() Assert.IsTrue(testSubChars.SequenceEqual(sub)); - // Read subset 'GET_CHARS' from actual 'TEST_GET_CHARS' data + // Read subset 'GET_CHARS' from actual 'TEST_GET_CHARS' data // and copy inside existing buffer replacing Xs char[] testSubCharsWithTargetOffset = "OFFSET GET_CHARS EXTRA".ToArray(); toReadLength = 9; @@ -906,7 +907,7 @@ public void TestGetChars() //** Invalid data offsets **// try { - // Data offset > data length + // Data offset > data length reader.GetChars(0, 25, sub, 7, toReadLength); Assert.Fail(); } @@ -929,7 +930,7 @@ public void TestGetChars() //** Invalid buffer offsets **// try { - // Buffer offset > buffer length + // Buffer offset > buffer length reader.GetChars(0, 6, sub, 25, toReadLength); Assert.Fail(); } @@ -950,7 +951,7 @@ public void TestGetChars() } //** Null buffer **// - // If null, this method returns the size required of the array in order to fit all + // If null, this method returns the size required of the array in order to fit all // of the specified data. read = reader.GetChars(0, 6, null, 0, toReadLength); Assert.AreEqual(testChars.Length, read); @@ -1016,7 +1017,7 @@ public void TestGetStream() "col2 BINARY", "col3 DOUBLE" }); - + string testChars = "TEST_GET_CHARS"; byte[] testBytes = Encoding.UTF8.GetBytes("TEST_GET_BINARY"); double testDouble = 1.2345678; @@ -1037,7 +1038,7 @@ public void TestGetStream() DbDataReader reader = (DbDataReader) cmd.ExecuteReader(); ValidateResultFormat(reader); - + Assert.IsTrue(reader.Read()); // Auto type conversion @@ -1087,9 +1088,9 @@ public void TestGetValueIndexOutOfBound() IDbCommand cmd = conn.CreateCommand(); cmd.CommandText = "select 1"; IDataReader reader = cmd.ExecuteReader(); - + ValidateResultFormat(reader); - + Assert.IsTrue(reader.Read()); try @@ -1128,7 +1129,7 @@ public void TestBasicDataReader() using (IDataReader reader = cmd.ExecuteReader()) { ValidateResultFormat(reader); - + Assert.AreEqual(2, reader.FieldCount); Assert.AreEqual(0, reader.Depth); Assert.IsTrue(((SnowflakeDbDataReader)reader).HasRows); @@ -1151,7 +1152,7 @@ public void TestBasicDataReader() reader.Close(); Assert.IsTrue(reader.IsClosed); - + try { reader.Read(); @@ -1199,7 +1200,7 @@ public void TestReadOutNullVal() using (IDataReader reader = cmd.ExecuteReader()) { ValidateResultFormat(reader); - + reader.Read(); object nullVal = reader.GetValue(0); Assert.AreEqual(DBNull.Value, nullVal); @@ -1211,7 +1212,7 @@ public void TestReadOutNullVal() } CloseConnection(conn); - } + } } [Test] @@ -1238,9 +1239,9 @@ public void TestGetGuid() cmd.CommandText = $"select * from {TableName}"; IDataReader reader = cmd.ExecuteReader(); - + ValidateResultFormat(reader); - + Assert.IsTrue(reader.Read()); Assert.AreEqual(val, reader.GetGuid(0)); @@ -1302,7 +1303,7 @@ public void TestCopyCmdResultSet() cmd.CommandText = $"create or replace stage {stageName}"; cmd.ExecuteNonQuery(); - cmd.CommandText = $"copy into {TableName} from @{stageName}"; + cmd.CommandText = $"copy into {TableName} from @{stageName}"; using (var rdr = cmd.ExecuteReader()) { // Can read the first row @@ -1433,7 +1434,7 @@ public void TestResultSetMetadata() CloseConnection(conn); } } - + [Test] public void TestHasRows() { @@ -1441,9 +1442,9 @@ public void TestHasRows() { DbCommand cmd = conn.CreateCommand(); cmd.CommandText = "select 1 where 1=2"; - + DbDataReader reader = cmd.ExecuteReader(); - + ValidateResultFormat(reader); Assert.IsFalse(reader.HasRows); @@ -1451,7 +1452,7 @@ public void TestHasRows() CloseConnection(conn); } } - + [Test] public void TestHasRowsMultiStatement() { @@ -1460,15 +1461,15 @@ public void TestHasRowsMultiStatement() DbCommand cmd = conn.CreateCommand(); cmd.CommandText = "select 1;" + "select 1 where 1=2;" + - "select 1;" + + "select 1;" + "select 1 where 1=2;"; - + DbParameter param = cmd.CreateParameter(); param.ParameterName = "MULTI_STATEMENT_COUNT"; param.DbType = DbType.Int16; param.Value = 4; cmd.Parameters.Add(param); - + DbDataReader reader = cmd.ExecuteReader(); // multi statements are always returned in JSON @@ -1483,7 +1484,7 @@ public void TestHasRowsMultiStatement() // select 1 where 1=2 Assert.IsFalse(reader.HasRows); reader.NextResult(); - + // select 1 Assert.IsTrue(reader.HasRows); reader.Read(); @@ -1494,12 +1495,12 @@ public void TestHasRowsMultiStatement() Assert.IsFalse(reader.HasRows); reader.NextResult(); Assert.IsFalse(reader.HasRows); - + reader.Close(); CloseConnection(conn); } } - + [Test] [TestCase("99")] // Int8 [TestCase("9.9")] // Int8 + scale @@ -1564,23 +1565,23 @@ public void TestTimestampTz(string testValue, int scale) using (var conn = CreateAndOpenConnection()) { DbCommand cmd = conn.CreateCommand(); - + cmd.CommandText = $"select '{testValue}'::TIMESTAMP_TZ({scale})"; using (SnowflakeDbDataReader reader = (SnowflakeDbDataReader)cmd.ExecuteReader()) { ValidateResultFormat(reader); reader.Read(); - + var expectedValue = DateTimeOffset.Parse(testValue); Assert.AreEqual(expectedValue, reader.GetValue(0)); } - + CloseConnection(conn); } } - + [Test] [TestCase("2019-01-01 12:12:12.1234567 +0500", 7)] [TestCase("2019-01-01 12:12:12.1234567 +1400", 7)] @@ -1591,23 +1592,23 @@ public void TestTimestampLtz(string testValue, int scale) using (var conn = CreateAndOpenConnection()) { DbCommand cmd = conn.CreateCommand(); - + cmd.CommandText = $"select '{testValue}'::TIMESTAMP_LTZ({scale})"; using (SnowflakeDbDataReader reader = (SnowflakeDbDataReader)cmd.ExecuteReader()) { ValidateResultFormat(reader); reader.Read(); - + var expectedValue = DateTimeOffset.Parse(testValue).ToLocalTime(); Assert.AreEqual(expectedValue, reader.GetValue(0)); } - + CloseConnection(conn); } } - + [Test] [TestCase("2019-01-01 12:12:12.1234567", 7)] [TestCase("0001-01-01 00:00:00.0000000", 9)] @@ -1617,19 +1618,19 @@ public void TestTimestampNtz(string testValue, int scale) using (var conn = CreateAndOpenConnection()) { DbCommand cmd = conn.CreateCommand(); - + cmd.CommandText = $"select '{testValue}'::TIMESTAMP_NTZ({scale})"; using (SnowflakeDbDataReader reader = (SnowflakeDbDataReader)cmd.ExecuteReader()) { ValidateResultFormat(reader); reader.Read(); - + var expectedValue = DateTime.Parse(testValue); Assert.AreEqual(expectedValue, reader.GetValue(0)); } - + CloseConnection(conn); } } diff --git a/Snowflake.Data.Tests/IntegrationTests/SFDbFactoryIT.cs b/Snowflake.Data.Tests/IntegrationTests/SFDbFactoryIT.cs index 580f16f7f..20b85f061 100644 --- a/Snowflake.Data.Tests/IntegrationTests/SFDbFactoryIT.cs +++ b/Snowflake.Data.Tests/IntegrationTests/SFDbFactoryIT.cs @@ -9,6 +9,7 @@ namespace Snowflake.Data.Tests.IntegrationTests using System.Data.Common; [TestFixture] + [Ignore("debugging")] // !!! class SFDbFactoryIT : SFBaseTest { DbProviderFactory _factory; diff --git a/Snowflake.Data.Tests/IntegrationTests/SFDbTransactionIT.cs b/Snowflake.Data.Tests/IntegrationTests/SFDbTransactionIT.cs index 2786d8226..4dca362c9 100644 --- a/Snowflake.Data.Tests/IntegrationTests/SFDbTransactionIT.cs +++ b/Snowflake.Data.Tests/IntegrationTests/SFDbTransactionIT.cs @@ -13,6 +13,7 @@ namespace Snowflake.Data.Tests.IntegrationTests using System.Threading.Tasks; [TestFixture] + [Ignore("debugging")] // !!! class SFDbTransactionIT : SFBaseTest { [Test] @@ -59,7 +60,7 @@ public void TestTransactionDispose() { conn.ConnectionString = ConnectionString; conn.Open(); - + CreateOrReplaceTable(conn, TableName, new []{"c INT"}); using (IDbTransaction t1 = conn.BeginTransaction()) @@ -79,19 +80,19 @@ public void TestTransactionDispose() } [Test] - // Test SNOW-761136 unnecessary ROLLBACK + // Test SNOW-761136 unnecessary ROLLBACK public void TestTransactionRollback() { var conn = new SnowflakeDbConnection(); conn.ConnectionString = ConnectionString; conn.Open(); - + CreateOrReplaceTable(conn, TableName, new [] { "x TIMESTAMP_NTZ", "a INTEGER" }); - + using (DbTransaction transaction = conn.BeginTransaction()) { IDbCommand t1c1 = conn.CreateCommand(); @@ -130,19 +131,19 @@ public void TestTransactionRollback() } [Test] - // Test SNOW-761136 unnecessary ROLLBACK + // Test SNOW-761136 unnecessary ROLLBACK public void TestTransactionRollbackOn2Transactions() { var conn = new SnowflakeDbConnection(); conn.ConnectionString = ConnectionString; conn.Open(); - + CreateOrReplaceTable(conn, TableName, new [] { "x TIMESTAMP_NTZ", "a INTEGER" }); - + using (DbTransaction transaction = conn.BeginTransaction()) { IDbCommand t1c1 = conn.CreateCommand(); diff --git a/Snowflake.Data.Tests/IntegrationTests/SFMultiStatementsIT.cs b/Snowflake.Data.Tests/IntegrationTests/SFMultiStatementsIT.cs index f34b6d915..362573989 100644 --- a/Snowflake.Data.Tests/IntegrationTests/SFMultiStatementsIT.cs +++ b/Snowflake.Data.Tests/IntegrationTests/SFMultiStatementsIT.cs @@ -14,6 +14,7 @@ namespace Snowflake.Data.Tests.IntegrationTests using NUnit.Framework; [TestFixture] + [Ignore("debugging")] // !!! class SFMultiStatementsIT : SFBaseTest { [Test] @@ -83,7 +84,7 @@ public void TestSelectWithoutBinding() conn.Close(); } } - + [Test] public async Task TestSelectAsync() { @@ -124,7 +125,7 @@ public async Task TestSelectAsync() conn.Close(); } } - + [Test] public void TestSelectWithBinding() { diff --git a/Snowflake.Data.Tests/IntegrationTests/SFReusableChunkTest.cs b/Snowflake.Data.Tests/IntegrationTests/SFReusableChunkTest.cs index 1dcc4ddc2..528d140f5 100644 --- a/Snowflake.Data.Tests/IntegrationTests/SFReusableChunkTest.cs +++ b/Snowflake.Data.Tests/IntegrationTests/SFReusableChunkTest.cs @@ -9,8 +9,9 @@ namespace Snowflake.Data.Tests.IntegrationTests using Core; using Client; using System.Threading.Tasks; - + [TestFixture, NonParallelizable] + [Ignore("debugging")] // !!! class SFReusableChunkTest : SFBaseTest { [Test] @@ -20,7 +21,7 @@ public void TestDelCharPr431() { conn.ConnectionString = ConnectionString; conn.Open(); - + SessionParameterAlterer.SetResultFormat(conn, ResultFormat.JSON); CreateOrReplaceTable(conn, TableName, new []{"col STRING"}); @@ -63,12 +64,12 @@ public void TestParseJson() { IChunkParserFactory previous = ChunkParserFactory.Instance; ChunkParserFactory.Instance = new TestChunkParserFactory(1); - + using (IDbConnection conn = new SnowflakeDbConnection()) { conn.ConnectionString = ConnectionString; conn.Open(); - + SessionParameterAlterer.SetResultFormat(conn, ResultFormat.JSON); CreateOrReplaceTable(conn, TableName, new []{"src VARIANT"}); @@ -78,8 +79,8 @@ public void TestParseJson() string insertCommand = $@" -- borrowed from https://docs.snowflake.com/en/user-guide/querying-semistructured.html#sample-data-used-in-examples insert into {TableName} ( -select parse_json('{{ - ""date"" : ""2017 - 04 - 28"", +select parse_json('{{ + ""date"" : ""2017 - 04 - 28"", ""dealership"" : ""Valley View Auto Sales"", ""salesperson"" : {{ ""id"": ""55"", @@ -125,12 +126,12 @@ public void TestChunkRetry() { IChunkParserFactory previous = ChunkParserFactory.Instance; ChunkParserFactory.Instance = new TestChunkParserFactory(6); // lower than default retry of 7 - + using (IDbConnection conn = new SnowflakeDbConnection()) { conn.ConnectionString = ConnectionString; conn.Open(); - + SessionParameterAlterer.SetResultFormat(conn, ResultFormat.JSON); CreateOrReplaceTable(conn, TableName, new []{"col STRING"}); @@ -172,15 +173,15 @@ public void TestChunkRetry() [Test] public void TestExceptionThrownWhenChunkDownloadRetryCountExceeded() - { + { IChunkParserFactory previous = ChunkParserFactory.Instance; ChunkParserFactory.Instance = new TestChunkParserFactory(8); // larger than default max retry of 7 - + using (IDbConnection conn = new SnowflakeDbConnection()) { conn.ConnectionString = ConnectionString; conn.Open(); - + CreateOrReplaceTable(conn, TableName, new []{"col STRING"}); IDbCommand cmd = conn.CreateCommand(); @@ -188,7 +189,7 @@ public void TestExceptionThrownWhenChunkDownloadRetryCountExceeded() int largeTableRowCount = 100000; string insertCommand = $"insert into {TableName}(select hex_decode_string(hex_encode('snow') || '7F' || hex_encode('FLAKE')) from table(generator(rowcount => {largeTableRowCount})))"; - cmd.CommandText = insertCommand; + cmd.CommandText = insertCommand; IDataReader insertReader = cmd.ExecuteReader(); Assert.AreEqual(largeTableRowCount, insertReader.RecordsAffected); @@ -223,13 +224,13 @@ class TestChunkParserFactory : IChunkParserFactory { private int _exceptionsThrown; private readonly int _expectedExceptionsNumber; - + public TestChunkParserFactory(int exceptionsToThrow) { _expectedExceptionsNumber = exceptionsToThrow; _exceptionsThrown = 0; } - + public IChunkParser GetParser(ResultFormat resultFormat, Stream stream) { if (++_exceptionsThrown <= _expectedExceptionsNumber) @@ -242,9 +243,9 @@ public IChunkParser GetParser(ResultFormat resultFormat, Stream stream) class ThrowingReusableChunkParser : IChunkParser { public Task ParseChunk(IResultChunk chunk) - { + { throw new Exception("json parsing error."); } } } -} \ No newline at end of file +} diff --git a/Snowflake.Data.Tests/IntegrationTests/SFStatementTypeTest.cs b/Snowflake.Data.Tests/IntegrationTests/SFStatementTypeTest.cs index a6d79f261..3a19ef8a8 100644 --- a/Snowflake.Data.Tests/IntegrationTests/SFStatementTypeTest.cs +++ b/Snowflake.Data.Tests/IntegrationTests/SFStatementTypeTest.cs @@ -10,6 +10,7 @@ namespace Snowflake.Data.Tests.IntegrationTests using System.Data.Common; [TestFixture] + [Ignore("debugging")] // !!! class SFStatementTypeTest : SFBaseTest { [Test]