Skip to content

Commit 392e93e

Browse files
authored
Update version to 1.11.0 (#607)
1 parent a9f4e12 commit 392e93e

5 files changed

Lines changed: 147 additions & 108 deletions

File tree

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ dotnet_diagnostic.CA1847.severity = none
4040
# We accept logging performance can improve later
4141
dotnet_diagnostic.CA1848.severity = none
4242

43+
# We accept logging performance can improve later
44+
dotnet_diagnostic.CA1873.severity = none
45+
4346
# Do not want to make all exceptions [Serializable], we don't support
4447
# cross-AppDomain currently
4548
dotnet_diagnostic.CA2237.severity = none

Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</PropertyGroup>
1919

2020
<PropertyGroup>
21-
<Version>1.10.0</Version>
21+
<Version>1.11.0</Version>
2222
<!--
2323
.NET does not allow the above version format for AssemblyVersion, and this
2424
is the version used in gRPC headers. The format is
@@ -33,7 +33,7 @@
3333
and 0.2.0 then is 0.2.0.5. But if there is no prerelease version, just
3434
leave revision off.
3535
-->
36-
<AssemblyVersion>1.10.0</AssemblyVersion>
36+
<AssemblyVersion>1.11.0</AssemblyVersion>
3737
</PropertyGroup>
3838

3939
<ItemGroup>

tests/Temporalio.Tests/Extensions/Hosting/ActivityScopeTests.cs

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -114,25 +114,31 @@ public async Task ActivityScope_CustomInstance_IsAccessible()
114114

115115
// Start the host
116116
using var tokenSource = new CancellationTokenSource();
117-
var hostTask = Task.Run(() => host.RunAsync(tokenSource.Token));
118-
119-
// Execute the workflow successfully. confirming no scope leak
120-
Assert.Null(ActivityScope.ServiceScope);
121-
Assert.Null(ActivityScope.ScopedInstance);
122-
await Client.ExecuteWorkflowAsync(
123-
(MyWorkflow wf) => wf.RunAsync("should-succeed"),
124-
new($"wf-{Guid.NewGuid()}", taskQueue));
125-
Assert.Null(ActivityScope.ServiceScope);
126-
Assert.Null(ActivityScope.ScopedInstance);
127-
128-
// Now execute a workflow with state that the interceptor will see set on the activity and
129-
// fail
130-
var exc = await Assert.ThrowsAsync<WorkflowFailedException>(() =>
131-
Client.ExecuteWorkflowAsync(
132-
(MyWorkflow wf) => wf.RunAsync("should-fail"),
133-
new($"wf-{Guid.NewGuid()}", taskQueue)));
134-
var exc2 = Assert.IsType<ActivityFailureException>(exc.InnerException);
135-
var exc3 = Assert.IsType<ApplicationFailureException>(exc2.InnerException);
136-
Assert.Equal("Intentional failure", exc3.Message);
117+
await host.StartAsync(tokenSource.Token);
118+
try
119+
{
120+
// Execute the workflow successfully. confirming no scope leak
121+
Assert.Null(ActivityScope.ServiceScope);
122+
Assert.Null(ActivityScope.ScopedInstance);
123+
await Client.ExecuteWorkflowAsync(
124+
(MyWorkflow wf) => wf.RunAsync("should-succeed"),
125+
new($"wf-{Guid.NewGuid()}", taskQueue));
126+
Assert.Null(ActivityScope.ServiceScope);
127+
Assert.Null(ActivityScope.ScopedInstance);
128+
129+
// Now execute a workflow with state that the interceptor will see set on the activity and
130+
// fail
131+
var exc = await Assert.ThrowsAsync<WorkflowFailedException>(() =>
132+
Client.ExecuteWorkflowAsync(
133+
(MyWorkflow wf) => wf.RunAsync("should-fail"),
134+
new($"wf-{Guid.NewGuid()}", taskQueue)));
135+
var exc2 = Assert.IsType<ActivityFailureException>(exc.InnerException);
136+
var exc3 = Assert.IsType<ApplicationFailureException>(exc2.InnerException);
137+
Assert.Equal("Intentional failure", exc3.Message);
138+
}
139+
finally
140+
{
141+
await host.StopAsync(tokenSource.Token);
142+
}
137143
}
138144
}

tests/Temporalio.Tests/Extensions/Hosting/TemporalWorkerServiceTests.cs

Lines changed: 112 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,24 @@ public async Task TemporalWorkerService_ExecuteAsync_SimpleWorker()
9393

9494
// Start the host
9595
using var tokenSource = new CancellationTokenSource();
96-
var hostTask = Task.Run(() => host.RunAsync(tokenSource.Token));
97-
98-
// Execute the workflow
99-
var result = await Client.ExecuteWorkflowAsync(
100-
(DatabaseWorkflow wf) => wf.RunAsync(),
101-
new($"wf-{Guid.NewGuid()}", taskQueue));
102-
// Single activity calls use the same client but different calls use different clients
103-
Assert.Equal(
104-
new List<string> { "something-6", "something-7", "something-6", "something-7", "something-static" },
105-
result);
106-
// Confirm the log appeared
107-
Assert.Contains(loggerFactory.Logs, e => e.Formatted == "Running database workflow");
96+
await host.StartAsync(tokenSource.Token);
97+
try
98+
{
99+
// Execute the workflow
100+
var result = await Client.ExecuteWorkflowAsync(
101+
(DatabaseWorkflow wf) => wf.RunAsync(),
102+
new($"wf-{Guid.NewGuid()}", taskQueue));
103+
// Single activity calls use the same client but different calls use different clients
104+
Assert.Equal(
105+
new List<string> { "something-6", "something-7", "something-6", "something-7", "something-static" },
106+
result);
107+
// Confirm the log appeared
108+
Assert.Contains(loggerFactory.Logs, e => e.Formatted == "Running database workflow");
109+
}
110+
finally
111+
{
112+
await host.StopAsync(tokenSource.Token);
113+
}
108114
}
109115

110116
public class SingletonCounter
@@ -186,27 +192,33 @@ public async Task TemporalWorkerService_ExecuteAsync_MultipleWorkers()
186192
// Start the host
187193
using var tokenSource = new CancellationTokenSource();
188194
using var host = bld.Build();
189-
var hostTask = Task.Run(() => host.RunAsync(tokenSource.Token));
190-
191-
// Execute the workflow
192-
var result = await Client.ExecuteWorkflowAsync(
193-
(MultiTaskQueueWorkflow wf) => wf.RunAsync(taskQueue2),
194-
new($"wf-{Guid.NewGuid()}", taskQueue1));
195-
Assert.Equal(
196-
new Dictionary<string, string>()
197-
{
198-
// Singletons share
199-
["singleton1"] = $"tq: {taskQueue1}, counter: 6",
200-
["singleton2"] = $"tq: {taskQueue1}, counter: 7",
201-
["singleton-other1"] = $"tq: {taskQueue2}, counter: 8",
202-
["singleton-other2"] = $"tq: {taskQueue2}, counter: 9",
203-
// Scoped do not share
204-
["scoped1"] = $"tq: {taskQueue1}, counter: 6",
205-
["scoped2"] = $"tq: {taskQueue1}, counter: 6",
206-
["scoped-other1"] = $"tq: {taskQueue2}, counter: 6",
207-
["scoped-other2"] = $"tq: {taskQueue2}, counter: 6",
208-
},
209-
result);
195+
await host.StartAsync(tokenSource.Token);
196+
try
197+
{
198+
// Execute the workflow
199+
var result = await Client.ExecuteWorkflowAsync(
200+
(MultiTaskQueueWorkflow wf) => wf.RunAsync(taskQueue2),
201+
new($"wf-{Guid.NewGuid()}", taskQueue1));
202+
Assert.Equal(
203+
new Dictionary<string, string>()
204+
{
205+
// Singletons share
206+
["singleton1"] = $"tq: {taskQueue1}, counter: 6",
207+
["singleton2"] = $"tq: {taskQueue1}, counter: 7",
208+
["singleton-other1"] = $"tq: {taskQueue2}, counter: 8",
209+
["singleton-other2"] = $"tq: {taskQueue2}, counter: 9",
210+
// Scoped do not share
211+
["scoped1"] = $"tq: {taskQueue1}, counter: 6",
212+
["scoped2"] = $"tq: {taskQueue1}, counter: 6",
213+
["scoped-other1"] = $"tq: {taskQueue2}, counter: 6",
214+
["scoped-other2"] = $"tq: {taskQueue2}, counter: 6",
215+
},
216+
result);
217+
}
218+
finally
219+
{
220+
await host.StopAsync(tokenSource.Token);
221+
}
210222
}
211223

212224
[Workflow]
@@ -266,25 +278,31 @@ public async Task TemporalWorkerService_WorkerClientReplacement_UsesNewClient()
266278
// Start the host
267279
using var tokenSource = new CancellationTokenSource();
268280
using var host = bld.Build();
269-
var hostTask = Task.Run(() => host.RunAsync(tokenSource.Token));
270-
271-
// Confirm the first ticking workflow has completed a task but not the second workflow
272-
await AssertMore.HasEventEventuallyAsync(handle1, e => e.WorkflowTaskCompletedEventAttributes != null);
273-
await foreach (var evt in handle2.FetchHistoryEventsAsync())
281+
await host.StartAsync(tokenSource.Token);
282+
try
274283
{
275-
Assert.Null(evt.WorkflowTaskCompletedEventAttributes);
276-
}
284+
// Confirm the first ticking workflow has completed a task but not the second workflow
285+
await AssertMore.HasEventEventuallyAsync(handle1, e => e.WorkflowTaskCompletedEventAttributes != null);
286+
await foreach (var evt in handle2.FetchHistoryEventsAsync())
287+
{
288+
Assert.Null(evt.WorkflowTaskCompletedEventAttributes);
289+
}
277290

278-
// Now replace the client, which should be used fairly quickly because we should have
279-
// timer-done poll completions every 100ms
280-
workerClientUpdater.UpdateClient(otherEnv.Client);
291+
// Now replace the client, which should be used fairly quickly because we should have
292+
// timer-done poll completions every 100ms
293+
workerClientUpdater.UpdateClient(otherEnv.Client);
281294

282-
// Now confirm the other workflow has started
283-
await AssertMore.HasEventEventuallyAsync(handle2, e => e.WorkflowTaskCompletedEventAttributes != null);
295+
// Now confirm the other workflow has started
296+
await AssertMore.HasEventEventuallyAsync(handle2, e => e.WorkflowTaskCompletedEventAttributes != null);
284297

285-
// Terminate both
286-
await handle1.TerminateAsync();
287-
await handle2.TerminateAsync();
298+
// Terminate both
299+
await handle1.TerminateAsync();
300+
await handle2.TerminateAsync();
301+
}
302+
finally
303+
{
304+
await host.StopAsync(tokenSource.Token);
305+
}
288306
}
289307

290308
[Workflow("DeploymentVersioningWorkflow", VersioningBehavior = VersioningBehavior.Pinned)]
@@ -323,23 +341,29 @@ public async Task TemporalWorkerService_ExecuteAsync_MultipleVersionsSameQueue()
323341
// Start the host
324342
using var tokenSource = new CancellationTokenSource();
325343
using var host = bld.Build();
326-
var hostTask = Task.Run(() => host.RunAsync(tokenSource.Token));
327-
328-
// Set 1.0 as default and run
329-
await Env.Client.UpdateWorkerBuildIdCompatibilityAsync(
330-
taskQueue, new BuildIdOp.AddNewDefault("1.0"));
331-
var res = await Client.ExecuteWorkflowAsync(
332-
(WorkflowV1 wf) => wf.RunAsync(),
333-
new($"wf-{Guid.NewGuid()}", taskQueue));
334-
Assert.Equal("done-v1", res);
335-
336-
// Update default and run again
337-
await Env.Client.UpdateWorkerBuildIdCompatibilityAsync(
338-
taskQueue, new BuildIdOp.AddNewDefault("2.0"));
339-
res = await Client.ExecuteWorkflowAsync(
340-
(WorkflowV1 wf) => wf.RunAsync(),
341-
new($"wf-{Guid.NewGuid()}", taskQueue));
342-
Assert.Equal("done-v2", res);
344+
await host.StartAsync(tokenSource.Token);
345+
try
346+
{
347+
// Set 1.0 as default and run
348+
await Env.Client.UpdateWorkerBuildIdCompatibilityAsync(
349+
taskQueue, new BuildIdOp.AddNewDefault("1.0"));
350+
var res = await Client.ExecuteWorkflowAsync(
351+
(WorkflowV1 wf) => wf.RunAsync(),
352+
new($"wf-{Guid.NewGuid()}", taskQueue));
353+
Assert.Equal("done-v1", res);
354+
355+
// Update default and run again
356+
await Env.Client.UpdateWorkerBuildIdCompatibilityAsync(
357+
taskQueue, new BuildIdOp.AddNewDefault("2.0"));
358+
res = await Client.ExecuteWorkflowAsync(
359+
(WorkflowV1 wf) => wf.RunAsync(),
360+
new($"wf-{Guid.NewGuid()}", taskQueue));
361+
Assert.Equal("done-v2", res);
362+
}
363+
finally
364+
{
365+
await host.StopAsync(tokenSource.Token);
366+
}
343367
#pragma warning restore CS0618
344368
}
345369

@@ -362,23 +386,29 @@ public async Task TemporalWorkerService_ExecuteAsync_MultipleDeploymentVersionsS
362386
// Start the host
363387
using var tokenSource = new CancellationTokenSource();
364388
using var host = bld.Build();
365-
var hostTask = Task.Run(() => host.RunAsync(tokenSource.Token));
366-
367-
// Set 1.0 as default and run
368-
var describe1 = await TestUtils.WaitUntilWorkerDeploymentVisibleAsync(Client, workerV1);
369-
await TestUtils.SetCurrentDeploymentVersionAsync(Client, describe1.ConflictToken, workerV1);
370-
var res = await Client.ExecuteWorkflowAsync(
371-
(WorkflowV1 wf) => wf.RunAsync(),
372-
new($"wf-{Guid.NewGuid()}", taskQueue));
373-
Assert.Equal("done-v1", res);
374-
375-
// Update default and run again
376-
var describe2 = await TestUtils.WaitUntilWorkerDeploymentVisibleAsync(Client, workerV2);
377-
await TestUtils.SetCurrentDeploymentVersionAsync(Client, describe2.ConflictToken, workerV2);
378-
res = await Client.ExecuteWorkflowAsync(
379-
(WorkflowV1 wf) => wf.RunAsync(),
380-
new($"wf-{Guid.NewGuid()}", taskQueue));
381-
Assert.Equal("done-v2", res);
389+
await host.StartAsync(tokenSource.Token);
390+
try
391+
{
392+
// Set 1.0 as default and run
393+
var describe1 = await TestUtils.WaitUntilWorkerDeploymentVisibleAsync(Client, workerV1);
394+
await TestUtils.SetCurrentDeploymentVersionAsync(Client, describe1.ConflictToken, workerV1);
395+
var res = await Client.ExecuteWorkflowAsync(
396+
(WorkflowV1 wf) => wf.RunAsync(),
397+
new($"wf-{Guid.NewGuid()}", taskQueue));
398+
Assert.Equal("done-v1", res);
399+
400+
// Update default and run again
401+
var describe2 = await TestUtils.WaitUntilWorkerDeploymentVisibleAsync(Client, workerV2);
402+
await TestUtils.SetCurrentDeploymentVersionAsync(Client, describe2.ConflictToken, workerV2);
403+
res = await Client.ExecuteWorkflowAsync(
404+
(WorkflowV1 wf) => wf.RunAsync(),
405+
new($"wf-{Guid.NewGuid()}", taskQueue));
406+
Assert.Equal("done-v2", res);
407+
}
408+
finally
409+
{
410+
await host.StopAsync(tokenSource.Token);
411+
}
382412
}
383413

384414
[Fact]

tests/Temporalio.Tests/Worker/WorkerDeploymentVersioningTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@ public async Task WorkerWithDeploymentOptions_FollowsVersioningBehavior()
105105
DeploymentOptions = new(workerV3, true),
106106
}.AddWorkflow<DeploymentVersioningWorkflowV3AutoUpgrade>());
107107

108-
var testTask = ExecuteTest(worker1, worker2, worker3);
108+
var testTask = ExecuteTest();
109109
await Task.WhenAll(
110110
worker1.ExecuteAsync(() => testTask),
111111
worker2.ExecuteAsync(() => testTask),
112112
worker3.ExecuteAsync(() => testTask));
113113

114-
async Task ExecuteTest(TemporalWorker w1, TemporalWorker w2, TemporalWorker w3)
114+
async Task ExecuteTest()
115115
{
116116
// Wait for deployment version to be registered and make it current
117117
var describe1 = await TestUtils.WaitUntilWorkerDeploymentVisibleAsync(Client, workerV1);
@@ -181,12 +181,12 @@ public async Task WorkerDeploymentRamp_ChangesTaskDistribution()
181181
DeploymentOptions = new(v2, true),
182182
}.AddWorkflow<DeploymentVersioningWorkflowV2Pinned>());
183183

184-
var testTask = ExecuteRampTest(worker1, worker2);
184+
var testTask = ExecuteRampTest();
185185
await Task.WhenAll(
186186
worker1.ExecuteAsync(() => testTask),
187187
worker2.ExecuteAsync(() => testTask));
188188

189-
async Task ExecuteRampTest(TemporalWorker w1, TemporalWorker w2)
189+
async Task ExecuteRampTest()
190190
{
191191
await TestUtils.WaitUntilWorkerDeploymentVisibleAsync(Client, v1);
192192
var describeResp = await TestUtils.WaitUntilWorkerDeploymentVisibleAsync(Client, v2);

0 commit comments

Comments
 (0)