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

[Backport 2.4] Fix boundary condition in indexing pressure test #5182

Merged
merged 1 commit into from
Nov 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

package org.opensearch.index;

import org.hamcrest.Matcher;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.opensearch.action.admin.indices.stats.CommonStatsFlags;
import org.opensearch.cluster.service.ClusterService;
Expand All @@ -23,6 +25,10 @@

import java.util.concurrent.atomic.AtomicInteger;

import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.lessThanOrEqualTo;

public class ShardIndexingPressureConcurrentExecutionTests extends OpenSearchTestCase {

private final Settings settings = Settings.builder()
Expand All @@ -34,8 +40,8 @@ public class ShardIndexingPressureConcurrentExecutionTests extends OpenSearchTes
.put(ShardIndexingPressureSettings.REQUEST_SIZE_WINDOW.getKey(), 100)
.build();

final ClusterSettings clusterSettings = new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
final ClusterService clusterService = new ClusterService(settings, clusterSettings, null);
private final ClusterSettings clusterSettings = new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
private final ClusterService clusterService = new ClusterService(settings, clusterSettings, null);

public enum OperationType {
COORDINATING,
Expand Down Expand Up @@ -71,15 +77,11 @@ public void testCoordinatingPrimaryThreadedUpdateToShardLimits() throws Exceptio
NUM_THREADS * 15,
shardIndexingPressure.shardStats().getIndexingPressureShardStats(shardId1).getCurrentCombinedCoordinatingAndPrimaryBytes()
);
assertTrue(
MatcherAssert.assertThat(
(double) (NUM_THREADS * 15) / shardIndexingPressure.shardStats()
.getIndexingPressureShardStats(shardId1)
.getCurrentPrimaryAndCoordinatingLimits() < 0.95
);
assertTrue(
(double) (NUM_THREADS * 15) / shardIndexingPressure.shardStats()
.getIndexingPressureShardStats(shardId1)
.getCurrentPrimaryAndCoordinatingLimits() > 0.75
.getCurrentPrimaryAndCoordinatingLimits(),
isInOperatingFactorRange()
);

for (int i = 0; i < NUM_THREADS; i++) {
Expand Down Expand Up @@ -112,15 +114,11 @@ public void testReplicaThreadedUpdateToShardLimits() throws Exception {
Releasable[] releasable = fireConcurrentRequests(NUM_THREADS, shardIndexingPressure, shardId1, 15, OperationType.REPLICA);

assertEquals(NUM_THREADS * 15, shardIndexingPressure.shardStats().getIndexingPressureShardStats(shardId1).getCurrentReplicaBytes());
assertTrue(
(double) (NUM_THREADS * 15) / shardIndexingPressure.shardStats()
.getIndexingPressureShardStats(shardId1)
.getCurrentReplicaLimits() < 0.95
);
assertTrue(
MatcherAssert.assertThat(
(double) (NUM_THREADS * 15) / shardIndexingPressure.shardStats()
.getIndexingPressureShardStats(shardId1)
.getCurrentReplicaLimits() > 0.75
.getCurrentReplicaLimits(),
isInOperatingFactorRange()
);

for (int i = 0; i < NUM_THREADS; i++) {
Expand Down Expand Up @@ -1087,4 +1085,11 @@ private void fireConcurrentAndParallelRequestsForUniformThroughPut(
t.join();
}
}

private Matcher<Double> isInOperatingFactorRange() {
return allOf(
greaterThan(ShardIndexingPressureMemoryManager.LOWER_OPERATING_FACTOR.get(settings)),
lessThanOrEqualTo(ShardIndexingPressureMemoryManager.UPPER_OPERATING_FACTOR.get(settings))
);
}
}