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 1ES CI for DTFx.AS v2 #1139

Merged
merged 35 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6807f98
increase timeouts
davidmrdavid Jul 13, 2024
7bbfb20
pass 1ES CI
davidmrdavid Jul 16, 2024
5341508
resolve warning
davidmrdavid Jul 16, 2024
dd49cf6
Fix indent
davidmrdavid Jul 16, 2024
4bc59ce
test removing pkg
davidmrdavid Jul 16, 2024
b2bd2f9
re-add dep
davidmrdavid Jul 16, 2024
bc9a5ea
add TODOs
davidmrdavid Jul 17, 2024
aa77bd5
testing the removal of netcoreapp3.1 in test
davidmrdavid Jul 17, 2024
56984ce
test method rename
davidmrdavid Jul 17, 2024
eef1d03
try renaming clean up
davidmrdavid Jul 17, 2024
b45e013
try conditional compilation
davidmrdavid Jul 17, 2024
5b7b1d8
simplify test assembly paths
davidmrdavid Jul 17, 2024
aa060c2
test
davidmrdavid Jul 17, 2024
941decc
adapt test clean up and initializers to work better with CI
davidmrdavid Jul 17, 2024
1e1275d
clean out NET462
davidmrdavid Jul 17, 2024
15f44df
try mitigation
davidmrdavid Jul 17, 2024
1c0c4d2
rev deps
davidmrdavid Jul 17, 2024
b1eec32
rev logging abstractions
davidmrdavid Jul 17, 2024
345fc27
add back compilerServices.Unsafe 6.x
davidmrdavid Jul 17, 2024
e791819
remove binding redirect in app.config
davidmrdavid Jul 17, 2024
01ba1b2
keep diagnosticsource low
davidmrdavid Jul 18, 2024
896fcc5
increase diagnostics source
davidmrdavid Jul 18, 2024
5df3df2
clean up
davidmrdavid Jul 18, 2024
dd7c604
diagnostic source to 6.0.01
davidmrdavid Jul 18, 2024
f1b0f72
rev diagnostic source
davidmrdavid Jul 18, 2024
de3761a
rev Azure.Core
davidmrdavid Jul 18, 2024
4bf3039
rev logging abstractions
davidmrdavid Jul 18, 2024
2e7d199
rev logging abstractions in azstorage
davidmrdavid Jul 18, 2024
1dda1ab
decrease logging change, try again to run all tests
davidmrdavid Jul 18, 2024
be16e51
add parens
davidmrdavid Jul 18, 2024
cb72151
simplify signature
davidmrdavid Jul 18, 2024
1f56a2d
try v3
davidmrdavid Jul 18, 2024
bd915ec
remove parallelism in DT.Core
davidmrdavid Jul 18, 2024
4d4dda0
get tests to pass
davidmrdavid Jul 18, 2024
275b3dd
re-enable all partition manager tests
davidmrdavid Jul 18, 2024
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
8 changes: 4 additions & 4 deletions eng/ci/public-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ resources:
ref: refs/tags/release

extends:
# The template we extend injects compliance-checks into the pipleine, such as SDL and CodeQL
# The template we extend injects compliance-checks into the pipeline, such as SDL and CodeQL
template: v1/1ES.Unofficial.PipelineTemplate.yml@1es
parameters:
pool:
Expand Down Expand Up @@ -67,7 +67,7 @@ extends:
# Run tests
- template: /eng/templates/test.yml@self
parameters:
testAssembly: '**\bin\**\netcoreapp3.1\DurableTask.Core.Tests.dll'
testAssembly: '**\bin\**\DurableTask.Core.Tests.dll'
- stage: DTFxASValidate
dependsOn: []
jobs:
Expand All @@ -86,7 +86,7 @@ extends:
# Run tests
- template: /eng/templates/test.yml@self
parameters:
testAssembly: '**\bin\**\netcoreapp3.1\DurableTask.AzureStorage.Tests.dll'
testAssembly: '**\bin\**\DurableTask.AzureStorage.Tests.dll'
- stage: DTFxEmulatorValidate
dependsOn: []
jobs:
Expand All @@ -105,4 +105,4 @@ extends:
# Run tests
- template: /eng/templates/test.yml@self
parameters:
testAssembly: '**\bin\**\netcoreapp3.1\DurableTask.Emulator.Tests.dll'
testAssembly: '**\bin\**\DurableTask.Emulator.Tests.dll'
24 changes: 11 additions & 13 deletions eng/templates/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,14 @@ steps:
- task: VSTest@2
displayName: 'Run tests'
inputs:
testAssemblyVer2: |
${{ parameters.testAssembly }}
!**\obj\**
testFiltercriteria: 'TestCategory!=DisabledInCI'
vsTestVersion: 17.0
distributionBatchType: basedOnExecutionTime
platform: 'any cpu'
configuration: 'Debug'
diagnosticsEnabled: True
collectDumpOn: always
rerunFailedTests: true
rerunFailedThreshold: 30
rerunMaxAttempts: 3
testAssemblyVer2: ${{ parameters.testAssembly }}
testFiltercriteria: 'TestCategory!=DisabledInCI'
vsTestVersion: 17.0
distributionBatchType: basedOnExecutionTime
platform: 'any cpu'
configuration: 'Debug'
diagnosticsEnabled: True
collectDumpOn: always
rerunFailedTests: true
rerunFailedThreshold: 30
rerunMaxAttempts: 3
9 changes: 7 additions & 2 deletions src/DurableTask.AzureStorage/DurableTask.AzureStorage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>embedded</DebugType>
<IncludeSymbols>false</IncludeSymbols>
<!--NuGet licenseUrl and PackageIconUrl/iconUrl deprecation. -->
<PackageReadmeFile>.\README.md</PackageReadmeFile>
<!--NuGet licenseUrl and PackageIconUrl/iconUrl deprecation. -->
<NoWarn>NU5125;NU5048;CS7035</NoWarn> <!-- TODO: addition of CS7035 (version format doesn't follow convention) is a temporary workaround during 1ES migration -->
</PropertyGroup>

Expand All @@ -40,7 +41,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Core" Version="1.40.0" />
<PackageReference Include="Azure.Core" Version="1.41.0" />
cgillum marked this conversation as resolved.
Show resolved Hide resolved
<PackageReference Include="Azure.Data.Tables" Version="12.8.3" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.20.0" />
<PackageReference Include="Azure.Storage.Queues" Version="12.18.0" />
Expand All @@ -53,6 +54,10 @@
<ProjectReference Include="..\DurableTask.Core\DurableTask.Core.csproj" />
</ItemGroup>

<ItemGroup>
<None Include=".\..\..\README.md" Pack="true" PackagePath="\"/>
</ItemGroup>

<ItemGroup Condition="'$(Configuration)'=='Release'">
<Content Include="..\..\_manifest\**">
<Pack>true</Pack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ public override async IAsyncEnumerable<OrchestrationState> GetStateAsync(IEnumer
yield break;
}

IEnumerable<Task<OrchestrationState>> instanceQueries = instanceIds.Select(instance => this.GetStateAsync(instance, allExecutions: true, fetchInput: false, cancellationToken).SingleAsync().AsTask());
IEnumerable<Task<OrchestrationState>> instanceQueries = instanceIds.Select(instance => this.GetStateAsync(instance, allExecutions: true, fetchInput: false, cancellationToken).SingleOrDefaultAsync().AsTask());
cgillum marked this conversation as resolved.
Show resolved Hide resolved
foreach (OrchestrationState state in await Task.WhenAll(instanceQueries))
{
if (state != null)
Expand Down
7 changes: 6 additions & 1 deletion src/DurableTask.Core/DurableTask.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<FileVersion Condition="'$(FileVersionRevision)' != ''">$(VersionPrefix).$(FileVersionRevision)</FileVersion>
<!-- The assembly version is only the major/minor pair, making it easier to do in-place upgrades -->
<AssemblyVersion>$(MajorVersion).$(MinorVersion).0.0</AssemblyVersion>
<PackageReadmeFile>.\README.md</PackageReadmeFile>
</PropertyGroup>

<!-- This version is used as the nuget package version -->
Expand All @@ -38,12 +39,16 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="5.0.1" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="6.0.1" />
<PackageReference Include="System.Reactive.Core" Version="4.4.1" />
<PackageReference Include="System.Reactive.Compatibility" Version="4.4.1" />
<PackageReference Include="Castle.Core" Version="5.0.0" />
</ItemGroup>

<ItemGroup>
<None Include=".\..\..\README.md" Pack="true" PackagePath="\"/>
</ItemGroup>

<ItemGroup Condition="'$(Configuration)'=='Release'">
<Content Include="..\..\_manifest\**">
<Pack>true</Pack>
Expand Down
1 change: 1 addition & 0 deletions src/DurableTask.Core/TaskActivityDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace DurableTask.Core
using DurableTask.Core.Logging;
using DurableTask.Core.Middleware;
using DurableTask.Core.Tracing;
using ActivityStatusCode = Tracing.ActivityStatusCode;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

after upgrading DTFx.Core's System.Diagnostics.DiagnosticSource to 6.x, there's some ambiguous definitions here. So I needed to add this alias to disambiguate


/// <summary>
/// Dispatcher for task activities to handle processing and renewing of work items
Expand Down
1 change: 1 addition & 0 deletions src/DurableTask.Core/TaskOrchestrationDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace DurableTask.Core
using DurableTask.Core.Middleware;
using DurableTask.Core.Serializing;
using DurableTask.Core.Tracing;
using ActivityStatusCode = Tracing.ActivityStatusCode;

/// <summary>
/// Dispatcher for orchestrations to handle processing and renewing, completion of orchestration events
Expand Down
14 changes: 7 additions & 7 deletions src/DurableTask.Core/Tracing/TraceHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public class TraceHelper
DateTimeOffset startTime = startEvent.ParentTraceContext.ActivityStartTime ?? default;

Activity? activity = ActivityTraceSource.StartActivity(
name: activityName,
activityName,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

after upgrading DTFx.Core's System.Diagnostics.DiagnosticSource to 6.x, these named parameters create ambiguous method invocations here (there's multiple versions of this method with the same parameters in different orders). Using a positional argument here disambiguates the call.

kind: activityKind,
parentContext: activityContext,
startTime: startTime);
Expand Down Expand Up @@ -139,7 +139,7 @@ public class TraceHelper
}

Activity? newActivity = ActivityTraceSource.StartActivity(
name: CreateSpanName(TraceActivityConstants.Activity, scheduledEvent.Name, scheduledEvent.Version),
CreateSpanName(TraceActivityConstants.Activity, scheduledEvent.Name, scheduledEvent.Version),
kind: ActivityKind.Server,
parentContext: activityContext);

Expand Down Expand Up @@ -180,7 +180,7 @@ public class TraceHelper
}

Activity? newActivity = ActivityTraceSource.StartActivity(
name: CreateSpanName(TraceActivityConstants.Activity, taskScheduledEvent.Name, taskScheduledEvent.Version),
CreateSpanName(TraceActivityConstants.Activity, taskScheduledEvent.Name, taskScheduledEvent.Version),
kind: ActivityKind.Client,
startTime: taskScheduledEvent.Timestamp,
parentContext: Activity.Current?.Context ?? default);
Expand Down Expand Up @@ -274,7 +274,7 @@ internal static void EmitTraceActivityForTaskFailed(
}

Activity? activity = ActivityTraceSource.StartActivity(
name: CreateSpanName(TraceActivityConstants.Orchestration, createdEvent.Name, createdEvent.Version),
CreateSpanName(TraceActivityConstants.Orchestration, createdEvent.Name, createdEvent.Version),
kind: ActivityKind.Client,
startTime: createdEvent.Timestamp,
parentContext: Activity.Current?.Context ?? default);
Expand Down Expand Up @@ -358,7 +358,7 @@ internal static void EmitTraceActivityForSubOrchestrationFailed(
string? targetInstanceId)
{
Activity? newActivity = ActivityTraceSource.StartActivity(
name: CreateSpanName(TraceActivityConstants.OrchestrationEvent, eventRaisedEvent.Name, null),
CreateSpanName(TraceActivityConstants.OrchestrationEvent, eventRaisedEvent.Name, null),
kind: ActivityKind.Producer,
parentContext: Activity.Current?.Context ?? default);

Expand Down Expand Up @@ -391,7 +391,7 @@ internal static void EmitTraceActivityForSubOrchestrationFailed(
internal static Activity? StartActivityForNewEventRaisedFromClient(EventRaisedEvent eventRaised, OrchestrationInstance instance)
{
Activity? newActivity = ActivityTraceSource.StartActivity(
name: CreateSpanName(TraceActivityConstants.OrchestrationEvent, eventRaised.Name, null),
CreateSpanName(TraceActivityConstants.OrchestrationEvent, eventRaised.Name, null),
kind: ActivityKind.Producer,
parentContext: Activity.Current?.Context ?? default,
tags: new KeyValuePair<string, object?>[]
Expand All @@ -418,7 +418,7 @@ internal static void EmitTraceActivityForTimer(
TimerFiredEvent timerFiredEvent)
{
Activity? newActivity = ActivityTraceSource.StartActivity(
name: CreateTimerSpanName(orchestrationName),
CreateTimerSpanName(orchestrationName),
kind: ActivityKind.Internal,
startTime: startTime,
parentContext: Activity.Current?.Context ?? default);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2252,6 +2252,7 @@ await Task.WhenAll(
/// End-to-end test which validates a simple orchestrator function that calls an activity function
/// and checks the OpenTelemetry trace information
/// </summary>
[TestCategory("DisabledInCI")]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

these disabled tests have not been running for a long time, and they're failing in the main branch as well. They weren't running because they're conditionally compiled not to run in NET462, and our previous testing task in ADO was configured to run tests found in the net462 dll.

Now, the test task does discover these tests, but I've disabled them as they aren't passing. @bachuv can you please add this as a To-Fix before Dist. Tracing GA?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, I'll add this task to the list.

[DataTestMethod]
[DataRow(true)]
[DataRow(false)]
Expand Down Expand Up @@ -2344,6 +2345,7 @@ public async Task OpenTelemetry_SayHelloWithActivity(bool enableExtendedSessions
/// End-to-end test which validates a simple orchestrator function that waits for an external event
/// raised through the RaiseEvent API and checks the OpenTelemetry trace information
/// </summary>
[TestCategory("DisabledInCI")]
[DataTestMethod]
[DataRow(true)]
[DataRow(false)]
Expand Down Expand Up @@ -2445,6 +2447,7 @@ public async Task OpenTelemetry_ExternalEvent_RaiseEvent(bool enableExtendedSess
/// End-to-end test which validates a simple orchestrator function that waits for an external event
/// raised by calling SendEvent and checks the OpenTelemetry trace information
/// </summary>
[TestCategory("DisabledInCI")]
[DataTestMethod]
[DataRow(true)]
[DataRow(false)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,31 @@
<TargetFrameworks>netcoreapp3.1;net462</TargetFrameworks>
</PropertyGroup>


<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
<PackageReference Include="Microsoft.WindowsAzure.ConfigurationManager" version="3.2.1" />
<PackageReference Include="WindowsAzure.Storage" version="8.7.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net462'">
<PackageReference Include="Azure.Monitor.OpenTelemetry.Exporter" Version="1.0.0-beta.3" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.6" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

newtonsoft.json is inherited by the DTFx.Core project

<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.5.0" />
<PackageReference Include="WindowsAzure.Storage" version="9.3.3" />
</ItemGroup>

<!-- Common package dependencies -->
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.2.0" />
Comment on lines +21 to +22
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added this Logging.Console dependency because I've configured the tests to emit traces to STDOUT, which makes debugging failed ADO tests much easier. I decided to unify the dependencies to version 2.2.0 for simplicy sake and to avoid conditional compilation.

Copy link
Collaborator

Choose a reason for hiding this comment

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

2.2.0 is quite old. Can we standardize to 6.0.0 as part of the v3 change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I had some issues getting the code to build on 1ES with more recent versions. I'm open to upgrading, but since this is the test project, I'd like to push that to be a separate PR.

<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.5.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.5.0" />
<PackageReference Include="Moq" Version="4.10.0" />

<!-- We don't really make use of these dependencies, but 1ES somehow detects them in our test project and flags them for update.
Since this is just a test project, and to prevent "warning fatigue" so real CVEs stand out, we choose to upgrade the dependency explicitly to remove the false alarm.-->
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" /> <!-- Version 4.3.1 was detected by default-->
<PackageReference Include="Microsoft.Data.Services.Client" Version="5.8.4" /> <!-- Without this, we resolve Microsoft.Data.OData 5.8.2, which is flagged-->
</ItemGroup>

<ItemGroup>
Expand All @@ -48,9 +51,6 @@
<None Update="large.jpeg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="testhost.dll.config" Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Comment on lines -51 to -53
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we don't have a netcoreapp2.1 TFM

</ItemGroup>

</Project>
6 changes: 4 additions & 2 deletions test/DurableTask.AzureStorage.Tests/TestHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public static TestOrchestrationHost GetTestOrchestrationHost(
{
string storageConnectionString = GetTestStorageAccountConnectionString();

// TODO: update Microsoft.Extensions.Logging to avoid the following warning suppression
#pragma warning disable CS0618 // Type or member is obsolete
var settings = new AzureStorageOrchestrationServiceSettings
{
ExtendedSessionIdleTimeout = TimeSpan.FromSeconds(extendedSessionTimeoutInSeconds),
Expand All @@ -40,9 +42,9 @@ public static TestOrchestrationHost GetTestOrchestrationHost(
TaskHubName = GetTestTaskHubName(),

// Setting up a logger factory to enable the new DurableTask.Core logs
// TODO: Add a logger provider so we can collect these logs in memory.
LoggerFactory = new LoggerFactory(),
LoggerFactory = new LoggerFactory().AddConsole(LogLevel.Trace),
};
#pragma warning restore CS0618 // Type or member is obsolete
Comment on lines -43 to +47
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

as mentioned, I've added logging to STDOUT on our tests to facilitate debugging. The current logging library we use is pretty old, which is why we have to disable the warning here. I tried using a newer library, but then had issues with the NET462 TFM. For speed, I decided to use the old library instead, which works.


// Give the caller a chance to make test-specific changes to the settings
modifySettingsAction?.Invoke(settings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ await WaitForConditionAsync(

// Start with four workers and four partitions. Then kill three workers.
// Test that the remaining worker will take all the partitions.
[TestCategory("DisabledInCI")]
[TestMethod]
public async Task TestKillThreeWorker()
{
Expand Down Expand Up @@ -586,7 +585,6 @@ await WaitForConditionAsync(
/// Ensure that all instances should be processed sucessfully.
/// </summary>
/// <returns></returns>
[TestCategory("DisabledInCI")]
[TestMethod]
public async Task EnsureOwnedQueueExclusive()
{
Expand Down
27 changes: 21 additions & 6 deletions test/DurableTask.Core.Tests/DispatcherMiddlewareTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------
#if !NET462 // for some reasons these tests are not discoverable on 1ES, leading to the test getting aborted. TODO: Needs investigation
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Do you mean the .net462 flavor of the tests are not discoverable? The .NET Core flavor is working?

#nullable enable
namespace DurableTask.Core.Tests
{
Expand All @@ -27,6 +28,8 @@ namespace DurableTask.Core.Tests
using DurableTask.Core.History;
using DurableTask.Emulator;
using DurableTask.Test.Orchestrations;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Console;
using Microsoft.VisualStudio.TestTools.UnitTesting;

[TestClass]
Expand All @@ -36,23 +39,34 @@ public class DispatcherMiddlewareTests
TaskHubClient client = null!;

[TestInitialize]
public async Task Initialize()
public void InitializeTests()
{
// configure logging so traces are emitted during tests.
// This facilitates debugging when tests fail.

// TODO: update Microsoft.Extensions.Logging to avoid the following warning suppression
#pragma warning disable CS0618 // Type or member is obsolete
Copy link
Member

Choose a reason for hiding this comment

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

Can we add comments here with reminders to update these dependencies?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, just did here -> bc9a5ea

var loggerFactory = new LoggerFactory().AddConsole(LogLevel.Trace);
#pragma warning restore CS0618 // Type or member is obsolete
var service = new LocalOrchestrationService();
this.worker = new TaskHubWorker(service);
this.worker = new TaskHubWorker(service, loggerFactory);

await this.worker
// We use `GetAwaiter().GetResult()` because otherwise this method will fail with:
// "X has wrong signature. The method must be non-static, public, does not return a value and should not take any parameter."
this.worker
.AddTaskOrchestrations(typeof(SimplestGreetingsOrchestration), typeof(ParentWorkflow), typeof(ChildWorkflow))
.AddTaskActivities(typeof(SimplestGetUserTask), typeof(SimplestSendGreetingTask))
.StartAsync();
.StartAsync().GetAwaiter().GetResult();

this.client = new TaskHubClient(service);
}

[TestCleanup]
public async Task TestCleanup()
public void CleanupTests()
{
await this.worker!.StopAsync(true);
// We use `GetAwaiter().GetResult()` because otherwise this method will fail with:
// "X has wrong signature. The method must be non-static, public, does not return a value and should not take any parameter."
this.worker!.StopAsync(true).GetAwaiter().GetResult();
}

[TestMethod]
Expand Down Expand Up @@ -440,3 +454,4 @@ public async Task MockActivityOrchestration()
}
}
}
#endif
Loading