Skip to content

Commit

Permalink
Fix testMaxDocsLimit (#92600)
Browse files Browse the repository at this point in the history
The issue was that the DOCUMENT_PAGE_SIZE setting could randomly
get a very low value, which resulted in multiple pages for the
cluster state update, which was prohibited by a randomly low max
docs value.
  • Loading branch information
kingherc authored Dec 30, 2022
1 parent b27e6eb commit c40615c
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.CollectionUtils;
import org.elasticsearch.gateway.PersistedClusterStateService;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.query.MatchAllQueryBuilder;
import org.elasticsearch.index.translog.Translog;
@@ -61,6 +62,18 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
return CollectionUtils.appendToCopy(super.nodePlugins(), TestEnginePlugin.class);
}

@Override
protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
// Document page size should not be too small, else we can fail to write the cluster state for small max doc values
return Settings.builder()
.put(super.nodeSettings(nodeOrdinal, otherSettings))
.put(
PersistedClusterStateService.DOCUMENT_PAGE_SIZE.getKey(),
PersistedClusterStateService.DOCUMENT_PAGE_SIZE.get(Settings.EMPTY)
)
.build();
}

@Before
public void setMaxDocs() {
maxDocs.set(randomIntBetween(10, 100)); // Do not set this too low as we can fail to write the cluster state
@@ -72,7 +85,6 @@ public void restoreMaxDocs() {
restoreIndexWriterMaxDocs();
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/92037")
public void testMaxDocsLimit() throws Exception {
internalCluster().ensureAtLeastNumDataNodes(1);
assertAcked(

0 comments on commit c40615c

Please sign in to comment.