Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix k8s task runner failure reporting #15311

Merged
merged 4 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -37,6 +37,7 @@ public class UpdateStatusAction implements TaskAction<Void>
@JsonIgnore
private final TaskStatus statusFull;
georgew5656 marked this conversation as resolved.
Show resolved Hide resolved

@Deprecated
public UpdateStatusAction(
georgew5656 marked this conversation as resolved.
Show resolved Hide resolved
String status
)
Expand Down Expand Up @@ -98,7 +99,7 @@ public String toString()
{
return "UpdateStatusAction{" +
"status=" + status +
"statusFull=" + statusFull +
", statusFull=" + statusFull +
'}';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.druid.indexing.common.task.NoopTask;
import org.apache.druid.indexing.common.task.Task;
import org.apache.druid.indexing.overlord.TaskRunner;
import org.junit.Assert;
import org.junit.Test;

import static org.mockito.ArgumentMatchers.any;
Expand All @@ -38,10 +39,12 @@
public class UpdateStatusActionTest
{

private static final String ID = "id";

@Test
public void testActionCallsTaskRunner()
{
UpdateStatusAction action = new UpdateStatusAction("successful");

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note test

Invoking
UpdateStatusAction.UpdateStatusAction
should be avoided because it has been deprecated.
Task task = NoopTask.create();
TaskActionToolbox toolbox = mock(TaskActionToolbox.class);
TaskRunner runner = mock(TaskRunner.class);
Expand All @@ -53,7 +56,7 @@
@Test
public void testFailureScenario()
{
UpdateStatusAction action = new UpdateStatusAction("failure");

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note test

Invoking
UpdateStatusAction.UpdateStatusAction
should be avoided because it has been deprecated.
Task task = NoopTask.create();
TaskActionToolbox toolbox = mock(TaskActionToolbox.class);
TaskRunner runner = mock(TaskRunner.class);
Expand All @@ -78,12 +81,20 @@
@Test
public void testNoTaskRunner()
{
UpdateStatusAction action = new UpdateStatusAction("successful");
UpdateStatusAction action = new UpdateStatusAction("", TaskStatus.success(ID));
Task task = NoopTask.create();
TaskActionToolbox toolbox = mock(TaskActionToolbox.class);
TaskRunner runner = mock(TaskRunner.class);
when(toolbox.getTaskRunner()).thenReturn(Optional.absent());
action.perform(task, toolbox);
verify(runner, never()).updateStatus(any(), any());
}

@Test
public void testEquals()
{
UpdateStatusAction one = new UpdateStatusAction("", TaskStatus.failure(ID, "error"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EqualsVerifier.forClass(UpdateStatusAction.class).verify() will verify all combinations of the underlying fields in the class and point out subtle issues in the equals / hash code logic - see other tests like testEquals or testEqualsAndHashCode for examples.

UpdateStatusAction two = new UpdateStatusAction("", TaskStatus.failure(ID, "error"));
Assert.assertEquals(one, two);
}
}