Skip to content

Commit 1d258e4

Browse files
author
Sophia Tevosyan
committed
added a test
1 parent fb3c483 commit 1d258e4

File tree

3 files changed

+52
-4
lines changed

3 files changed

+52
-4
lines changed

src/InProcessTestHost/Sidecar/Grpc/ProtobufUtils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ public static OrchestratorAction ToOrchestratorAction(Proto.OrchestratorAction a
288288
ParentTraceContext = a.CreateSubOrchestration.ParentTraceContext is not null
289289
? new DistributedTraceContext(a.CreateSubOrchestration.ParentTraceContext.TraceParent, a.CreateSubOrchestration.ParentTraceContext.TraceState)
290290
: null,
291-
Tags = null, // TODO
291+
Tags = a.CreateSubOrchestration.Tags,
292292
Version = a.CreateSubOrchestration.Version,
293293
};
294294
case Proto.OrchestratorAction.OrchestratorActionTypeOneofCase.CreateTimer:

src/Worker/Core/Shims/TaskOrchestrationContextWrapper.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ public override async Task<TResult> CallSubOrchestratorAsync<TResult>(
235235
orchestratorName.Name,
236236
version,
237237
instanceId,
238-
input),
238+
input,
239+
options?.Tags),
239240
orchestratorName.Name,
240241
handler,
241242
default);
@@ -246,7 +247,8 @@ public override async Task<TResult> CallSubOrchestratorAsync<TResult>(
246247
orchestratorName.Name,
247248
version,
248249
instanceId,
249-
input);
250+
input,
251+
options?.Tags);
250252
}
251253
}
252254
catch (global::DurableTask.Core.Exceptions.SubOrchestrationFailedException e)

test/Grpc.IntegrationTests/OrchestrationPatterns.cs

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public async Task EmptyOrchestration()
3636
}
3737

3838
[Fact]
39-
public async Task ScheduleOrchesrationWithTags()
39+
public async Task ScheduleOrchestrationWithTags()
4040
{
4141
TaskName orchestratorName = nameof(EmptyOrchestration);
4242
await using HostTestLifetime server = await this.StartWorkerAsync(b =>
@@ -67,6 +67,52 @@ public async Task ScheduleOrchesrationWithTags()
6767
Assert.Equal("value2", metadata.Tags["tag2"]);
6868
}
6969

70+
[Fact]
71+
public async Task ScheduleSubOrchestrationWithTags()
72+
{
73+
TaskName orchestratorName = nameof(ScheduleSubOrchestrationWithTags);
74+
75+
// Schedule a new orchestration instance with tags
76+
SubOrchestrationOptions subOrchestrationOptions = new()
77+
{
78+
InstanceId = "instance_id",
79+
Tags = new Dictionary<string, string>
80+
{
81+
{ "tag1", "value1" },
82+
{ "tag2", "value2" }
83+
}
84+
};
85+
86+
await using HostTestLifetime server = await this.StartWorkerAsync(b =>
87+
{
88+
b.AddTasks(tasks => tasks.AddOrchestratorFunc<int, int>(orchestratorName, async (ctx, input) =>
89+
{
90+
int result = 1;
91+
if (input < 2)
92+
{
93+
// recursively call this same orchestrator
94+
result += await ctx.CallSubOrchestratorAsync<int>(orchestratorName, input: input + 1, subOrchestrationOptions);
95+
}
96+
97+
return result;
98+
}));
99+
});
100+
101+
102+
await server.Client.ScheduleNewOrchestrationInstanceAsync(orchestratorName, input: 1);
103+
104+
OrchestrationMetadata metadata = await server.Client.WaitForInstanceCompletionAsync(
105+
subOrchestrationOptions.InstanceId, this.TimeoutToken);
106+
107+
Assert.NotNull(metadata);
108+
Assert.Equal(subOrchestrationOptions.InstanceId, metadata.InstanceId);
109+
Assert.Equal(OrchestrationRuntimeStatus.Completed, metadata.RuntimeStatus);
110+
Assert.NotNull(metadata.Tags);
111+
Assert.Equal(2, metadata.Tags.Count);
112+
Assert.Equal("value1", metadata.Tags["tag1"]);
113+
Assert.Equal("value2", metadata.Tags["tag2"]);
114+
}
115+
70116
[Fact]
71117
public async Task SingleTimer()
72118
{

0 commit comments

Comments
 (0)