Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Commit

Permalink
revert changes for workerId required in /tasks/ack API (#980)
Browse files Browse the repository at this point in the history
* revert changes for workerId required in /tasks/ack API

* Made validation error logging more verbose
  • Loading branch information
falu2010-netflix authored Feb 6, 2019
1 parent 5171593 commit 7eecae3
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ public String toString() {
builder.append(", instance: ").append(instance);
}

if (this.validationErrors != null) {
builder.append(", validationErrors: ").append(validationErrors.toString());
}

builder.append("}");
return builder.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;
import com.netflix.conductor.common.validation.ValidationError;
import java.util.StringJoiner;


//TODO: Use one from common
Expand Down Expand Up @@ -53,4 +54,15 @@ public String getInstance() {
public void setInstance(String instance) {
this.instance = instance;
}

@Override
public String toString() {
return new StringJoiner(", ", ErrorResponse.class.getSimpleName() + "[", "]")
.add("code='" + code + "'")
.add("message='" + message + "'")
.add("instance='" + instance + "'")
.add("retryable=" + retryable)
.add("validationErrors=" + validationErrors)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ private void handleUniformInterfaceException(UniformInterfaceException exception
return;
}
String errorMessage = clientResponse.getEntity(String.class);
logger.error("Unable to invoke Conductor API with uri: {}, unexpected response from server: {}", uri, clientResponseToString(exception.getResponse()), exception);
logger.error("Unable to invoke Conductor API with uri: {}, unexpected response from server: statusCode={}, responseBody='{}'.", uri, clientResponse.getStatus(), errorMessage);
ErrorResponse errorResponse;
try {
errorResponse = objectMapper.readValue(errorMessage, ErrorResponse.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.netflix.conductor.common.validation;

import com.netflix.conductor.common.validation.ErrorResponse;
import java.util.StringJoiner;

/**
* Captures a validation error that can be returned in {@link ErrorResponse}.
Expand Down Expand Up @@ -42,5 +43,14 @@ public void setMessage(String message) {
public void setInvalidValue(String invalidValue) {
this.invalidValue = invalidValue;
}

@Override
public String toString() {
return new StringJoiner(", ", ValidationError.class.getSimpleName() + "[", "]")
.add("path='" + path + "'")
.add("message='" + message + "'")
.add("invalidValue='" + invalidValue + "'")
.toString();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ public interface AdminService {
* @return list of pending {@link Task}
*/
List<Task> getListOfPendingTask(@NotEmpty(message = "TaskType cannot be null or empty.") String taskType,
@NotNull Integer start, @NotNull Integer count);
Integer start, Integer count);
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ Task getPendingTaskForWorkflow(@NotEmpty(message = "WorkflowId cannot be null or
* @param workerId Id of the worker
* @return `true|false` if task if received or not
*/
String ackTaskReceived(@NotEmpty(message = "TaskId cannot be null or empty.") String taskId,
@NotEmpty(message = "WorkerID cannot be null or empty.") String workerId);
String ackTaskReceived(@NotEmpty(message = "TaskId cannot be null or empty.") String taskId, String workerId);

/**
* Ack Task is received.
Expand Down Expand Up @@ -144,7 +143,7 @@ void removeTaskFromQueue(@NotEmpty(message = "TaskType cannot be null or empty."
* @param taskTypes List of task types.
* @return map of task type as Key and queue size as value.
*/
Map<String, Integer> getTaskQueueSizes(@NotEmpty(message = "List of taskType cannot be null or empty") List<@NotEmpty String> taskTypes);
Map<String, Integer> getTaskQueueSizes(List<String> taskTypes);

/**
* Get the details about each queue.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import static com.netflix.conductor.utility.TestUtils.getConstraintViolationMessages;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

public class TaskServiceTest {
Expand Down Expand Up @@ -126,18 +127,23 @@ public void testUpdateTaskInValid() {
}
}


@Test(expected = ConstraintViolationException.class)
public void testAckTaskReceived() {
try{
taskService.ackTaskReceived(null, null);
} catch (ConstraintViolationException ex){
assertEquals(2, ex.getConstraintViolations().size());
assertEquals(1, ex.getConstraintViolations().size());
Set<String> messages = getConstraintViolationMessages(ex.getConstraintViolations());
assertTrue(messages.contains("TaskId cannot be null or empty."));
assertTrue(messages.contains("WorkerID cannot be null or empty."));
throw ex;
}
}
@Test
public void testAckTaskReceivedMissingWorkerId() {
String ack = taskService.ackTaskReceived("abc", null);
assertNotNull(ack);
}

@Test(expected = ConstraintViolationException.class)
public void testLog(){
Expand Down Expand Up @@ -188,19 +194,6 @@ public void testRemoveTaskFromQueue(){
}
}

@Test(expected = ConstraintViolationException.class)
public void testGetTaskQueueSizes(){
try{
List<String> list = new ArrayList<>();
taskService.getTaskQueueSizes(list);
} catch (ConstraintViolationException ex){
assertEquals(1, ex.getConstraintViolations().size());
Set<String> messages = getConstraintViolationMessages(ex.getConstraintViolations());
assertTrue(messages.contains("List of taskType cannot be null or empty"));
throw ex;
}
}

@Test(expected = ConstraintViolationException.class)
public void testGetPollData(){
try{
Expand Down

0 comments on commit 7eecae3

Please sign in to comment.