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

Fixing unit tests related to mlclient getTask and adding integration test for workflow provisioning under multitenancy #1045

Merged
merged 3 commits into from
Feb 4, 2025
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 @@ -127,7 +127,7 @@ public void testDeployModel() throws ExecutionException, InterruptedException, I

// Stub getTask for success case
doAnswer(invocation -> {
ActionListener<MLTask> actionListener = invocation.getArgument(1);
ActionListener<MLTask> actionListener = invocation.getArgument(2);
MLTask output = MLTask.builder().taskId(taskId).modelId(modelId).state(MLTaskState.COMPLETED).async(false).build();
actionListener.onResponse(output);
return null;
Expand Down Expand Up @@ -203,11 +203,11 @@ public void testDeployModelTaskFailure() throws IOException, InterruptedExceptio

// Stub getTask for success case
doAnswer(invocation -> {
ActionListener<MLTask> actionListener = invocation.getArgument(1);
ActionListener<MLTask> actionListener = invocation.getArgument(2);
MLTask output = MLTask.builder().taskId(taskId).modelId(modelId).state(MLTaskState.FAILED).async(false).error("error").build();
actionListener.onResponse(output);
return null;
}).when(machineLearningNodeClient).getTask(any(), any());
}).when(machineLearningNodeClient).getTask(any(), nullable(String.class), any());

PlainActionFuture<WorkflowData> future = this.deployModel.execute(
inputData.getNodeId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public void testRegisterLocalCustomModelSuccess() throws Exception {

// Stub getTask for success case
doAnswer(invocation -> {
ActionListener<MLTask> actionListener = invocation.getArgument(1);
ActionListener<MLTask> actionListener = invocation.getArgument(2);
MLTask output = MLTask.builder().taskId(taskId).modelId(modelId).state(MLTaskState.COMPLETED).async(false).build();
actionListener.onResponse(output);
return null;
Expand Down Expand Up @@ -209,7 +209,7 @@ public void testRegisterLocalCustomModelSuccess() throws Exception {
future.actionGet();

verify(machineLearningNodeClient, times(2)).register(any(MLRegisterModelInput.class), any());
verify(machineLearningNodeClient, times(2)).getTask(any(), any());
verify(machineLearningNodeClient, times(2)).getTask(any(), nullable(String.class), any());

assertEquals(modelId, future.get().getContent().get(MODEL_ID));
assertEquals(status, future.get().getContent().get(REGISTER_MODEL_STATUS));
Expand All @@ -231,11 +231,11 @@ public void testRegisterLocalCustomModelDeployStateUpdateFail() throws Exception

// Stub getTask for success case
doAnswer(invocation -> {
ActionListener<MLTask> actionListener = invocation.getArgument(1);
ActionListener<MLTask> actionListener = invocation.getArgument(2);
MLTask output = MLTask.builder().taskId(taskId).modelId(modelId).state(MLTaskState.COMPLETED).async(false).build();
actionListener.onResponse(output);
return null;
}).when(machineLearningNodeClient).getTask(any(), any());
}).when(machineLearningNodeClient).getTask(any(), nullable(String.class), any());

AtomicInteger invocationCount = new AtomicInteger(0);
doAnswer(invocation -> {
Expand Down Expand Up @@ -322,7 +322,7 @@ public void testRegisterLocalCustomModelTaskFailure() {

// Stub get ml task for failure case
doAnswer(invocation -> {
ActionListener<MLTask> actionListener = invocation.getArgument(1);
ActionListener<MLTask> actionListener = invocation.getArgument(2);
MLTask output = MLTask.builder()
.taskId(taskId)
.modelId(modelId)
Expand All @@ -332,7 +332,7 @@ public void testRegisterLocalCustomModelTaskFailure() {
.build();
actionListener.onResponse(output);
return null;
}).when(machineLearningNodeClient).getTask(any(), any());
}).when(machineLearningNodeClient).getTask(any(), nullable(String.class), any());

PlainActionFuture<WorkflowData> future = this.registerLocalModelStep.execute(
workflowData.getNodeId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public void testRegisterLocalPretrainedModelSuccess() throws Exception {

// Stub getTask for success case
doAnswer(invocation -> {
ActionListener<MLTask> actionListener = invocation.getArgument(1);
ActionListener<MLTask> actionListener = invocation.getArgument(2);
MLTask output = MLTask.builder().taskId(taskId).modelId(modelId).state(MLTaskState.COMPLETED).async(false).build();
actionListener.onResponse(output);
return null;
Expand Down Expand Up @@ -196,7 +196,7 @@ public void testRegisterLocalPretrainedModelSuccess() throws Exception {
future.actionGet();

verify(machineLearningNodeClient, times(2)).register(any(MLRegisterModelInput.class), any());
verify(machineLearningNodeClient, times(2)).getTask(any(), any());
verify(machineLearningNodeClient, times(2)).getTask(any(), nullable(String.class), any());

assertEquals(modelId, future.get().getContent().get(MODEL_ID));
assertEquals(status, future.get().getContent().get(REGISTER_MODEL_STATUS));
Expand Down Expand Up @@ -240,7 +240,7 @@ public void testRegisterLocalPretrainedModelTaskFailure() {

// Stub get ml task for failure case
doAnswer(invocation -> {
ActionListener<MLTask> actionListener = invocation.getArgument(1);
ActionListener<MLTask> actionListener = invocation.getArgument(2);
MLTask output = MLTask.builder()
.taskId(taskId)
.modelId(modelId)
Expand All @@ -250,7 +250,7 @@ public void testRegisterLocalPretrainedModelTaskFailure() {
.build();
actionListener.onResponse(output);
return null;
}).when(machineLearningNodeClient).getTask(any(), any());
}).when(machineLearningNodeClient).getTask(any(), nullable(String.class), any());

PlainActionFuture<WorkflowData> future = this.registerLocalPretrainedModelStep.execute(
workflowData.getNodeId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public void testRegisterLocalSparseEncodingModelSuccess() throws Exception {

// Stub getTask for success case
doAnswer(invocation -> {
ActionListener<MLTask> actionListener = invocation.getArgument(1);
ActionListener<MLTask> actionListener = invocation.getArgument(2);
MLTask output = MLTask.builder().taskId(taskId).modelId(modelId).state(MLTaskState.COMPLETED).async(false).build();
actionListener.onResponse(output);
return null;
Expand Down Expand Up @@ -201,7 +201,7 @@ public void testRegisterLocalSparseEncodingModelSuccess() throws Exception {
future.actionGet();

verify(machineLearningNodeClient, times(2)).register(any(MLRegisterModelInput.class), any());
verify(machineLearningNodeClient, times(2)).getTask(any(), any());
verify(machineLearningNodeClient, times(2)).getTask(any(), nullable(String.class), any());

assertEquals(modelId, future.get().getContent().get(MODEL_ID));
assertEquals(status, future.get().getContent().get(REGISTER_MODEL_STATUS));
Expand Down Expand Up @@ -245,7 +245,7 @@ public void testRegisterLocalSparseEncodingModelTaskFailure() {

// Stub get ml task for failure case
doAnswer(invocation -> {
ActionListener<MLTask> actionListener = invocation.getArgument(1);
ActionListener<MLTask> actionListener = invocation.getArgument(2);
MLTask output = MLTask.builder()
.taskId(taskId)
.modelId(modelId)
Expand All @@ -255,7 +255,7 @@ public void testRegisterLocalSparseEncodingModelTaskFailure() {
.build();
actionListener.onResponse(output);
return null;
}).when(machineLearningNodeClient).getTask(any(), any());
}).when(machineLearningNodeClient).getTask(any(), nullable(String.class), any());

PlainActionFuture<WorkflowData> future = this.registerLocalSparseEncodingModelStep.execute(
workflowData.getNodeId(),
Expand Down
Loading