forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HotToWarmTieringService changes and changes in shard balancer to tier
shards Signed-off-by: Neetika Singhal <[email protected]>
- Loading branch information
1 parent
5569b43
commit 044ea5b
Showing
11 changed files
with
1,330 additions
and
1 deletion.
There are no files selected for viewing
132 changes: 132 additions & 0 deletions
132
...nternalClusterTest/java/org/opensearch/remotestore/tiering/HotToWarmTieringServiceIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.remotestore.tiering; | ||
|
||
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters; | ||
|
||
import org.opensearch.action.search.SearchResponse; | ||
import org.opensearch.action.tiering.HotToWarmTieringAction; | ||
import org.opensearch.action.tiering.HotToWarmTieringResponse; | ||
import org.opensearch.action.tiering.TieringIndexRequest; | ||
import org.opensearch.cluster.ClusterInfoService; | ||
import org.opensearch.cluster.MockInternalClusterInfoService; | ||
import org.opensearch.cluster.metadata.IndexMetadata; | ||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.common.util.FeatureFlags; | ||
import org.opensearch.core.common.unit.ByteSizeUnit; | ||
import org.opensearch.core.common.unit.ByteSizeValue; | ||
import org.opensearch.index.IndexModule; | ||
import org.opensearch.index.query.QueryBuilders; | ||
import org.opensearch.index.store.remote.file.CleanerDaemonThreadLeakFilter; | ||
import org.opensearch.monitor.fs.FsInfo; | ||
import org.opensearch.plugins.Plugin; | ||
import org.opensearch.remotestore.RemoteStoreBaseIntegTestCase; | ||
import org.opensearch.test.OpenSearchIntegTestCase; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
|
||
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked; | ||
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertHitCount; | ||
|
||
@ThreadLeakFilters(filters = CleanerDaemonThreadLeakFilter.class) | ||
@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 0, supportsDedicatedMasters = false) | ||
// Uncomment the below line to enable trace level logs for this test for better debugging | ||
// @TestLogging(reason = "Getting trace logs from tiering package", value = | ||
// "org.opensearch.tiering:TRACE,org.opensearch.cluster.routing.allocation.decider:TRACE") | ||
public class HotToWarmTieringServiceIT extends RemoteStoreBaseIntegTestCase { | ||
|
||
protected static final String TEST_IDX_1 = "test-idx-1"; | ||
protected static final String TEST_IDX_2 = "test-idx-2"; | ||
protected static final String TARGET_TIER = "warm"; | ||
protected static final int NUM_DOCS_IN_BULK = 10; | ||
private static final long TOTAL_SPACE_BYTES = new ByteSizeValue(1000, ByteSizeUnit.KB).getBytes(); | ||
|
||
/* | ||
Disabling MockFSIndexStore plugin as the MockFSDirectoryFactory wraps the FSDirectory over a OpenSearchMockDirectoryWrapper which extends FilterDirectory (whereas FSDirectory extends BaseDirectory) | ||
As a result of this wrapping the local directory of Composite Directory does not satisfy the assertion that local directory must be of type FSDirectory | ||
*/ | ||
@Override | ||
protected boolean addMockIndexStorePlugin() { | ||
return false; | ||
} | ||
|
||
@Override | ||
protected Collection<Class<? extends Plugin>> nodePlugins() { | ||
return Collections.singletonList(MockInternalClusterInfoService.TestPlugin.class); | ||
} | ||
|
||
@Override | ||
protected Settings featureFlagSettings() { | ||
Settings.Builder featureSettings = Settings.builder(); | ||
featureSettings.put(FeatureFlags.TIERED_REMOTE_INDEX, true); | ||
return featureSettings.build(); | ||
} | ||
|
||
@Before | ||
public void setup() { | ||
internalCluster().startClusterManagerOnlyNode(); | ||
} | ||
|
||
@Test | ||
public void testTieringBasic() { | ||
final int numReplicasIndex = 0; | ||
internalCluster().ensureAtLeastNumDataNodes(1); | ||
final Settings settings = Settings.builder() | ||
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) | ||
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, numReplicasIndex) | ||
.put(IndexModule.INDEX_STORE_LOCALITY_SETTING.getKey(), IndexModule.DataLocalityType.FULL.name()) | ||
.build(); | ||
|
||
String[] indices = new String[] { TEST_IDX_1, TEST_IDX_2 }; | ||
for (String index : indices) { | ||
assertAcked(client().admin().indices().prepareCreate(index).setSettings(settings).get()); | ||
ensureGreen(index); | ||
// Ingesting some docs | ||
indexBulk(index, NUM_DOCS_IN_BULK); | ||
flushAndRefresh(index); | ||
// ensuring cluster is green after performing force-merge | ||
ensureGreen(); | ||
SearchResponse searchResponse = client().prepareSearch(index).setQuery(QueryBuilders.matchAllQuery()).get(); | ||
// Asserting that search returns same number of docs as ingested | ||
assertHitCount(searchResponse, NUM_DOCS_IN_BULK); | ||
} | ||
|
||
// Spin up node having search role | ||
internalCluster().ensureAtLeastNumSearchAndDataNodes(1); | ||
|
||
final MockInternalClusterInfoService clusterInfoService = getMockInternalClusterInfoService(); | ||
clusterInfoService.setDiskUsageFunctionAndRefresh( | ||
(discoveryNode, fsInfoPath) -> setDiskUsage(fsInfoPath, TOTAL_SPACE_BYTES, TOTAL_SPACE_BYTES) | ||
); | ||
|
||
TieringIndexRequest request = new TieringIndexRequest(TARGET_TIER, indices); | ||
request.waitForCompletion(true); | ||
HotToWarmTieringResponse response = client().admin().indices().execute(HotToWarmTieringAction.INSTANCE, request).actionGet(); | ||
assertAcked(response); | ||
assertTrue(response.getFailedIndices().isEmpty()); | ||
assertTrue(response.isAcknowledged()); | ||
for (String index : indices) { | ||
SearchResponse searchResponse = client().prepareSearch(index).setQuery(QueryBuilders.matchAllQuery()).get(); | ||
// Asserting that search returns same number of docs as ingested | ||
assertHitCount(searchResponse, NUM_DOCS_IN_BULK); | ||
assertAcked(client().admin().indices().prepareDelete(index).get()); | ||
} | ||
} | ||
|
||
private MockInternalClusterInfoService getMockInternalClusterInfoService() { | ||
return (MockInternalClusterInfoService) internalCluster().getCurrentClusterManagerNodeInstance(ClusterInfoService.class); | ||
} | ||
|
||
private static FsInfo.Path setDiskUsage(FsInfo.Path original, long totalBytes, long freeBytes) { | ||
return new FsInfo.Path(original.getPath(), original.getMount(), totalBytes, freeBytes, freeBytes); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.