Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add suspend/resume tests #3028

Merged
merged 10 commits into from
Feb 6, 2025
Merged

Conversation

andystaples
Copy link
Contributor

Adds testing for suspend/resume in Durable

Pull request checklist

  • My changes do not require documentation changes
    • Otherwise: Documentation PR is ready to merge and referenced in pending_docs.md
  • My changes should not be added to the release notes for the next release
    • Otherwise: I've added my notes to release_notes.md
  • My changes do not need to be backported to a previous version
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • I have added all required tests (Unit tests, E2E tests)
  • My changes do not require any extra work to be leveraged by OutOfProc SDKs
    • Otherwise: That work is being tracked here: #issue_or_pr_in_each_sdk
  • My changes do not change the version of the WebJobs.Extensions.DurableTask package
    • Otherwise: major or minor version updates are reflected in /src/Worker.Extensions.DurableTask/AssemblyInfo.cs
  • My changes do not add EventIds to our EventSource logs
    • Otherwise: Ensure the EventIds are within the supported range in our existing Windows infrastructure. You may validate this with a deployed app's telemetry. You may also extend the range by completing a PR such as this one.
  • My changes should be added to v2.x branch.
    • Otherwise: This change applies exclusively to WebJobs.Extensions.DurableTask v3.x. It will be retained only in the dev and main branches and will not be merged into the v2.x branch.

Comment on lines 33 to 36
Thread.Sleep(1000);

var orchestrationDetails = await DurableHelpers.GetRunningOrchestrationDetailsAsync(statusQueryGetUri);
Assert.Equal("Running", orchestrationDetails.RuntimeStatus);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than sleeping and hoping that the status will change after the sleep interval, we can make these checks a bit more reliable and potentially faster if we use a polling pattern to check for the state change. This would address the very common flakey test problem where engineers need to increase sleep durations because things ran slower than we expected. Consider creating a helper method that can wait for an orchestration to transition from one state to another (Pending --> Running, Running --> Suspended, Suspended --> Running, etc.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Feel free to critique my implementation

try
{
using HttpResponseMessage suspendResponse = await HttpHelpers.InvokeHttpTrigger("SuspendInstance", $"?instanceId={instanceId}");
await AssertRequestFailsAsync(suspendResponse);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple things:

  1. The method AssertRequestFailsAsync assumes that the request is a termination request, but you're sending a suspend request.
  2. What's the expected behavior for in-proc? Do we throw if you try to suspend a suspended orchestration? I was hoping we wouldn't, but if we are, then checking for a failure message is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. The behavior is the same, but I've updated the parameters and variable names to reflect this.
  2. Yes, we throw in the same way for in-proc (except with a more verbose exception message, as described in the bug linked in the comments)

@andystaples andystaples merged commit 76eea66 into dev Feb 6, 2025
7 checks passed
@andystaples andystaples deleted the andystaples/add-suspend-resume-testing branch February 6, 2025 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants