Skip to content

Commit

Permalink
addressing review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Poojita Raj <poojiraj@amazon.com>
  • Loading branch information
Poojita-Raj authored and dreamer-89 committed Apr 18, 2023
1 parent 790d82b commit d4b7354
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked;
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertHitCount;
Expand Down Expand Up @@ -97,7 +98,7 @@ public void onFailure(Exception e) {
assertBusy(() -> {
assertHitCount(client().prepareSearch("test").setQuery(QueryBuilders.matchQuery(fieldName, "test-user")).get(), numDocs);
assertHitCount(client().prepareSearch("test").setQuery(QueryBuilders.matchQuery(fieldName, "test user")).get(), 0);
});
}, 60, TimeUnit.SECONDS);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
/**
* Multi node integration tests for PIT creation and search operation with PIT ID.
*/
@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, minNumDataNodes = 2)
@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 2)
public class PitMultiNodeIT extends OpenSearchIntegTestCase {

@Before
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,46 +198,44 @@ public void testSimpleSorts() throws Exception {
}
refresh();

int size = 1 + random.nextInt(10);
final SearchResponse[] searchResponse = new SearchResponse[1];
// STRING script
int size = 1 + random.nextInt(10);

Script script = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "doc['str_value'].value", Collections.emptyMap());

int finalSize = size;
assertBusy(() -> {
searchResponse[0] = client().prepareSearch()
SearchResponse searchResponse = client().prepareSearch()
.setQuery(matchAllQuery())
.setSize(finalSize)
.addSort(new ScriptSortBuilder(script, ScriptSortType.STRING))
.get();
assertHitCount(searchResponse[0], 10);
});

assertThat(searchResponse[0].getHits().getHits().length, equalTo(size));
for (int i = 0; i < size; i++) {
SearchHit searchHit = searchResponse[0].getHits().getAt(i);
assertThat(searchHit.getId(), equalTo(Integer.toString(i)));
assertHitCount(searchResponse, 10);
assertThat(searchResponse.getHits().getHits().length, equalTo(finalSize));
for (int i = 0; i < finalSize; i++) {
SearchHit searchHit = searchResponse.getHits().getAt(i);
assertThat(searchHit.getId(), equalTo(Integer.toString(i)));

String expected = new String(new char[] { (char) (97 + i), (char) (97 + i) });
assertThat(searchHit.getSortValues()[0].toString(), equalTo(expected));
}
String expected = new String(new char[] { (char) (97 + i), (char) (97 + i) });
assertThat(searchHit.getSortValues()[0].toString(), equalTo(expected));
}
});

size = 1 + random.nextInt(10);
searchResponse[0] = client().prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("str_value", SortOrder.DESC).get();
SearchResponse searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("str_value", SortOrder.DESC).get();

assertHitCount(searchResponse[0], 10);
assertThat(searchResponse[0].getHits().getHits().length, equalTo(size));
assertHitCount(searchResponse, 10);
assertThat(searchResponse.getHits().getHits().length, equalTo(size));
for (int i = 0; i < size; i++) {
SearchHit searchHit = searchResponse[0].getHits().getAt(i);
SearchHit searchHit = searchResponse.getHits().getAt(i);
assertThat(searchHit.getId(), equalTo(Integer.toString(9 - i)));

String expected = new String(new char[] { (char) (97 + (9 - i)), (char) (97 + (9 - i)) });
assertThat(searchHit.getSortValues()[0].toString(), equalTo(expected));
}

assertThat(searchResponse[0].toString(), not(containsString("error")));
assertNoFailures(searchResponse[0]);
assertThat(searchResponse.toString(), not(containsString("error")));
assertNoFailures(searchResponse);
}

public void testSortMinValueScript() throws Exception {
Expand Down
7 changes: 0 additions & 7 deletions server/src/main/java/org/opensearch/index/IndexSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -751,13 +751,6 @@ public IndexSettings(final IndexMetadata indexMetadata, final Settings nodeSetti
this.indexMetadata = indexMetadata;
numberOfShards = settings.getAsInt(IndexMetadata.SETTING_NUMBER_OF_SHARDS, null);
replicationType = IndexMetadata.INDEX_REPLICATION_TYPE_SETTING.get(settings);
// if (FeatureFlags.isEnabled(FeatureFlags.SEGMENT_REPLICATION_EXPERIMENTAL)
// && indexMetadata.isSystem() == false
// && settings.get(IndexMetadata.SETTING_REPLICATION_TYPE) == null) {
// replicationType = IndicesService.CLUSTER_REPLICATION_TYPE_SETTING.get(settings);
// } else {
// replicationType = IndexMetadata.INDEX_REPLICATION_TYPE_SETTING.get(settings);
// }
isRemoteStoreEnabled = settings.getAsBoolean(IndexMetadata.SETTING_REMOTE_STORE_ENABLED, false);
isRemoteTranslogStoreEnabled = settings.getAsBoolean(IndexMetadata.SETTING_REMOTE_TRANSLOG_STORE_ENABLED, false);
remoteStoreTranslogRepository = settings.get(IndexMetadata.SETTING_REMOTE_TRANSLOG_STORE_REPOSITORY);
Expand Down

0 comments on commit d4b7354

Please sign in to comment.