-
Notifications
You must be signed in to change notification settings - Fork 25.6k
[TEST] Cover custom sorting and routing in randomized testing #120584
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
Merged
Merged
Changes from 12 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
dcbf452
Cover custom sorting and routing in randomized testing
kkrik-es e46010f
[CI] Auto commit changes from spotless
1752745
fix reindex tests
kkrik-es f6d0e03
Merge remote-tracking branch 'origin/logsdb/random-test-routing' into…
kkrik-es adf23a6
fix reindex tests
kkrik-es aba5714
refactor classes
kkrik-es 20f50f5
Merge branch 'main' into logsdb/random-test-routing
kkrik-es c715220
comment
kkrik-es dd3579f
Merge remote-tracking branch 'origin/logsdb/random-test-routing' into…
kkrik-es 87086e6
more refactoring
kkrik-es b5e93cd
more refactoring
kkrik-es 257db49
Merge branch 'main' into logsdb/random-test-routing
kkrik-es fb14a37
restore tests with static mappings
kkrik-es ed92f95
Merge remote-tracking branch 'origin/logsdb/random-test-routing' into…
kkrik-es 011baf5
reduce diff
kkrik-es 5ff68dc
reduce diff
kkrik-es a88a129
Merge branch 'main' into logsdb/random-test-routing
kkrik-es e8e99e1
Restore single-element array removal in synthetic source
kkrik-es e2b047f
Revert "Restore single-element array removal in synthetic source"
kkrik-es c71d36a
Merge branch 'main' into logsdb/random-test-routing
kkrik-es 2549d14
Merge branch 'main' into logsdb/random-test-routing
kkrik-es 4a7835e
[CI] Auto commit changes from spotless
d9730c1
Merge branch 'main' into logsdb/random-test-routing
kkrik-es File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
...n/logsdb/src/javaRestTest/java/org/elasticsearch/xpack/logsdb/qa/BulkChallengeRestIT.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| package org.elasticsearch.xpack.logsdb.qa; | ||
|
|
||
| import org.elasticsearch.common.CheckedSupplier; | ||
| import org.elasticsearch.common.Strings; | ||
| import org.elasticsearch.xcontent.XContentBuilder; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * Challenge test that uses bulk indexing for both baseline and contender sides. | ||
| */ | ||
| public class BulkChallengeRestIT extends StandardVersusLogsIndexModeRandomDataChallengeRestIT { | ||
|
|
||
| public BulkChallengeRestIT() {} | ||
|
|
||
| protected BulkChallengeRestIT(DataGenerationHelper dataGenerationHelper) { | ||
| super(dataGenerationHelper); | ||
| } | ||
|
|
||
| @Override | ||
| public void indexDocuments( | ||
| final CheckedSupplier<List<XContentBuilder>, IOException> baselineSupplier, | ||
| final CheckedSupplier<List<XContentBuilder>, IOException> contenderSupplier | ||
| ) throws IOException { | ||
| var contenderResponseEntity = indexContenderDocuments(contenderSupplier); | ||
| indexBaselineDocuments(baselineSupplier, contenderResponseEntity); | ||
| } | ||
|
|
||
| private Map<String, Object> indexContenderDocuments(final CheckedSupplier<List<XContentBuilder>, IOException> documentsSupplier) | ||
| throws IOException { | ||
| final StringBuilder sb = new StringBuilder(); | ||
| int id = 0; | ||
| for (var document : documentsSupplier.get()) { | ||
| if (autoGenerateId()) { | ||
| sb.append("{ \"create\": { } }\n"); | ||
| } else { | ||
| sb.append(Strings.format("{ \"create\": { \"_id\" : \"%d\" } }\n", id)); | ||
| } | ||
| sb.append(Strings.toString(document)).append("\n"); | ||
| id++; | ||
| } | ||
| return performBulkRequest(sb.toString(), false); | ||
| } | ||
|
|
||
| @SuppressWarnings("unchecked") | ||
| private void indexBaselineDocuments( | ||
| final CheckedSupplier<List<XContentBuilder>, IOException> documentsSupplier, | ||
| final Map<String, Object> contenderResponseEntity | ||
| ) throws IOException { | ||
| final StringBuilder sb = new StringBuilder(); | ||
| int id = 0; | ||
| final List<Map<String, Object>> items = (List<Map<String, Object>>) contenderResponseEntity.get("items"); | ||
| for (var document : documentsSupplier.get()) { | ||
| if (autoGenerateId()) { | ||
| var contenderId = ((Map<String, Object>) items.get(id).get("create")).get("_id"); | ||
| sb.append(Strings.format("{ \"create\": { \"_id\" : \"%s\" } }\n", contenderId)); | ||
| } else { | ||
| sb.append(Strings.format("{ \"create\": { \"_id\" : \"%d\" } }\n", id)); | ||
| } | ||
| sb.append(Strings.toString(document)).append("\n"); | ||
| id++; | ||
| } | ||
| performBulkRequest(sb.toString(), true); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
Doesn't this effectively remove all tests that were in this class (inherited from
StandardVersusLogsIndexModeChallengeRestIT)? Those are the actual logsdb vs standard random data tests.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.
These now run in
BulkChallengeRestITthat inherits fromStandardVersusLogsIndexModeRandomDataChallengeRestIT.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.
ah thanks