-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Increase the length of randomly generated field #34857
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
Increase the length of randomly generated field #34857
Conversation
randomAlphaOfLength(2) produced duplicates which led to com.fasterxml.jackson.core.JsonParseException: Duplicate field increase it to randomAlphaOfLength(7) closes elastic#34837
| } | ||
|
|
||
| TermVectorsResponse.TermVector tv = new TermVectorsResponse.TermVector("field" + randomAlphaOfLength(2), fs, terms); | ||
| TermVectorsResponse.TermVector tv = new TermVectorsResponse.TermVector("field" + randomAlphaOfLength(7), fs, terms); |
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 think it'd be nice to check for duplicated before adding to the list and retry. Or to pass in a unique prefix to this method to be sure we don't have duplicates.
| } | ||
|
|
||
| // generate a new string different from the supplied usedStrings | ||
| private String produceUniqueString(List<String> usedStrings) { |
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.
nit: I think it woiuld make sense to use a Set here so you can simply user contains rather than having to iterate through the list. Not a big deal in this test case though since lists are very short, more as a general suggestion.
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.
@cbuescher Thanks for the suggestion, I will remember about this next time.
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.
On a related note, there is a helper in ESTestCase that might be usable here: randomValueOtherThanMany(). I think in this method could be used here instead of produceUniqueString, somehow like String fieldName = randomValueOtherThanMany(t -> usedStrings.contains(t), () -> randomAlphaOfLength(7)) (I might have the predicate the wrong way around). Just as a suggestion as well.
|
Please remember to add all relevant labels (area label, version label(s) and change type label) on all PRs and please look for this as part of reviews. The release note generation process is made much harder when PRs are not labelled correctly. |
|
Pinging @elastic/es-search-aggs |
|
@cbuescher Thanks for the suggestion, |
cbuescher
left a comment
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.
Thanks, LGTM
* Increase the length of randomly generated field randomAlphaOfLength(2) produced duplicates which led to com.fasterxml.jackson.core.JsonParseException: Duplicate field increase it to randomAlphaOfLength(7) closes #34837
randomAlphaOfLength(2) produced duplicates which led to
com.fasterxml.jackson.core.JsonParseException: Duplicate field
increase it to randomAlphaOfLength(7)
closes #34837