From 675c1966a62f27cae9eb612377862382efdedbfe Mon Sep 17 00:00:00 2001 From: Blake Niemyjski Date: Wed, 25 Sep 2024 22:16:44 -0500 Subject: [PATCH] Added missing tests - removed some skips --- docker-compose.yml | 8 +- src/Foundatio.AWS/Queues/SQSQueueEntry.cs | 1 - .../Queues/SQSQueueTests.cs | 117 +++++++++++++----- .../Storage/S3FileStorageTests.cs | 30 ++++- .../Storage/ScopedS3StorageTests.cs | 36 ++++++ 5 files changed, 154 insertions(+), 38 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index e81f719..341a11e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,6 @@ -version: '2.1' services: localstack: - image: localstack/localstack:3.0.2 + image: localstack/localstack:3.7.2 ports: - 4563-4599:4563-4599 - 8055:8080 @@ -11,6 +10,11 @@ services: volumes: - "localstackdata:/var/lib/localstack" - "/var/run/docker.sock:/var/run/docker.sock" + deploy: + resources: + limits: + memory: 1g + ready: image: andrewlock/wait-for-dependencies command: localstack:4566 diff --git a/src/Foundatio.AWS/Queues/SQSQueueEntry.cs b/src/Foundatio.AWS/Queues/SQSQueueEntry.cs index 519d034..7f2b91a 100644 --- a/src/Foundatio.AWS/Queues/SQSQueueEntry.cs +++ b/src/Foundatio.AWS/Queues/SQSQueueEntry.cs @@ -6,7 +6,6 @@ namespace Foundatio.Queues; public class SQSQueueEntry : QueueEntry where T : class { - public Message UnderlyingMessage { get; } public SQSQueueEntry(Message message, T value, IQueue queue) diff --git a/tests/Foundatio.AWS.Tests/Queues/SQSQueueTests.cs b/tests/Foundatio.AWS.Tests/Queues/SQSQueueTests.cs index a8a94c1..0a7a1de 100644 --- a/tests/Foundatio.AWS.Tests/Queues/SQSQueueTests.cs +++ b/tests/Foundatio.AWS.Tests/Queues/SQSQueueTests.cs @@ -52,35 +52,15 @@ protected IQueue GetQueue(int retries = 1, TimeSpan? workItemTim } [Fact] - public void RetryBackoff() + public override Task CanQueueAndDequeueWorkItemAsync() { - var options = new SQSQueueOptions(); - var backoff1 = options.RetryDelay(1); - Assert.InRange(backoff1, TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(3)); - var backoff2 = options.RetryDelay(2); - Assert.InRange(backoff2, TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(5)); - var backoff3 = options.RetryDelay(3); - Assert.InRange(backoff3, TimeSpan.FromSeconds(8), TimeSpan.FromSeconds(9)); - var backoff4 = options.RetryDelay(4); - Assert.InRange(backoff4, TimeSpan.FromSeconds(16), TimeSpan.FromSeconds(17)); - var backoff5 = options.RetryDelay(5); - Assert.InRange(backoff5, TimeSpan.FromSeconds(32), TimeSpan.FromSeconds(33)); - var backoff6 = options.RetryDelay(6); - Assert.InRange(backoff6, TimeSpan.FromSeconds(64), TimeSpan.FromSeconds(65)); - var backoff7 = options.RetryDelay(7); - Assert.InRange(backoff7, TimeSpan.FromSeconds(128), TimeSpan.FromSeconds(129)); - var backoff8 = options.RetryDelay(8); - Assert.InRange(backoff8, TimeSpan.FromSeconds(256), TimeSpan.FromSeconds(257)); - var backoff9 = options.RetryDelay(9); - Assert.InRange(backoff9, TimeSpan.FromSeconds(512), TimeSpan.FromSeconds(513)); - var backoff10 = options.RetryDelay(10); - Assert.InRange(backoff10, TimeSpan.FromSeconds(1024), TimeSpan.FromSeconds(1025)); + return base.CanQueueAndDequeueWorkItemAsync(); } [Fact] - public override Task CanQueueAndDequeueWorkItemAsync() + public override Task CanQueueAndDequeueWorkItemWithDelayAsync() { - return base.CanQueueAndDequeueWorkItemAsync(); + return base.CanQueueAndDequeueWorkItemWithDelayAsync(); } [Fact] @@ -89,23 +69,46 @@ public override Task CanUseQueueOptionsAsync() return base.CanUseQueueOptionsAsync(); } + [Fact] + public override Task CanDiscardDuplicateQueueEntriesAsync() + { + return base.CanDiscardDuplicateQueueEntriesAsync(); + } + [Fact] public override Task CanDequeueWithCancelledTokenAsync() { return base.CanDequeueWithCancelledTokenAsync(); } + [Fact] + public override Task CanDequeueEfficientlyAsync() + { + return base.CanDequeueEfficientlyAsync(); + } + + [Fact] + public override Task CanResumeDequeueEfficientlyAsync() + { + return base.CanResumeDequeueEfficientlyAsync(); + } + [Fact] public override Task CanQueueAndDequeueMultipleWorkItemsAsync() { return base.CanQueueAndDequeueMultipleWorkItemsAsync(); } - [Fact(Skip = "Some issue where this test fails if it's run with others")] - public override async Task WillWaitForItemAsync() + [Fact] + public override Task WillNotWaitForItemAsync() { - await Task.Delay(5000); - await base.WillWaitForItemAsync(); + return base.WillNotWaitForItemAsync(); + } + + [Fact] + public override Task WillWaitForItemAsync() + { + return base.WillWaitForItemAsync(); } [Fact] @@ -144,12 +147,18 @@ public override Task CanAutoCompleteWorkerAsync() return base.CanAutoCompleteWorkerAsync(); } - [Fact(Skip = "Doesn't work well on SQS")] + [Fact] public override Task CanHaveMultipleQueueInstancesAsync() { return base.CanHaveMultipleQueueInstancesAsync(); } + [Fact] + public override Task CanDelayRetryAsync() + { + return base.CanDelayRetryAsync(); + } + [Fact] public override Task CanRunWorkItemWithMetricsAsync() { @@ -174,6 +183,24 @@ public override Task CanCompleteQueueEntryOnceAsync() return base.CanCompleteQueueEntryOnceAsync(); } + [Fact] + public override Task CanDequeueWithLockingAsync() + { + return base.CanDequeueWithLockingAsync(); + } + + [Fact] + public override Task CanHaveMultipleQueueInstancesWithLockingAsync() + { + return base.CanHaveMultipleQueueInstancesWithLockingAsync(); + } + + [Fact] + public override Task MaintainJobNotAbandon_NotWorkTimeOutEntry() + { + return base.MaintainJobNotAbandon_NotWorkTimeOutEntry(); + } + [Fact] public override Task VerifyRetryAttemptsAsync() { @@ -186,6 +213,38 @@ public override Task VerifyDelayedRetryAttemptsAsync() return base.VerifyDelayedRetryAttemptsAsync(); } + [Fact] + public override Task CanHandleAutoAbandonInWorker() + { + return base.CanHandleAutoAbandonInWorker(); + } + + [Fact] + public void RetryBackoff() + { + var options = new SQSQueueOptions(); + var backoff1 = options.RetryDelay(1); + Assert.InRange(backoff1, TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(3)); + var backoff2 = options.RetryDelay(2); + Assert.InRange(backoff2, TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(5)); + var backoff3 = options.RetryDelay(3); + Assert.InRange(backoff3, TimeSpan.FromSeconds(8), TimeSpan.FromSeconds(9)); + var backoff4 = options.RetryDelay(4); + Assert.InRange(backoff4, TimeSpan.FromSeconds(16), TimeSpan.FromSeconds(17)); + var backoff5 = options.RetryDelay(5); + Assert.InRange(backoff5, TimeSpan.FromSeconds(32), TimeSpan.FromSeconds(33)); + var backoff6 = options.RetryDelay(6); + Assert.InRange(backoff6, TimeSpan.FromSeconds(64), TimeSpan.FromSeconds(65)); + var backoff7 = options.RetryDelay(7); + Assert.InRange(backoff7, TimeSpan.FromSeconds(128), TimeSpan.FromSeconds(129)); + var backoff8 = options.RetryDelay(8); + Assert.InRange(backoff8, TimeSpan.FromSeconds(256), TimeSpan.FromSeconds(257)); + var backoff9 = options.RetryDelay(9); + Assert.InRange(backoff9, TimeSpan.FromSeconds(512), TimeSpan.FromSeconds(513)); + var backoff10 = options.RetryDelay(10); + Assert.InRange(backoff10, TimeSpan.FromSeconds(1024), TimeSpan.FromSeconds(1025)); + } + [Fact] public async Task CanGetQueueItemWithDeliveryDelayAndEnsureMessageNotMarkedWorkingWhileWaiting() { diff --git a/tests/Foundatio.AWS.Tests/Storage/S3FileStorageTests.cs b/tests/Foundatio.AWS.Tests/Storage/S3FileStorageTests.cs index 9fd049c..539b080 100644 --- a/tests/Foundatio.AWS.Tests/Storage/S3FileStorageTests.cs +++ b/tests/Foundatio.AWS.Tests/Storage/S3FileStorageTests.cs @@ -33,6 +33,12 @@ public override Task CanGetFileListForSingleFolderAsync() return base.CanGetFileListForSingleFolderAsync(); } + [Fact] + public override Task CanGetFileListForSingleFileAsync() + { + return base.CanGetFileListForSingleFileAsync(); + } + [Fact] public override Task CanGetPagedFileListForSingleFolderAsync() { @@ -93,6 +99,12 @@ public override Task CanDeleteEntireFolderWithWildcardAsync() return base.CanDeleteEntireFolderWithWildcardAsync(); } + [Fact] + public override Task CanDeleteFolderWithMultiFolderWildcardsAsync() + { + return base.CanDeleteFolderWithMultiFolderWildcardsAsync(); + } + [Fact] public override Task CanDeleteSpecificFilesAsync() { @@ -111,12 +123,6 @@ public override Task CanDeleteSpecificFilesInNestedFolderAsync() return base.CanDeleteSpecificFilesInNestedFolderAsync(); } - [Fact] - public override Task CanDeleteFolderWithMultiFolderWildcardsAsync() - { - return base.CanDeleteFolderWithMultiFolderWildcardsAsync(); - } - [Fact] public override Task CanRoundTripSeekableStreamAsync() { @@ -129,6 +135,18 @@ public override Task WillRespectStreamOffsetAsync() return base.WillRespectStreamOffsetAsync(); } + [Fact(Skip = "Write Stream is not yet supported")] + public override Task WillWriteStreamContentAsync() + { + return base.WillWriteStreamContentAsync(); + } + + [Fact] + public override Task CanSaveOverExistingStoredContent() + { + return base.CanSaveOverExistingStoredContent(); + } + [Fact] public virtual async Task WillNotReturnDirectoryInGetPagedFileListAsync() { diff --git a/tests/Foundatio.AWS.Tests/Storage/ScopedS3StorageTests.cs b/tests/Foundatio.AWS.Tests/Storage/ScopedS3StorageTests.cs index ce623c1..3345a15 100644 --- a/tests/Foundatio.AWS.Tests/Storage/ScopedS3StorageTests.cs +++ b/tests/Foundatio.AWS.Tests/Storage/ScopedS3StorageTests.cs @@ -33,6 +33,12 @@ public override Task CanGetFileListForSingleFolderAsync() return base.CanGetFileListForSingleFolderAsync(); } + [Fact] + public override Task CanGetFileListForSingleFileAsync() + { + return base.CanGetFileListForSingleFileAsync(); + } + [Fact] public override Task CanGetPagedFileListForSingleFolderAsync() { @@ -75,6 +81,12 @@ public override Task CanConcurrentlyManageFilesAsync() return base.CanConcurrentlyManageFilesAsync(); } + [Fact] + public override void CanUseDataDirectory() + { + base.CanUseDataDirectory(); + } + [Fact] public override Task CanDeleteEntireFolderAsync() { @@ -111,6 +123,30 @@ public override Task CanDeleteSpecificFilesInNestedFolderAsync() return base.CanDeleteSpecificFilesInNestedFolderAsync(); } + [Fact] + public override Task CanRoundTripSeekableStreamAsync() + { + return base.CanRoundTripSeekableStreamAsync(); + } + + [Fact] + public override Task WillRespectStreamOffsetAsync() + { + return base.WillRespectStreamOffsetAsync(); + } + + [Fact(Skip = "Write Stream is not yet supported")] + public override Task WillWriteStreamContentAsync() + { + return base.WillWriteStreamContentAsync(); + } + + [Fact] + public override Task CanSaveOverExistingStoredContent() + { + return base.CanSaveOverExistingStoredContent(); + } + [Fact] public virtual async Task WillNotReturnDirectoryInGetPagedFileListAsync() {