Skip to content

Commit b9d764f

Browse files
committed
save
1 parent dd75b8d commit b9d764f

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

test/Grpc.IntegrationTests/LargePayloadTests.cs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,58 @@ public async Task LargeOrchestrationInputAndOutputAndCustomStatus()
8888
Assert.Contains(JsonSerializer.Serialize(largeInput + largeInput), fakeStore.uploadedPayloads);
8989
}
9090

91+
// Validates terminating an instance with a large output payload is externalized by the client.
92+
[Fact]
93+
public async Task LargeTerminateWithPayload()
94+
{
95+
string largeOutput = new string('T', 900 * 1024);
96+
TaskName orch = nameof(LargeTerminateWithPayload);
97+
98+
InMemoryPayloadStore store = new InMemoryPayloadStore();
99+
100+
await using HostTestLifetime server = await this.StartWorkerAsync(
101+
worker =>
102+
{
103+
worker.AddTasks(tasks => tasks.AddOrchestratorFunc<object?, object?>(
104+
orch,
105+
async (ctx, _) =>
106+
{
107+
await ctx.CreateTimer(TimeSpan.FromSeconds(30), CancellationToken.None);
108+
return null;
109+
}));
110+
111+
worker.UseExternalizedPayloads(opts =>
112+
{
113+
opts.ExternalizeThresholdBytes = 1024;
114+
opts.ContainerName = "test";
115+
opts.ConnectionString = "UseDevelopmentStorage=true";
116+
});
117+
worker.Services.AddSingleton<IPayloadStore>(store);
118+
},
119+
client =>
120+
{
121+
client.UseExternalizedPayloads(opts =>
122+
{
123+
opts.ExternalizeThresholdBytes = 1024;
124+
opts.ContainerName = "test";
125+
opts.ConnectionString = "UseDevelopmentStorage=true";
126+
});
127+
client.Services.AddSingleton<IPayloadStore>(store);
128+
});
129+
130+
string id = await server.Client.ScheduleNewOrchestrationInstanceAsync(orch);
131+
await server.Client.WaitForInstanceStartAsync(id, this.TimeoutToken);
132+
133+
await server.Client.TerminateInstanceAsync(id, new TerminateInstanceOptions { Output = largeOutput }, this.TimeoutToken);
134+
135+
await server.Client.WaitForInstanceCompletionAsync(id, this.TimeoutToken);
136+
OrchestrationMetadata? status = await server.Client.GetInstanceAsync(id, getInputsAndOutputs: false);
137+
Assert.NotNull(status);
138+
Assert.Equal(OrchestrationRuntimeStatus.Terminated, status!.RuntimeStatus);
139+
Assert.True(store.UploadCount >= 1);
140+
Assert.True(store.DownloadCount >= 1);
141+
Assert.Contains(JsonSerializer.Serialize(largeOutput), store.uploadedPayloads);
142+
}
91143
// Validates large custom status and ContinueAsNew input are externalized and resolved across iterations.
92144
[Fact]
93145
public async Task LargeContinueAsNewAndCustomStatus()
@@ -412,6 +464,8 @@ public async Task LargeExternalEvent()
412464
string? output = completed.ReadOutputAs<string>();
413465
Assert.Equal(largeEvent, output);
414466
Assert.True(fakeStore.UploadCount >= 1);
467+
Assert.True(fakeStore.DownloadCount >= 1);
468+
Assert.Contains(JsonSerializer.Serialize(largeEvent), fakeStore.uploadedPayloads);
415469
}
416470

417471

0 commit comments

Comments
 (0)