Skip to content

Commit a41c3cc

Browse files
committed
Fix more tests
1 parent 14a7e2c commit a41c3cc

File tree

8 files changed

+33
-22
lines changed

8 files changed

+33
-22
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.function.JsonHelpers;
2+
3+
import java.time.Instant;
4+
5+
import com.google.gson.Gson;
6+
import com.google.gson.GsonBuilder;
7+
8+
public class DurableMetadataGsonProvider {
9+
public static Gson createGson() {
10+
return new GsonBuilder()
11+
.registerTypeAdapter(Instant.class, new InstantAdapter())
12+
.create();
13+
}
14+
}

test/e2e/Apps/BasicJava/src/main/java/com/function/LargeOutputOrchestrator.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.function;
22

33
import com.microsoft.azure.functions.annotation.*;
4+
import com.function.JsonHelpers.DurableMetadataGsonProvider;
45
import com.google.gson.Gson;
56
import com.microsoft.azure.functions.*;
67

@@ -48,7 +49,7 @@ public HttpResponseMessage httpStart(
4849
@DurableClientInput(name = "durableContext") DurableClientContext durableContext,
4950
final ExecutionContext context) {
5051
int sizeInKB = 0;
51-
Gson gson = new Gson();
52+
Gson gson = DurableMetadataGsonProvider.createGson();
5253
try {
5354
String body = request.getBody().orElse("0");
5455
sizeInKB = gson.fromJson(body, int.class);
@@ -80,10 +81,12 @@ public HttpResponseMessage queryOutput(
8081
return response;
8182
}
8283

83-
Object output = metadata.readOutputAs(Object.class);
84+
Gson gson = DurableMetadataGsonProvider.createGson();
85+
String outputJson = gson.toJson(metadata);
86+
8487
HttpResponseMessage response = request.createResponseBuilder(HttpStatus.OK)
8588
.header("Content-Type", "application/json")
86-
.body(output != null ? output.toString() : "[]")
89+
.body(outputJson)
8790
.build();
8891
return response;
8992
}

test/e2e/Apps/BasicJava/src/main/java/com/function/OrchestrationQuery.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
package com.function;
22

33
import com.microsoft.azure.functions.annotation.*;
4-
import com.function.JsonHelpers.InstantAdapter;
5-
import com.google.gson.Gson;
6-
import com.google.gson.GsonBuilder;
4+
import com.function.JsonHelpers.DurableMetadataGsonProvider;
75
import com.microsoft.azure.functions.*;
86

9-
import java.time.Instant;
107
import java.util.*;
118

129
import com.microsoft.durabletask.*;
@@ -15,12 +12,6 @@
1512

1613

1714
public class OrchestrationQuery {
18-
public Gson newInstancesConverter() {
19-
GsonBuilder gsonBuilder = new GsonBuilder();
20-
gsonBuilder.registerTypeAdapter(Instant.class, new InstantAdapter());
21-
return gsonBuilder.create();
22-
}
23-
2415
/**
2516
* This HTTP-triggered function returns all orchestration instances.
2617
*/
@@ -33,7 +24,7 @@ public HttpResponseMessage getAllInstances(
3324
try {
3425
// Java SDK: getAllInstancesAsync returns a CompletableFuture<List<OrchestrationInstanceStatus>>
3526
OrchestrationStatusQueryResult instances = client.queryInstances(new OrchestrationStatusQuery());
36-
String instanceString = newInstancesConverter().toJson(instances);
27+
String instanceString = DurableMetadataGsonProvider.createGson().toJson(instances.getOrchestrationState());
3728
return request.createResponseBuilder(HttpStatus.OK)
3829
.header("Content-Type", "application/json")
3930
.body(instanceString)
@@ -65,7 +56,7 @@ public HttpResponseMessage getRunningInstances(
6556
OrchestrationStatusQuery query = new OrchestrationStatusQuery();
6657
query.setRuntimeStatusList(statuses);
6758
OrchestrationStatusQueryResult instances = client.queryInstances(query);
68-
String instanceString = newInstancesConverter().toJson(instances);
59+
String instanceString = DurableMetadataGsonProvider.createGson().toJson(instances.getOrchestrationState());
6960
return request.createResponseBuilder(HttpStatus.OK)
7061
.header("Content-Type", "application/json")
7162
.body(instanceString)

test/e2e/Tests/Localizers/JavaTestLanguageLocalizer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ internal class JavaTestLanguageLocalizer : ITestLanguageLocalizer
77
private readonly Dictionary<string, string> isolatedLocalizedStrings = new Dictionary<string, string>
88
{
99
{ "CaughtActivityException.ErrorMessage", "Task 'RaiseException' (#0) failed with an unhandled exception:" },
10-
{ "RethrownActivityException.ErrorMessage", "Microsoft.DurableTask.TaskFailedException" },
11-
{ "CaughtEntityException.ErrorMessage", "Operation 'ThrowFirstTimeOnly' of entity '@counter@MyExceptionEntity' failed:" },
12-
{ "RethrownEntityException.ErrorMessage", "Microsoft.DurableTask.Entities.EntityOperationFailedException" },
10+
{ "RethrownActivityException.ErrorMessage", "com.microsoft.durabletask.TaskFailedException: Task " },
11+
{ "CaughtEntityException.ErrorMessage", "N/A (Test not implemented)" },
12+
{ "RethrownEntityException.ErrorMessage", "N/A (Test not implemented)" },
1313
{ "ExternalEvent.CompletedInstance.ErrorName", "gRPC error: StatusRuntimeException - FAIL" },
1414
{ "ExternalEvent.CompletedInstance.ErrorMessage", "The orchestration instance with the provided instance id is not running." },
1515
{ "ExternalEvent.InvalidInstance.ErrorName", "gRPC error: StatusRuntimeException - NOT_FOUND" },

test/e2e/Tests/Tests/ErrorHandlingTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ public async Task OrchestratorWithCustomRetriedActivityException_ShouldSucceed()
219219
// We want to ensure that multiline exception messages and inner exceptions are preserved
220220
Assert.Contains(this.fixture.TestLogs.CoreToolsLogs, x => x.Contains(nameof(InvalidOperationException)) &&
221221
x.Contains("This activity failed"));
222+
Assert.Contains(this.fixture.TestLogs.CoreToolsLogs, x => x.Contains("More information about the failure"));
222223
Assert.Contains(this.fixture.TestLogs.CoreToolsLogs, x => x.Contains(nameof(OverflowException)) &&
223-
x.Contains("More information about the failure"));
224+
x.Contains("Inner exception message"));
224225
}
225226
}

test/e2e/Tests/Tests/HelloCitiesTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ public async Task ScheduledStartTests(string functionName, int startDelaySeconds
6767

6868
if (scheduledStartTime > DateTime.UtcNow + TimeSpan.FromSeconds(1))
6969
{
70-
if (this.fixture.functionLanguageLocalizer.GetLanguageType() == LanguageType.DotnetIsolated)
70+
if (this.fixture.functionLanguageLocalizer.GetLanguageType() == LanguageType.DotnetIsolated ||
71+
this.fixture.functionLanguageLocalizer.GetLanguageType() == LanguageType.Java)
7172
{
7273
await DurableHelpers.WaitForOrchestrationStateAsync(statusQueryGetUri, "Pending", 30);
7374
}

test/e2e/Tests/Tests/LargeOutputOrchestratorTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ public async Task LargeOutputStatusQueryTests(int sizeInKB)
4141

4242
[Theory]
4343
[InlineData(4608)]// This value exceeds the default 4 MB, as the test sets the threshold to 6 MB.
44-
[Trait("DTS", "Skip")]
44+
[Trait("DTS", "Skip")]
45+
[Trait("Java", "Skip")] // Bug: Needs investigation, Exception: StatusRuntimeException: RESOURCE_EXHAUSTED: gRPC message exceeds maximum size 4194304: 4718735
4546
public async Task DurableTaskClientWriteOutputTests(int sizeInKB)
4647
{
4748
using HttpResponseMessage response = await HttpHelpers.InvokeHttpTriggerWithBody("LargeOutputOrchestrator_HttpStart", sizeInKB.ToString(), "application/json");

test/e2e/Tests/Tests/VersioningTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public VersioningTests(FunctionAppFixture fixture, ITestOutputHelper testOutputH
3131
// mid-test.
3232
[Trait("Python", "Skip")] // The above applies to Python as well
3333
[Trait("Node", "Skip")] // The above applies to Node as well
34-
[Trait("Node", "Skip")] // The above applies to Java as well
34+
[Trait("Java", "Skip")] // The above applies to Java as well
3535
public async Task TestVersionedOrchestration_OKWithMatchingVersion(string? version)
3636
{
3737
string queryString = version == null ? string.Empty : $"?version={version}";

0 commit comments

Comments
 (0)