Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ranjith Ramachandra committed Sep 3, 2023
1 parent 0ec5189 commit 49ce212
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,15 @@ protected String getConcreteIndexName() {
public void testIndexActions() throws Exception {
createIndex();
NumShards numShards = getNumShards(getConcreteIndexName());
logger.info("Running Cluster Health");
logger.info("ConcreteIndexName Running Cluster Health" + getConcreteIndexName());
ensureGreen();

GetSettingsRequest getSettingsRequest = new GetSettingsRequest().indices(getConcreteIndexName());
client().admin().indices().getSettings(getSettingsRequest).actionGet().getIndexToSettings();
String remoteStoreEnabledStr = client().admin().indices().getSettings(getSettingsRequest).actionGet().getSetting(getConcreteIndexName(), IndexMetadata.SETTING_REMOTE_STORE_ENABLED);
logger.warn("MyIndexSettings (" + remoteStoreEnabledStr + ")");
logger.warn("MyFullSettings ( " + client().admin().indices().getSettings(getSettingsRequest).actionGet().getIndexToSettings() + ")");

logger.info("Indexing [type1/1]");
IndexResponse indexResponse = client().prepareIndex()
.setIndex("test")
Expand All @@ -93,9 +100,6 @@ public void testIndexActions() throws Exception {
logger.info("Refreshing");
RefreshResponse refreshResponse = refresh();

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 {
Expand All @@ -113,20 +117,12 @@ public void testIndexActions() throws Exception {
.clearCache(clearIndicesCacheRequest("test").fieldDataCache(true).queryCache(true))
.actionGet();
assertNoFailures(clearIndicesCacheResponse);
if(Objects.equals(remoteStoreEnabledStr, "true")) {
assertThat(clearIndicesCacheResponse.getSuccessfulShards(), equalTo(numShards.numPrimaries));
} else {
assertThat(clearIndicesCacheResponse.getSuccessfulShards(), equalTo(numShards.totalNumShards));
}
assertThat(clearIndicesCacheResponse.getSuccessfulShards(), equalTo(numShards.totalNumShards));

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

GetResponse getResult;

Expand Down Expand Up @@ -176,7 +172,12 @@ public void testIndexActions() throws Exception {

logger.info("Flushing");
FlushResponse flushResult = client().admin().indices().prepareFlush("test").execute().actionGet();
assertThat(flushResult.getSuccessfulShards(), equalTo(numShards.totalNumShards));
if(Objects.equals(remoteStoreEnabledStr, "true")) {
assertThat(flushResult.getSuccessfulShards(), equalTo(numShards.numPrimaries));
}
else {
assertThat(flushResult.getSuccessfulShards(), equalTo(numShards.totalNumShards));
}
assertThat(flushResult.getFailedShards(), equalTo(0));
logger.info("Refreshing");
client().admin().indices().refresh(refreshRequest("test")).actionGet();
Expand Down Expand Up @@ -221,6 +222,9 @@ public void testBulk() throws Exception {
NumShards numShards = getNumShards(getConcreteIndexName());
logger.info("-> running Cluster Health");
ensureGreen();
GetSettingsRequest getSettingsRequest = new GetSettingsRequest().indices(getConcreteIndexName());
String remoteStoreEnabledStr = client().admin().indices().getSettings(getSettingsRequest).actionGet().getSetting(getConcreteIndexName(), IndexMetadata.SETTING_REMOTE_STORE_ENABLED);
logger.warn("MyIndexSettings (" + remoteStoreEnabledStr + ")");

BulkResponse bulkResponse = client().prepareBulk()
.add(client().prepareIndex().setIndex("test").setId("1").setSource(source("1", "test")))
Expand Down Expand Up @@ -268,9 +272,6 @@ public void testBulk() throws Exception {
RefreshResponse refreshResponse = client().admin().indices().prepareRefresh("test").execute().actionGet();
assertNoFailures(refreshResponse);

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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ public Iterator<Setting<?>> settings() {

public static final String SETTING_REMOTE_STORE_ENABLED = "index.remote_store.enabled";


public static final String SETTING_REMOTE_SEGMENT_STORE_REPOSITORY = "index.remote_store.segment.repository";

public static final String SETTING_REMOTE_TRANSLOG_STORE_REPOSITORY = "index.remote_store.translog.repository";
Expand Down

0 comments on commit 49ce212

Please sign in to comment.