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

GitHub-issue#253 : Implemented GeoIP processor integration test #2927

Conversation

venkataraopasyavula
Copy link
Contributor

Description

Integration Test

Issues Resolved

GitHub-issue #253

Check List

  • New functionality includes testing.
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed with a real name per the DCO

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.

Signed-off-by: venkataraopasyavula <venkataraopasyavula@gmail.com>
String cityUrl = "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=" + maxmindLicenseKey + URL_SUFFIX;
String countryUrl = "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&license_key=" + maxmindLicenseKey + URL_SUFFIX;

String pipelineConfig = " aws:\n" +
Copy link
Collaborator

Choose a reason for hiding this comment

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

Usually, you can do this by Mocking the config. There are many IT.java files where you can see how to do this. Take a look at ./data-prepper-plugins/aggregate-processor/src/test/java/org/opensearch/dataprepper/plugins/processor/aggregate/AggregateProcessorIT.java

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As per David suggestion, we have added yaml input (configuration) in other plugins like S3Source.
For example in S3Source: S3SelectCSVOptionTest.java, S3ScanScanOptionsTest.java.
In case integration testing, the mocking should be avoided as much as possible.

geoData = geoIPProcessorService.getGeoData(inetAddress, null);

assertThat(geoData.get("country_iso_code"), equalTo("US"));
assertThat(geoData.get("ip"), equalTo("/8.8.8.8"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is it "/8.8.8.8" and not "8.8.8.8"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the code to get the valid IP in PR#2925 also updated assertion statement with "8.8.8.8" instead of "/8.8.8.8".

venkataraopasyavula and others added 3 commits July 10, 2023 11:57
Signed-off-by: venkataraopasyavula <venkataraopasyavula@gmail.com>
Signed-off-by: venkataraopasyavula <venkataraopasyavula@gmail.com>
Copy link
Collaborator

@oeyh oeyh left a comment

Choose a reason for hiding this comment

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

@venkataraopasyavula There's a build failure. Can you take a look?

        if (IPValidationcheck.isPublicIpAddress(ipAddress)) {
                             ^
  symbol:   method isPublicIpAddress(String)
  location: class IPValidationcheck
/home/runner/work/data-prepper/data-prepper/data-prepper-plugins/geoip-processor/src/integrationTest/java/org/opensearch/dataprepper/plugins/processor/GeoIPProcessorUrlServiceIT.java:95: error: method getGeoData in class GeoIPProcessorService cannot be applied to given types;
            geoData = geoIPProcessorService.getGeoData(inetAddress, null);
                                           ^
  required: InetAddress,List<String>,ZonedDateTime
  found: InetAddress,<null>
  reason: actual and formal argument lists differ in length
2 errors

FAILURE: Build failed with an exception.

@kkondaka kkondaka merged commit 0b804fd into opensearch-project:main Jul 14, 2023
chenqi0805 pushed a commit that referenced this pull request Jul 19, 2023
* GitHub-issue#253 : Implemented GeoIP processor integration test
Signed-off-by: venkataraopasyavula <venkataraopasyavula@gmail.com>

* GitHub-issue#253 : Implemented GeoIP processor integration test
Signed-off-by: venkataraopasyavula <venkataraopasyavula@gmail.com>

* GitHub-issue#253 : Implemented GeoIP processor integration test
Signed-off-by: venkataraopasyavula <venkataraopasyavula@gmail.com>

* GitHub-issue#253 : Implemented GeoIP processor integration test
Signed-off-by: venkataraopasyavula <venkataraopasyavula@gmail.com>

* GitHub-issue#253 : Implemented GeoIP processor integration test
Signed-off-by: venkataraopasyavula <venkataraopasyavula@gmail.com>
Signed-off-by: George Chen <qchea@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants