Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ranjith Ramachandra committed Sep 2, 2023
1 parent 83224fa commit 5b7af05
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,23 @@
import org.opensearch.action.admin.indices.flush.FlushResponse;
import org.opensearch.action.admin.indices.forcemerge.ForceMergeResponse;
import org.opensearch.action.admin.indices.refresh.RefreshResponse;
import org.opensearch.action.admin.indices.settings.get.GetSettingsRequest;
import org.opensearch.action.bulk.BulkResponse;
import org.opensearch.action.delete.DeleteResponse;
import org.opensearch.action.get.GetResponse;
import org.opensearch.action.index.IndexResponse;
import org.opensearch.action.search.SearchResponse;
import org.opensearch.action.support.WriteRequest.RefreshPolicy;
import org.opensearch.cluster.health.ClusterHealthStatus;
import org.opensearch.cluster.metadata.IndexMetadata;
import org.opensearch.common.xcontent.XContentFactory;
import org.opensearch.core.xcontent.MediaTypeRegistry;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.test.OpenSearchIntegTestCase;
import org.opensearch.test.hamcrest.OpenSearchAssertions;

import java.io.IOException;
import java.util.Objects;

import static org.opensearch.action.DocWriteRequest.OpType;
import static org.opensearch.client.Requests.clearIndicesCacheRequest;
Expand Down Expand Up @@ -89,7 +92,15 @@ public void testIndexActions() throws Exception {
assertThat(indexResponse.getId(), equalTo("1"));
logger.info("Refreshing");
RefreshResponse refreshResponse = refresh();
assertThat(refreshResponse.getSuccessfulShards(), equalTo(numShards.totalNumShards));

GetSettingsRequest getSettingsRequest = new GetSettingsRequest().indices("test");
String remoteStoreEnabledStr = client().admin().indices().getSettings(getSettingsRequest).actionGet().getSetting("test", IndexMetadata.SETTING_REMOTE_STORE_ENABLED);
logger.warn("IndexSettings (" + remoteStoreEnabledStr + ")");
if(Objects.equals(remoteStoreEnabledStr, "true")) {
assertThat(refreshResponse.getSuccessfulShards(), equalTo(numShards.numPrimaries));
} else {
assertThat(refreshResponse.getSuccessfulShards(), equalTo(numShards.totalNumShards));
}

logger.info("--> index exists?");
assertThat(indexExists(getConcreteIndexName()), equalTo(true));
Expand All @@ -102,12 +113,20 @@ public void testIndexActions() throws Exception {
.clearCache(clearIndicesCacheRequest("test").fieldDataCache(true).queryCache(true))
.actionGet();
assertNoFailures(clearIndicesCacheResponse);
assertThat(clearIndicesCacheResponse.getSuccessfulShards(), equalTo(numShards.totalNumShards));
if(Objects.equals(remoteStoreEnabledStr, "true")) {
assertThat(clearIndicesCacheResponse.getSuccessfulShards(), equalTo(numShards.numPrimaries));
} else {
assertThat(clearIndicesCacheResponse.getSuccessfulShards(), equalTo(numShards.totalNumShards));
}

logger.info("Force Merging");
waitForRelocation(ClusterHealthStatus.GREEN);
ForceMergeResponse mergeResponse = forceMerge();
assertThat(mergeResponse.getSuccessfulShards(), equalTo(numShards.totalNumShards));
if(Objects.equals(remoteStoreEnabledStr, "true")) {
assertThat(mergeResponse.getSuccessfulShards(), equalTo(numShards.numPrimaries));
} else {
assertThat(mergeResponse.getSuccessfulShards(), equalTo(numShards.totalNumShards));
}

GetResponse getResult;

Expand Down Expand Up @@ -248,7 +267,15 @@ public void testBulk() throws Exception {
waitForRelocation(ClusterHealthStatus.GREEN);
RefreshResponse refreshResponse = client().admin().indices().prepareRefresh("test").execute().actionGet();
assertNoFailures(refreshResponse);
assertThat(refreshResponse.getSuccessfulShards(), equalTo(numShards.totalNumShards));

GetSettingsRequest getSettingsRequest = new GetSettingsRequest().indices("test");
String remoteStoreEnabledStr = client().admin().indices().getSettings(getSettingsRequest).actionGet().getSetting("test", IndexMetadata.SETTING_REMOTE_STORE_ENABLED);
logger.warn("IndexSettings (" + remoteStoreEnabledStr + ")");
if(Objects.equals(remoteStoreEnabledStr, "true")) {
assertThat(refreshResponse.getSuccessfulShards(), equalTo(numShards.numPrimaries));
} else {
assertThat(refreshResponse.getSuccessfulShards(), equalTo(numShards.totalNumShards));
}

for (int i = 0; i < 5; i++) {
GetResponse getResult = client().get(getRequest("test").id("1")).actionGet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private void cleanupMaxBuckets() {
// Make sure that unordered, reversed, disjoint and/or overlapping ranges are supported
// Duel with filters
public void testRandomRanges() throws Exception {
final int numDocs = scaledRandomIntBetween(500, 5000);
final int numDocs = scaledRandomIntBetween(5, 500);
final double[][] docs = new double[numDocs][];
for (int i = 0; i < numDocs; ++i) {
final int numValues = randomInt(5);
Expand Down Expand Up @@ -228,8 +228,8 @@ public void testRandomRanges() throws Exception {

// test long/double/string terms aggs with high number of buckets that require array growth
public void testDuelTerms() throws Exception {
final int numDocs = scaledRandomIntBetween(1000, 2000);
final int maxNumTerms = randomIntBetween(10, 5000);
final int numDocs = scaledRandomIntBetween(10, 20);
final int maxNumTerms = randomIntBetween(1, 50);

final Set<Integer> valuesSet = new HashSet<>();
cluster().wipeIndices("idx");
Expand Down Expand Up @@ -363,9 +363,9 @@ public void testDuelTermsHistogram() throws Exception {
.endObject()
).get();

final int numDocs = scaledRandomIntBetween(500, 5000);
final int maxNumTerms = randomIntBetween(10, 2000);
final int interval = randomIntBetween(1, 100);
final int numDocs = scaledRandomIntBetween(5, 50);
final int maxNumTerms = randomIntBetween(10, 200);
final int interval = randomIntBetween(1, 10);

final Integer[] values = new Integer[maxNumTerms];
for (int i = 0; i < values.length; ++i) {
Expand Down Expand Up @@ -424,7 +424,7 @@ public void testLargeNumbersOfPercentileBuckets() throws Exception {
.endObject()
).get();

final int numDocs = scaledRandomIntBetween(2500, 5000);
final int numDocs = scaledRandomIntBetween(25, 50);
logger.info("Indexing [{}] docs", numDocs);
List<IndexRequestBuilder> indexingRequests = new ArrayList<>();
for (int i = 0; i < numDocs; ++i) {
Expand Down Expand Up @@ -501,7 +501,7 @@ private void assertEquals(Terms t1, Terms t2) {

public void testDuelDepthBreadthFirst() throws Exception {
createIndex("idx");
final int numDocs = randomIntBetween(100, 500);
final int numDocs = randomIntBetween(10, 50);
List<IndexRequestBuilder> reqs = new ArrayList<>();
for (int i = 0; i < numDocs; ++i) {
final int v1 = randomInt(1 << randomInt(7));
Expand Down

0 comments on commit 5b7af05

Please sign in to comment.