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

Cross cluster search integration tests #2178

Merged

Conversation

lukasz-soszynski-eliatra
Copy link
Contributor

Description

[Describe what this change achieves]

  • Category (Integration tests)
  • Why these changes are required?
  • What is the old behaviour before changes and new behaviour after changes?

Integration tests related to the cross-cluster search feature created

Issues Resolved

[List any issues this PR will resolve]

Is this a backport? If so, please add backport PR # and/or commits #

Testing

[Please provide details of testing done: unit testing, integration testing and manual testing]

Check List

  • New functionality includes testing
  • New functionality has been documented
  • Commits are signed per the DCO using --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.

@lukasz-soszynski-eliatra lukasz-soszynski-eliatra requested a review from a team October 19, 2022 14:50

static final String GENRE_ROCK = "rock";
static final String GENRE_JAZZ = "jazz";
static final String GENRE_BLUES = "blues";

static final String QUERY_TITLE_NEXT_SONG = FIELD_TITLE + ":" + "\"" + TITLE_NEXT_SONG + "\"";
static final String QUERY_TITLE_POISON = FIELD_TITLE + ":" + TITLE_POISON;
static final String QUERY_TITLE_MAGNUM_OPUS = FIELD_TITLE + ":" + TITLE_MAGNUM_OPUS;

static final Object[][] SONGS = {
Copy link
Member

Choose a reason for hiding this comment

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

This is complex and a small error could blow up many tests for an unknown reason, what do you think about introducing a type representing a song scheme to ensure consistent construction?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right. This data structure is getting more and more complex. I will create a DTO class which contains fields like artist, title, etc. and will serialize the class to JSON with a Jackson library.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Finally, I manage to do this without Jackson.

@@ -26,14 +26,21 @@ public final class SearchRequestFactory {
private SearchRequestFactory() {

}
public static SearchRequest queryStringQueryRequest(String indexName, String queryString) {
public static SearchRequest queryStringQueryRequest(String indexName, String queryString, Boolean ccsMinimizeRoundtrips) {
Copy link
Member

Choose a reason for hiding this comment

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

The SearchRequest is mutable, these additional overloads seem like they are going to be more maintenance work as additional scenarios are added over the long run. What would you think about creating a 'builder' function like minimizeRoundTrips(...) that can be used inline to add these parameter?

public static SearchRequest minimizeRoundTrips(SearchRequest sr) {
   sr.setCcsMinimizeRoundtrips(true);
   return sr;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

peternied
peternied previously approved these changes Oct 24, 2022
Signed-off-by: Lukasz Soszynski <lukasz.soszynski@eliatra.com>
Copy link
Member

@DarshitChanpura DarshitChanpura left a comment

Choose a reason for hiding this comment

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

Great work @lukasz-soszynski-eliatra ! I have request a small change.

@@ -49,7 +49,7 @@
mismatchDescription.appendText("Source document is null, is fetch source option set to true?");
return false;
}
if(!source.containsKey(fieldName)) {
if(source.containsKey(fieldName) == false) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: This change should not be needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please correct me if I am wrong, but I thought that some documents define the convention to use expressions like source.containsKey(fieldName) == false instead of !source.containsKey(fieldName)

Copy link
Member

Choose a reason for hiding this comment

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

interesting...I'm not aware about such documents.. If you have one handy could you please link it here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is an implicit rule that negative boolean expressions should use the form foo == false instead of !foo for better readability of the code. While this isn't strictly enforced, if might get called out in PR reviews as something to change.

Please see https://github.com/opensearch-project/OpenSearch/blob/main/DEVELOPER_GUIDE.md .

But this file is placed in the main OpenSearch repository and not in the security plugin repository. Therefore I am not sure if the rule is applicable.

@DarshitChanpura
Copy link
Member

Bwc tests are broken on main. Tracking issue here: #2221

@peternied peternied merged commit 40e2e9c into opensearch-project:main Nov 9, 2022
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.

None yet

3 participants