mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-25 14:26:27 +00:00
[TEST] Provide overloaded indexRandom to opt out of dummy documents
This commit is contained in:
parent
0741ce3684
commit
ac28557228
@ -973,22 +973,45 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase
|
|||||||
|
|
||||||
|
|
||||||
private static final String RANDOM_BOGUS_TYPE = "RANDOM_BOGUS_TYPE______";
|
private static final String RANDOM_BOGUS_TYPE = "RANDOM_BOGUS_TYPE______";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indexes the given {@link IndexRequestBuilder} instances randomly. It shuffles the given builders and either
|
* Indexes the given {@link IndexRequestBuilder} instances randomly. It shuffles the given builders and either
|
||||||
* indexes they in a blocking or async fashion. This is very useful to catch problems that relate to internal document
|
* indexes they in a blocking or async fashion. This is very useful to catch problems that relate to internal document
|
||||||
* ids or index segment creations. Some features might have bug when a given document is the first or the last in a
|
* ids or index segment creations. Some features might have bug when a given document is the first or the last in a
|
||||||
* segment or if only one document is in a segment etc. This method prevents issues like this by randomizing the index
|
* segment or if only one document is in a segment etc. This method prevents issues like this by randomizing the index
|
||||||
* layout.
|
* layout.
|
||||||
|
*
|
||||||
|
* @param forceRefresh if <tt>true</tt> all involved indices are refreshed once the documents are indexed. Additionally if <tt>true</tt>
|
||||||
|
* some empty dummy documents are may be randomly inserted into the document list and deleted once all documents are indexed.
|
||||||
|
* This is useful to produce deleted documents on the server side.
|
||||||
|
* @param builders the documents to index.
|
||||||
|
*
|
||||||
|
* @see #indexRandom(boolean, boolean, java.util.List)
|
||||||
*/
|
*/
|
||||||
public void indexRandom(boolean forceRefresh, List<IndexRequestBuilder> builders) throws InterruptedException, ExecutionException {
|
public void indexRandom(boolean forceRefresh, List<IndexRequestBuilder> builders) throws InterruptedException, ExecutionException {
|
||||||
|
indexRandom(forceRefresh, forceRefresh, builders);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indexes the given {@link IndexRequestBuilder} instances randomly. It shuffles the given builders and either
|
||||||
|
* indexes they in a blocking or async fashion. This is very useful to catch problems that relate to internal document
|
||||||
|
* ids or index segment creations. Some features might have bug when a given document is the first or the last in a
|
||||||
|
* segment or if only one document is in a segment etc. This method prevents issues like this by randomizing the index
|
||||||
|
* layout.
|
||||||
|
*
|
||||||
|
* @param forceRefresh if <tt>true</tt> all involved indices are refreshed once the documents are indexed.
|
||||||
|
* @param dummyDocuments if <tt>true</tt> some empty dummy documents are may be randomly inserted into the document list and deleted once
|
||||||
|
* all documents are indexed. This is useful to produce deleted documents on the server side.
|
||||||
|
* @param builders the documents to index.
|
||||||
|
*/
|
||||||
|
public void indexRandom(boolean forceRefresh, boolean dummyDocuments, List<IndexRequestBuilder> builders) throws InterruptedException, ExecutionException {
|
||||||
Random random = getRandom();
|
Random random = getRandom();
|
||||||
Set<String> indicesSet = new HashSet<>();
|
Set<String> indicesSet = new HashSet<>();
|
||||||
for (IndexRequestBuilder builder : builders) {
|
for (IndexRequestBuilder builder : builders) {
|
||||||
indicesSet.add(builder.request().index());
|
indicesSet.add(builder.request().index());
|
||||||
}
|
}
|
||||||
Set<Tuple<String, String>> bogusIds = new HashSet<>();
|
Set<Tuple<String, String>> bogusIds = new HashSet<>();
|
||||||
if (random.nextBoolean() && !builders.isEmpty() && forceRefresh) {
|
if (random.nextBoolean() && !builders.isEmpty() && dummyDocuments) {
|
||||||
// we only do this if we forceRefresh=true since we need to refresh to reflect the deletes
|
|
||||||
builders = new ArrayList<>(builders);
|
builders = new ArrayList<>(builders);
|
||||||
final String[] indices = indicesSet.toArray(new String[0]);
|
final String[] indices = indicesSet.toArray(new String[0]);
|
||||||
// inject some bogus docs
|
// inject some bogus docs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user