From 9a569b7d2511f8984f8fc4465d64651a19b609e5 Mon Sep 17 00:00:00 2001 From: Piotr Bulawa Date: Thu, 29 Aug 2024 12:01:40 +0200 Subject: [PATCH] Fix --- .../ConnectionSinglePoolCacheAsyncIT.cs | 2 ++ .../Mock/MockRetryUntilRestTimeout.cs | 2 +- .../UnitTests/SFAzureClientTest.cs | 4 +-- .../UnitTests/SFGCSClientTest.cs | 4 +-- .../UnitTests/SFReusableChunkTest.cs | 30 ++++++++++--------- .../UnitTests/SFS3ClientTest.cs | 8 ++--- 6 files changed, 27 insertions(+), 23 deletions(-) diff --git a/Snowflake.Data.Tests/IntegrationTests/ConnectionSinglePoolCacheAsyncIT.cs b/Snowflake.Data.Tests/IntegrationTests/ConnectionSinglePoolCacheAsyncIT.cs index 1b0ac0cf8..2adb1a1e0 100644 --- a/Snowflake.Data.Tests/IntegrationTests/ConnectionSinglePoolCacheAsyncIT.cs +++ b/Snowflake.Data.Tests/IntegrationTests/ConnectionSinglePoolCacheAsyncIT.cs @@ -205,7 +205,9 @@ static async Task InvalidConnectionTaskAsync(string connectionString, int times) { // intentionally not using await so the connection // will be disposed with invalid underlying session +#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed conn.OpenAsync(); +#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed }; // wait 100ms each time so the invalid sessions are generated // roughly at the same speed as connections for query tasks diff --git a/Snowflake.Data.Tests/Mock/MockRetryUntilRestTimeout.cs b/Snowflake.Data.Tests/Mock/MockRetryUntilRestTimeout.cs index 17b0ffcfc..99c1e54b1 100644 --- a/Snowflake.Data.Tests/Mock/MockRetryUntilRestTimeout.cs +++ b/Snowflake.Data.Tests/Mock/MockRetryUntilRestTimeout.cs @@ -36,7 +36,7 @@ protected override async Task SendAsync(HttpRequestMessage _forceTimeoutForNonLoginRequestsOnly && !message.RequestUri.AbsolutePath.Equals(RestPath.SF_LOGIN_PATH)) { // Override the http timeout and set to 1ms to force all http request to timeout and retry - message.Properties[BaseRestRequest.HTTP_REQUEST_TIMEOUT_KEY] = TimeSpan.FromTicks(0); + message.Options.Set(new HttpRequestOptionsKey(BaseRestRequest.HTTP_REQUEST_TIMEOUT_KEY), TimeSpan.FromTicks(0)); } return await (base.SendAsync(message, restTimeout, externalCancellationToken).ConfigureAwait(false)); diff --git a/Snowflake.Data.Tests/UnitTests/SFAzureClientTest.cs b/Snowflake.Data.Tests/UnitTests/SFAzureClientTest.cs index f83351f99..a1c791071 100644 --- a/Snowflake.Data.Tests/UnitTests/SFAzureClientTest.cs +++ b/Snowflake.Data.Tests/UnitTests/SFAzureClientTest.cs @@ -60,10 +60,10 @@ class SFAzureClientTest : SFBaseTest SFFileMetadata _fileMetadata; [SetUp] - public void BeforeTest() + public new void BeforeTest() { t_downloadFileName = TestNameWithWorker + "_mockFileName.txt"; - + _fileMetadata = new SFFileMetadata() { stageInfo = new PutGetStageInfo() diff --git a/Snowflake.Data.Tests/UnitTests/SFGCSClientTest.cs b/Snowflake.Data.Tests/UnitTests/SFGCSClientTest.cs index da7c0cdf4..925ce4c98 100644 --- a/Snowflake.Data.Tests/UnitTests/SFGCSClientTest.cs +++ b/Snowflake.Data.Tests/UnitTests/SFGCSClientTest.cs @@ -53,10 +53,10 @@ class SFGCSClientTest : SFBaseTest SFFileMetadata _fileMetadata; [SetUp] - public void BeforeTest() + public new void BeforeTest() { t_downloadFileName = TestNameWithWorker + "_mockFileName.txt"; - + _fileMetadata = new SFFileMetadata() { stageInfo = new PutGetStageInfo() diff --git a/Snowflake.Data.Tests/UnitTests/SFReusableChunkTest.cs b/Snowflake.Data.Tests/UnitTests/SFReusableChunkTest.cs index 4ca4eec79..6f021994b 100755 --- a/Snowflake.Data.Tests/UnitTests/SFReusableChunkTest.cs +++ b/Snowflake.Data.Tests/UnitTests/SFReusableChunkTest.cs @@ -23,13 +23,15 @@ public void TestExtractCellWithRowParameterReadsAllRows() string data = "[ [\"1\", \"1.234\", \"abcde\"], [\"2\", \"5.678\", \"fghi\"] ]"; var chunk = PrepareChunkAsync(data, 3, 2).Result; +#pragma warning disable CS0618 // Type or member is obsolete Assert.AreEqual("1", chunk.ExtractCell(0,0).SafeToString()); Assert.AreEqual("1.234", chunk.ExtractCell(0, 1).SafeToString()); Assert.AreEqual("abcde", chunk.ExtractCell(0, 2).SafeToString()); - + Assert.AreEqual("2", chunk.ExtractCell(1, 0).SafeToString()); Assert.AreEqual("5.678", chunk.ExtractCell(1, 1).SafeToString()); Assert.AreEqual("fghi", chunk.ExtractCell(1, 2).SafeToString()); +#pragma warning restore CS0618 // Type or member is obsolete } [Test] @@ -42,7 +44,7 @@ public void TestSimpleChunk() Assert.AreEqual("1", chunk.ExtractCell(0).SafeToString()); Assert.AreEqual("1.234", chunk.ExtractCell(1).SafeToString()); Assert.AreEqual("abcde", chunk.ExtractCell(2).SafeToString()); - + chunk.Next(); Assert.AreEqual("2", chunk.ExtractCell(0).SafeToString()); Assert.AreEqual("5.678", chunk.ExtractCell(1).SafeToString()); @@ -59,7 +61,7 @@ public void TestChunkWithNull() Assert.AreEqual(null, chunk.ExtractCell(0).SafeToString()); Assert.AreEqual("1.234", chunk.ExtractCell(1).SafeToString()); Assert.AreEqual(null, chunk.ExtractCell(2).SafeToString()); - + chunk.Next(); Assert.AreEqual("2", chunk.ExtractCell(0).SafeToString()); Assert.AreEqual(null, chunk.ExtractCell(1).SafeToString()); @@ -76,7 +78,7 @@ public void TestChunkWithDate() Assert.AreEqual(null, chunk.ExtractCell(0).SafeToString()); Assert.AreEqual("2019-08-21T11:58:00", chunk.ExtractCell(1).SafeToString()); Assert.AreEqual(null, chunk.ExtractCell(2).SafeToString()); - + chunk.Next(); Assert.AreEqual("2", chunk.ExtractCell(0).SafeToString()); Assert.AreEqual(null, chunk.ExtractCell(1).SafeToString()); @@ -93,7 +95,7 @@ public void TestChunkWithEscape() Assert.AreEqual("\\åäö\nÅÄÖ\r", chunk.ExtractCell(0).SafeToString()); Assert.AreEqual("1.234", chunk.ExtractCell(1).SafeToString()); Assert.AreEqual(null, chunk.ExtractCell(2).SafeToString()); - + chunk.Next(); Assert.AreEqual("2", chunk.ExtractCell(0).SafeToString()); Assert.AreEqual(null, chunk.ExtractCell(1).SafeToString()); @@ -111,7 +113,7 @@ public void TestChunkWithLongString() Assert.AreEqual("åäö\nÅÄÖ\r", chunk.ExtractCell(0).SafeToString()); Assert.AreEqual("1.234", chunk.ExtractCell(1).SafeToString()); Assert.AreEqual(null, chunk.ExtractCell(2).SafeToString()); - + chunk.Next(); Assert.AreEqual("2", chunk.ExtractCell(0).SafeToString()); Assert.AreEqual(null, chunk.ExtractCell(1).SafeToString()); @@ -140,7 +142,7 @@ public async Task TestParserError2() { // Unterminated string string data = "[ [\"åäö"; - + try { await PrepareChunkAsync(data, 1, 1); @@ -177,7 +179,7 @@ public void TestNextIteratesThroughAllRecords() } Assert.IsFalse(chunk.Next()); } - + [Test] public void TestRewindIteratesThroughAllRecords() { @@ -190,14 +192,14 @@ public void TestRewindIteratesThroughAllRecords() chunk.Next(); } chunk.Next(); - + for (var i = 0; i < RowCount; ++i) { Assert.IsTrue(chunk.Rewind()); } Assert.IsFalse(chunk.Rewind()); } - + [Test] public void TestResetClearsChunkData() { @@ -211,14 +213,14 @@ public void TestResetClearsChunkData() uncompressedSize = 100, rowCount = 200 }; - + chunk.Reset(chunkInfo, 0); - + Assert.AreEqual(0, chunk.ChunkIndex); Assert.AreEqual(chunkInfo.url, chunk.Url); Assert.AreEqual(chunkInfo.rowCount, chunk.RowCount); } - + private async Task PrepareChunkAsync(string stringData, int colCount, int rowCount) { byte[] bytes = Encoding.UTF8.GetBytes(stringData); @@ -234,7 +236,7 @@ private async Task PrepareChunkAsync(string stringData, int col SFReusableChunk chunk = new SFReusableChunk(colCount); chunk.Reset(chunkInfo, 0); - + await parser.ParseChunk(chunk); return chunk; } diff --git a/Snowflake.Data.Tests/UnitTests/SFS3ClientTest.cs b/Snowflake.Data.Tests/UnitTests/SFS3ClientTest.cs index da3baf531..50faae758 100644 --- a/Snowflake.Data.Tests/UnitTests/SFS3ClientTest.cs +++ b/Snowflake.Data.Tests/UnitTests/SFS3ClientTest.cs @@ -78,10 +78,10 @@ class SFS3ClientTest : SFBaseTest AmazonS3Config _clientConfig; [SetUp] - public void BeforeTest() + public new void BeforeTest() { t_downloadFileName = TestNameWithWorker + "_mockFileName.txt"; - + _fileMetadata = new SFFileMetadata() { stageInfo = new PutGetStageInfo() @@ -274,7 +274,7 @@ public async Task TestUploadFileAsync(string requestKey, ResultStatus expectedRe iv = MockS3Client.AmzIV, key = MockS3Client.AmzKey, matDesc = MockS3Client.AmzMatdesc - }, + }, _cancellationToken).ConfigureAwait(false); // Assert @@ -331,7 +331,7 @@ public async Task TestDownloadFileAsync(string requestKey, ResultStatus expected _client = new SFS3Client(_fileMetadata.stageInfo, MaxRetry, Parallel, _proxyCredentials, mockAmazonS3Client.Object); _fileMetadata.client = _client; _fileMetadata.stageInfo.location = requestKey; - + // Act await _client.DownloadFileAsync(_fileMetadata, t_downloadFileName, Parallel, _cancellationToken).ConfigureAwait(false);