-
Notifications
You must be signed in to change notification settings - Fork 38
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
[Feature] New module geospatial-client
for cross-plugin IP enrichment
#700
[Feature] New module geospatial-client
for cross-plugin IP enrichment
#700
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked very high level on the code. I like the idea of having a client. But I want to get some consistencies in the code. and I am hoping client to very lightweight.
@ExtendWith(MockitoExtension.class) | ||
class IpEnrichmentActionClientTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For all the tests lets use the same test framework used in plugin rather than using standard Mockito ensure that test framework is same across different modules of the plugin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated the build.gradle to read the Mockito version from the opensearch.build
plugin, in this case we will have the same version of Mockito as the main OpenSearch repo.
testImplementation "org.mockito:mockito-core:${versions.mockito}"
Or you mean I should ditch Mockito all together?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My idea was tests in this client should extend from OpenSearchTestCase
just like the plugin and not specifically on the mockito version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems we don't extend from OpenSearchTestCase
for client module? https://github.com/opensearch-project/ml-commons/blob/main/client/src/test/java/org/opensearch/ml/client/MachineLearningNodeClientTest.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with not doing this would be that we first we will not able to test the code with random data and another problem is since we will not have seed whenever we want to reproduce a failure. Not sure why MLCommons didn't do this. This is an acceptable practice in Opensearch Plugins. Plus you will miss out on all the different mocking and testing framework added by Opensearch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my point, this depends on the amount of logic to test.
I agree we should have it to remain the consistency, but for now if we aim to have it as a thin client which has no actual logic inside except the argument validation.
This may be a overkill.
client/src/main/java/org/opensearch/geospatial/action/IpEnrichmentActionClient.java
Outdated
Show resolved
Hide resolved
client/src/main/java/org/opensearch/geospatial/action/IpEnrichmentAction.java
Show resolved
Hide resolved
@navneet1v I have fixed most of the point except the Mockito, can you have a look on the review? |
client/src/main/java/org/opensearch/geospatial/action/IpEnrichmentActionClient.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/geospatial/ip2geo/action/IpEnrichmentTransportAction.java
Outdated
Show resolved
Hide resolved
client/src/main/java/org/opensearch/geospatial/action/IpEnrichmentResponse.java
Show resolved
Hide resolved
@heemin32 I updated the code to reflect comments, can you have another look. |
I think, we can add versioning on this serialization/deserialization using OpenSearch version? |
@Xtansia Could you take a look at this? |
Just to align on this, what's the expected behaviour in the case when serializationID doesn't match? |
I have updated the code to perform version check, can you have a look and advise? |
client/src/main/java/org/opensearch/geospatial/action/IpEnrichmentResponse.java
Outdated
Show resolved
Hide resolved
Another general comment is if we should implement it as a rest API rather than client? What do you think? @andy-k-improving |
We should have it in the long term || as day-2, but I don't think that make sense to bundle it in one PR, as there will be more considerations I foresee (Ex: performance, web-layer security) need to be addressed || discussed ahead of the implementation. |
client/src/main/java/org/opensearch/geospatial/action/IpEnrichmentRequest.java
Outdated
Show resolved
Hide resolved
@heemin32 Also do you foresee any problem to publish the |
No need for that. I was considering either this or that, but not both. Thanks. |
I don’t have much expertise on that topic. @ylwu-amzn, is there anything specific we should consider when publishing the client? Asking as ml-common already has done it. |
If that is the case, then I rather keep this instead of REST. |
src/test/java/org/opensearch/geospatial/ip2geo/action/IpEnrichmentTransportActionTests.java
Outdated
Show resolved
Hide resolved
2920257
to
fee8dcc
Compare
Signed-off-by: Andy Kwok <andy.kwok@improving.com>
Signed-off-by: Andy Kwok <andy.kwok@improving.com>
Signed-off-by: Andy Kwok <andy.kwok@improving.com>
Signed-off-by: Andy Kwok <andy.kwok@improving.com>
Signed-off-by: Andy Kwok <andy.kwok@improving.com>
Signed-off-by: Andy Kwok <andy.kwok@improving.com>
Signed-off-by: Andy Kwok <andy.kwok@improving.com>
Signed-off-by: Andy Kwok <andy.kwok@improving.com>
Signed-off-by: Andy Kwok <andy.kwok@improving.com>
Signed-off-by: Andy Kwok <andy.kwok@improving.com>
Signed-off-by: Andy Kwok <andy.kwok@improving.com>
Signed-off-by: Andy Kwok <andy.kwok@improving.com>
Signed-off-by: Andy Kwok <andy.kwok@improving.com>
Signed-off-by: Andy Kwok <andy.kwok@improving.com>
Signed-off-by: Andy Kwok <andy.kwok@improving.com>
9e0145a
to
2a1b2e7
Compare
@heemin32 done. |
@andy-k-improving, thanks for the change. If you don't get response from @navneet1v by next Monday, let me pull in another person to review this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small comment. Overall code looks good to me. There is system.out statement left in the code. Added a comment for that.
client/src/test/java/org/opensearch/geospatial/action/IpEnrichmentRequestTests.java
Show resolved
Hide resolved
@ExtendWith(MockitoExtension.class) | ||
class IpEnrichmentActionClientTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with not doing this would be that we first we will not able to test the code with random data and another problem is since we will not have seed whenever we want to reproduce a failure. Not sure why MLCommons didn't do this. This is an acceptable practice in Opensearch Plugins. Plus you will miss out on all the different mocking and testing framework added by Opensearch.
…nt (#700) * Common module Signed-off-by: Andy Kwok <andy.kwok@improving.com> * POC Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Consolidate interface Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Consolidate interface Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Remove common module Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Gradle cleanup Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Lombok Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Java doc - 1 Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Java doc Signed-off-by: Andy Kwok <andy.kwok@improving.com> * API Signature Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Fetch default data source Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Logger Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Initial test cases Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Add test-cases Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Test-cases: Client Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Update tests Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Update code style Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Style fix Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Update deps Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Spotless Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Spotless Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Code refactor Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Serialisation attempt Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Remove custom serialisation support Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Address code comments Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Update test infra Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Remove unused test-cases Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Add lombok config Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Update test Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Update changelog Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Update gradle Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Update Gradle build Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Update artifact info Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Minimise diff Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Style fix Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Code comments Signed-off-by: Andy Kwok <andy.kwok@improving.com> --------- Signed-off-by: Andy Kwok <andy.kwok@improving.com> (cherry picked from commit eb8aba6)
…nt (#700) (#705) * Common module Signed-off-by: Andy Kwok <andy.kwok@improving.com> * POC Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Consolidate interface Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Consolidate interface Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Remove common module Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Gradle cleanup Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Lombok Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Java doc - 1 Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Java doc Signed-off-by: Andy Kwok <andy.kwok@improving.com> * API Signature Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Fetch default data source Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Logger Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Initial test cases Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Add test-cases Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Test-cases: Client Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Update tests Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Update code style Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Style fix Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Update deps Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Spotless Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Spotless Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Code refactor Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Serialisation attempt Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Remove custom serialisation support Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Address code comments Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Update test infra Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Remove unused test-cases Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Add lombok config Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Update test Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Update changelog Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Update gradle Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Update Gradle build Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Update artifact info Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Minimise diff Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Style fix Signed-off-by: Andy Kwok <andy.kwok@improving.com> * Code comments Signed-off-by: Andy Kwok <andy.kwok@improving.com> --------- Signed-off-by: Andy Kwok <andy.kwok@improving.com> (cherry picked from commit eb8aba6) Co-authored-by: Andy Kwok <andy.kwok@improving.com>
Description
This is an implementation ticket which follow the discussion of #698, to create a new Gradle module for other OpenSearch Plugin to import, in order to make an IP enrichment call to GeoSpatial plugin to resolve GeoLocation data with existing data source.
Hight-level code changes:
geospatial-client
with appreciate Gradle setting files to publish it as a standalone Jar.ipEnrichmentActionClient
which serve as the interface, this is the only way for other Plugin to interact with GeoSpatial's IP enrichment functionalityIpEnrichmentAction
,IpEnrichmentRequest
andIpEnrichmentResponse
IpEnrichementTransportAction
class which contain the logic for the IP address lookup and register it during the GeoSpatial's bootstrap timeNon GeoSpatial plugin can now interact with the new functionality like below:
Related Issues
Resolves #698
Check List
--signoff
.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.