Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class CreateInstancesResponse {
UUID requestId;
}

@PostExchange(value = "/v1/si?Action=RequestInstances",
@PostExchange(value = "/v1/si?Action=RequestInstancesForTask",
accept = "application/json",
contentType = "application/x-www-form-urlencoded")
CreateInstancesResponse createInstance(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ void shouldScheduleInstanceForContainerBasedTask() {
// Assert
assertThat(requestId).isNotNull();
List<ServeEvent> allServeEvents = MockIcmsServer.getMockIcmsServer().getAllServeEvents();
String formUrlEncodedBody = allServeEvents.getFirst().getRequest().getBodyAsString();
validateTaskInstancePayload(formUrlEncodedBody, task1);
validateTaskInstanceRequest(allServeEvents.getFirst(), task1);

taskService.deleteTask(task1);
}
Expand All @@ -183,8 +182,7 @@ void shouldScheduleInstanceForHelmBasedTask() {
// Assert
assertThat(requestId).isNotNull();
List<ServeEvent> allServeEvents = MockIcmsServer.getMockIcmsServer().getAllServeEvents();
String formUrlEncodedBody = allServeEvents.getFirst().getRequest().getBodyAsString();
validateTaskInstancePayload(formUrlEncodedBody, task1);
validateTaskInstanceRequest(allServeEvents.getFirst(), task1);

taskService.deleteTask(task1);
}
Expand All @@ -209,7 +207,11 @@ void shouldTolerateTerminateWhenIcmsWorkloadNotFound() {
}

@SneakyThrows
private void validateTaskInstancePayload(String formUrlEncodedBody, TaskEntity task) {
private void validateTaskInstanceRequest(ServeEvent serveEvent, TaskEntity task) {
assertThat(serveEvent.getRequest().queryParameter("Action").firstValue())
.isEqualTo("RequestInstancesForTask");

String formUrlEncodedBody = serveEvent.getRequest().getBodyAsString();
Map<String, Object> paramMap = Arrays.stream(formUrlEncodedBody.split("&"))
.map(s -> s.split("=", 2))
.collect(Collectors.toMap(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public static void start(
mockIcmsServer = new WireMockServer(config);
mockIcmsServer.stubFor(post(urlPathEqualTo("/v1/si"))
.withQueryParam("Action",
new EqualToPattern("RequestInstances"))
new EqualToPattern("RequestInstancesForTask"))
.willReturn(aResponse().withStatus(200)
.withTransformers(instanceRequestExtension.getName())
.withHeader(CONTENT_TYPE, APPLICATION_JSON_VALUE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,16 @@ func TestMessageAction_Normalize(t *testing.T) {
input: MessageAction("RequestSparInstancesForTask"),
expected: TaskCreationAction,
},
{
name: "legacy SPOT function action normalizes",
input: MessageAction("RequestSpotInstances"),
expected: FunctionCreationAction,
},
{
name: "legacy SPOT task action normalizes",
input: MessageAction("RequestSpotInstancesForTask"),
expected: TaskCreationAction,
},
{
name: "legacy RequestInstances action normalizes",
input: MessageAction("RequestInstances"),
Expand Down Expand Up @@ -236,6 +246,16 @@ func TestMessageAction_UnmarshalJSON(t *testing.T) {
json: `"RequestSparInstancesForTask"`,
expected: RequestICMSInstancesForTask,
},
{
name: "legacy RequestSpotInstances normalizes to RequestICMSInstances",
json: `"RequestSpotInstances"`,
expected: RequestICMSInstances,
},
{
name: "legacy RequestSpotInstancesForTask normalizes to RequestICMSInstancesForTask",
json: `"RequestSpotInstancesForTask"`,
expected: RequestICMSInstancesForTask,
},
{
name: "legacy RequestInstances normalizes to RequestICMSInstances",
json: `"RequestInstances"`,
Expand Down
Loading