Skip to content
Merged

Dev #259

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"
# Check for updates to GitHub Actions every quarter
interval: "quarterly"
labels:
- "Release Not Needed"
target-branch: "dev"
target-branch: "dev"
2 changes: 1 addition & 1 deletion .github/workflows/handle-stale-discussions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ jobs:
discussions: write
steps:
- name: Stale discussions action
uses: aws-github-ops/handle-stale-discussions@711a9813957be17629fc6933afcd8bd132c57254 #v1.6
uses: aws-github-ops/handle-stale-discussions@c0beee451a5d33d9c8f048a6d4e7c856b5422544 #v1.6.0
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
2 changes: 1 addition & 1 deletion .github/workflows/semgrep-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
p/owasp-top-ten

- name: Upload SARIF file for GitHub Advanced Security Dashboard
uses: github/codeql-action/upload-sarif@60168efe1c415ce0f5521ea06d5c2062adbeed1b #v3.28.17
uses: github/codeql-action/upload-sarif@fca7ace96b7d713c7035871441bd52efbe39e27e #v3.28.19
with:
sarif_file: semgrep.sarif
if: always()
21 changes: 18 additions & 3 deletions test/AWS.Messaging.UnitTests/SQSMessagePollerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,11 @@ public async Task SQSMessagePoller_PollingControlStopped_DoesNotPollSQS()
public async Task SQSMessagePoller_PollingControlRestarted_PollsSQS()
{
var client = new Mock<IAmazonSQS>();
var messageReceived = new TaskCompletionSource<bool>();
client.Setup(x => x.ReceiveMessageAsync(It.IsAny<ReceiveMessageRequest>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(new ReceiveMessageResponse(), TimeSpan.FromMilliseconds(50));
.ReturnsAsync(new ReceiveMessageResponse(), TimeSpan.FromMilliseconds(50))
.Callback(() => messageReceived.TrySetResult(true));

var pollingControlToken = new PollingControlToken
{
PollingWaitTime = TimeSpan.FromMilliseconds(25)
Expand All @@ -90,12 +93,24 @@ public async Task SQSMessagePoller_PollingControlRestarted_PollsSQS()
var pump = BuildMessagePumpService(client, options => { options.WaitTimeSeconds = 1; }, pollingControlToken: pollingControlToken);
var task = pump.StartAsync(source.Token);

// Verify no messages are received while polling is stopped
client.Verify(x => x.ReceiveMessageAsync(It.IsAny<ReceiveMessageRequest>(), It.IsAny<CancellationToken>()), Times.Never);

// Start polling and wait for a message to be received
pollingControlToken.StartPolling();

// Wait for a message to be received with a timeout
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(5));
try
{
await messageReceived.Task.WaitAsync(cts.Token);
}
catch (OperationCanceledException)
{
Assert.Fail("Timed out waiting for message to be received after polling was restarted");
}

SpinWait.SpinUntil(() => false, pollingControlToken.PollingWaitTime * 5);

// Verify that messages were received
client.Verify(x => x.ReceiveMessageAsync(It.IsAny<ReceiveMessageRequest>(), It.IsAny<CancellationToken>()), Times.AtLeastOnce());

source.Cancel();
Expand Down