Skip to content

Commit

Permalink
Rebased with latest main
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyas-gopalakrishna committed Oct 25, 2023
1 parent d76307c commit 55502ab
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,38 +146,6 @@ private String getInstanceStatusURL(HttpRequestMessage<?> request, String instan
throw new IllegalArgumentException("Failed to encode the instance ID: " + instanceId, ex);
}

String instanceStatusURL = baseUrl + "/runtime/webhooks/durabletask/instances/" + encodedInstanceId;

// Construct the response as an HTTP 202 with a JSON object payload
return request.createResponseBuilder(HttpStatus.ACCEPTED)
.header("Location", instanceStatusURL + "?" + this.requiredQueryStringParameters)
.header("Content-Type", "application/json")
.body(new HttpCreateCheckStatusResponse(
instanceId,
instanceStatusURL,
this.requiredQueryStringParameters))
.build();
}

private static class HttpCreateCheckStatusResponse {
// These fields are serialized to JSON
public final String id;
public final String purgeHistoryDeleteUri;
public final String sendEventPostUri;
public final String statusQueryGetUri;
public final String terminatePostUri;
public final String rewindPostUri;

public HttpCreateCheckStatusResponse(
String instanceId,
String instanceStatusURL,
String requiredQueryStringParameters) {
this.id = instanceId;
this.purgeHistoryDeleteUri = instanceStatusURL + "?" + requiredQueryStringParameters;
this.sendEventPostUri = instanceStatusURL + "/raiseEvent/{eventName}?" + requiredQueryStringParameters;
this.statusQueryGetUri = instanceStatusURL + "?" + requiredQueryStringParameters;
this.terminatePostUri = instanceStatusURL + "/terminate?reason={text}&" + requiredQueryStringParameters;
this.rewindPostUri = instanceStatusURL + "/rewind?reason={text}&" + requiredQueryStringParameters;
}
return baseUrl + "/runtime/webhooks/durabletask/instances/" + encodedInstanceId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class HttpManagementPayload {
private final String terminatePostUri;
private final String resumePostUri;
private final String suspendPostUri;
public final String rewindPostUri;

/**
* Creates a {@link HttpManagementPayload} to manage orchestration instances
Expand All @@ -38,6 +39,7 @@ public HttpManagementPayload(
this.terminatePostUri = instanceStatusURL + "/terminate?reason={text}&" + requiredQueryStringParameters;
this.resumePostUri = instanceStatusURL + "/resume?reason={text}&" + requiredQueryStringParameters;
this.suspendPostUri = instanceStatusURL + "/suspend?reason={text}&" + requiredQueryStringParameters;
this.rewindPostUri = instanceStatusURL + "/rewind?reason={text}&" + requiredQueryStringParameters;
}

/**
Expand Down
12 changes: 0 additions & 12 deletions samples-azure-functions/extensions.csproj

This file was deleted.

4 changes: 4 additions & 0 deletions samples-azure-functions/host.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@
"durableTask": {
"hubName": "DFJavaSmokeTest"
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[4.*, 5.0.0)"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,4 @@ public static HttpResponseMessage resetApproval(
approvalFlag = 0;
return request.createResponseBuilder(HttpStatus.OK).body(approvalFlag).build();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

@Tag("e2e")
public class EndToEndTests {

private static final String hostHealthPingUrl = "/admin/host/ping";
private static final String startOrchestrationUrl = "/api/StartOrchestration";
private static final String startApprovalWorkflowUrl = "/api/ApprovalWorkflowOrchestration";
Expand All @@ -30,8 +31,7 @@ public class EndToEndTests {
@Order(1)
@Test
public void setupHost() {
String hostHealthPingPath = "/admin/host/ping";
post(hostHealthPingPath).then().statusCode(200);
post(hostHealthPingUrl).then().statusCode(200);
}

@ParameterizedTest
Expand Down Expand Up @@ -81,15 +81,6 @@ public void retryTestSuccess() throws InterruptedException {
String statusQueryGetUri = jsonPath.get("statusQueryGetUri");
boolean pass = pollingCheck(statusQueryGetUri, "Completed", null, Duration.ofSeconds(10));
assertTrue(pass);
String runtimeStatus = null;
for (int i = 0; i < 15; i++) {
Response statusResponse = get(statusQueryGetUri);
runtimeStatus = statusResponse.jsonPath().get("runtimeStatus");
if (!"Completed".equals(runtimeStatus)) {
Thread.sleep(1000);
} else break;
}
assertEquals("Completed", runtimeStatus);
}

@Test
Expand Down Expand Up @@ -286,5 +277,4 @@ public void testRewindInstanceHttpAPI() throws InterruptedException {
// Reset approval for other test cases
post(resetApprovalUrl);
}
}

}

0 comments on commit 55502ab

Please sign in to comment.