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

Updated Testcases for RemoteModel.java #1535

Closed
wants to merge 1 commit into from
Closed
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 @@ -11,6 +11,7 @@
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.opensearch.ml.common.MLModel;
Expand All @@ -19,9 +20,11 @@
import org.opensearch.ml.common.connector.ConnectorProtocols;
import org.opensearch.ml.common.connector.HttpConnector;
import org.opensearch.ml.common.input.MLInput;
import org.opensearch.ml.common.output.model.ModelTensorOutput;
import org.opensearch.ml.engine.encryptor.Encryptor;
import org.opensearch.ml.engine.encryptor.EncryptorImpl;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;

Expand All @@ -32,6 +35,12 @@

public class RemoteModelTest {

@InjectMocks
RemoteModel remoteModel;

@Mock
RemoteConnectorExecutor remoteConnectorExecutor;

@Mock
MLInput mlInput;

Expand All @@ -41,7 +50,6 @@ public class RemoteModelTest {
@Rule
public ExpectedException exceptionRule = ExpectedException.none();

RemoteModel remoteModel;
Encryptor encryptor;

@Before
Expand All @@ -65,6 +73,15 @@ public void predict_NullConnectorExecutor() {
remoteModel.predict(mlInput);
}

@Test
public void predict_ModelPredictSuccess() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

"testXYZ" and no underscore.

Connector connector = createConnector(ImmutableMap.of("Authorization", "Bearer ${credential.key}"));
when(mlModel.getConnector()).thenReturn(connector);
remoteModel.initModel(mlModel, ImmutableMap.of(), encryptor);
Assert.assertTrue(remoteModel.isModelReady());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this going to be flaky due to timing?

when(remoteConnectorExecutor.executePredict(mlInput)).thenReturn(new ModelTensorOutput(new ArrayList<>()));
Copy link
Collaborator

Choose a reason for hiding this comment

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

What are you testing??

}

@Test
public void predict_ModelDeployed_WrongInput() {
exceptionRule.expect(RuntimeException.class);
Expand Down Expand Up @@ -129,4 +146,4 @@ private Connector createConnector(Map<String, String> headers) {
return connector;
}

}
}
Loading