-
Notifications
You must be signed in to change notification settings - Fork 271
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
Override new "base" Terminate API #2829
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b9431cc
override the right Terminate API
davidmrdavid 6bb5832
Fix indentation
davidmrdavid 460fe6b
add tests
davidmrdavid e2fc345
minor edits
davidmrdavid 14eae6c
indentation fixes
davidmrdavid b690e14
indentation fixes
davidmrdavid 247cf9b
.\release_notes.md
davidmrdavid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using System.Runtime.CompilerServices; | ||
using Microsoft.Azure.Functions.Worker.Extensions.Abstractions; | ||
|
||
// TODO: Find a way to generate this dynamically at build-time | ||
[assembly: ExtensionInformation("Microsoft.Azure.WebJobs.Extensions.DurableTask", "2.13.3")] | ||
[assembly: InternalsVisibleTo("Worker.Extensions.DurableTask.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100cd1dabd5a893b40e75dc901fe7293db4a3caf9cd4d3e3ed6178d49cd476969abe74a9e0b7f4a0bb15edca48758155d35a4f05e6e852fff1b319d103b39ba04acbadd278c2753627c95e1f6f6582425374b92f51cca3deb0d2aab9de3ecda7753900a31f70a236f163006beefffe282888f85e3c76d1205ec7dfef7fa472a17b1")] | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,8 @@ public override HttpMethod Read( | |
Type objectType, | ||
JsonSerializerOptions options) | ||
{ | ||
return new HttpMethod(reader.GetString()); | ||
string readerString = reader.GetString() ?? string.Empty; | ||
return new HttpMethod(readerString); | ||
Comment on lines
+23
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a small warning that |
||
} | ||
|
||
public override void Write( | ||
|
57 changes: 57 additions & 0 deletions
57
test/Worker.Extensions.DurableTask.Tests/FunctionsDurableTaskClientTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using Microsoft.DurableTask.Client; | ||
using Microsoft.DurableTask.Client.Grpc; | ||
using Moq; | ||
|
||
namespace Microsoft.Azure.Functions.Worker.Tests | ||
{ | ||
/// <summary> | ||
/// Unit tests for <see cref="FunctionsDurableTaskClient />. | ||
/// </summary> | ||
public class FunctionsDurableTaskClientTests | ||
{ | ||
private FunctionsDurableTaskClient GetTestFunctionsDurableTaskClient() | ||
{ | ||
// construct mock client | ||
|
||
// The DurableTaskClient demands a string parameter in it's constructor, so we pass it in | ||
string clientName = string.Empty; | ||
Mock<DurableTaskClient> durableClientMock = new(clientName); | ||
|
||
Task completedTask = Task.CompletedTask; | ||
durableClientMock.Setup(x => x.TerminateInstanceAsync( | ||
It.IsAny<string>(), It.IsAny<TerminateInstanceOptions>(), It.IsAny<CancellationToken>())).Returns(completedTask); | ||
|
||
DurableTaskClient durableClient = durableClientMock.Object; | ||
FunctionsDurableTaskClient client = new FunctionsDurableTaskClient(durableClient, queryString: null); | ||
return client; | ||
} | ||
|
||
/// <summary> | ||
/// Test that the `TerminateInstnaceAsync` can be invoked without exceptions. | ||
/// Exceptions are a risk since we inherit from an abstract class where default implementations are not provided. | ||
/// </summary> | ||
[Fact] | ||
public async void TerminateDoesNotThrow() | ||
{ | ||
FunctionsDurableTaskClient client = GetTestFunctionsDurableTaskClient(); | ||
|
||
string instanceId = string.Empty; | ||
object output = string.Empty; | ||
TerminateInstanceOptions options = new TerminateInstanceOptions(); | ||
CancellationToken token = CancellationToken.None; | ||
|
||
// call terminate API with every possible parameter combination | ||
// if we don't encounter any unimplemented exceptions from the abstract class, | ||
// then the test passes | ||
|
||
await client.TerminateInstanceAsync(instanceId, token); | ||
|
||
await client.TerminateInstanceAsync(instanceId, output); | ||
await client.TerminateInstanceAsync(instanceId, output, token); | ||
|
||
await client.TerminateInstanceAsync(instanceId); | ||
await client.TerminateInstanceAsync(instanceId, options); | ||
await client.TerminateInstanceAsync(instanceId, options, token); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
test/Worker.Extensions.DurableTask.Tests/Worker.Extensions.DurableTask.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
|
||
<!-- Sign assembly so it can reference internal components of the Worker Extension package --> | ||
<SignAssembly>true</SignAssembly> | ||
<AssemblyOriginatorKeyFile>..\..\sign.snk</AssemblyOriginatorKeyFile> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="coverlet.collector" Version="6.0.0" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" /> | ||
<PackageReference Include="xunit" Version="2.5.3" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" /> | ||
<PackageReference Include="Moq" Version="4.7.145" /> | ||
<ProjectReference Include="..\..\src\Worker.Extensions.DurableTask\Worker.Extensions.DurableTask.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Using Include="Xunit" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So that internal classes can be tested in the tests project. This is a standard pattern, and we use it for the DF WebJobs Extension tests afaik.