|
136 | 136 | import static java.util.Collections.emptyMap;
|
137 | 137 | import static java.util.Collections.singleton;
|
138 | 138 | import static java.util.Collections.singletonList;
|
| 139 | +import static org.opensearch.cluster.metadata.IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING; |
139 | 140 | import static org.opensearch.cluster.metadata.IndexMetadata.INDEX_NUMBER_OF_ROUTING_SHARDS_SETTING;
|
140 | 141 | import static org.opensearch.cluster.metadata.IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING;
|
141 | 142 | import static org.opensearch.cluster.metadata.IndexMetadata.INDEX_READ_ONLY_BLOCK;
|
@@ -1821,6 +1822,42 @@ private void validateRemoteCustomData(Map<String, String> customData, String exp
|
1821 | 1822 | assertEquals(expectedValue, customData.get(expectedKey));
|
1822 | 1823 | }
|
1823 | 1824 |
|
| 1825 | + public void testNumberOfRoutingShardsShowsInIndexSettings() { |
| 1826 | + withTemporaryClusterService(((clusterService, threadPool) -> { |
| 1827 | + MetadataCreateIndexService checkerService = new MetadataCreateIndexService( |
| 1828 | + Settings.EMPTY, |
| 1829 | + clusterService, |
| 1830 | + indicesServices, |
| 1831 | + null, |
| 1832 | + null, |
| 1833 | + createTestShardLimitService(randomIntBetween(1, 1000), false, clusterService), |
| 1834 | + null, |
| 1835 | + null, |
| 1836 | + threadPool, |
| 1837 | + null, |
| 1838 | + new SystemIndices(Collections.emptyMap()), |
| 1839 | + false, |
| 1840 | + new AwarenessReplicaBalance(Settings.EMPTY, clusterService.getClusterSettings()), |
| 1841 | + DefaultRemoteStoreSettings.INSTANCE, |
| 1842 | + repositoriesServiceSupplier |
| 1843 | + ); |
| 1844 | + final int routingNumberOfShards = 4; |
| 1845 | + Settings indexSettings = Settings.builder() |
| 1846 | + .put("index.version.created", Version.CURRENT) |
| 1847 | + .put(INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 2) |
| 1848 | + .put(INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0) |
| 1849 | + .put(INDEX_NUMBER_OF_ROUTING_SHARDS_SETTING.getKey(), routingNumberOfShards) |
| 1850 | + .build(); |
| 1851 | + CreateIndexClusterStateUpdateRequest request = new CreateIndexClusterStateUpdateRequest("create index", "test", "test"); |
| 1852 | + IndexMetadata indexMetadata = checkerService.buildAndValidateTemporaryIndexMetadata( |
| 1853 | + indexSettings, |
| 1854 | + request, |
| 1855 | + routingNumberOfShards |
| 1856 | + ); |
| 1857 | + assertEquals(INDEX_NUMBER_OF_ROUTING_SHARDS_SETTING.get(indexMetadata.getSettings()).intValue(), routingNumberOfShards); |
| 1858 | + })); |
| 1859 | + } |
| 1860 | + |
1824 | 1861 | public void testGetIndexNumberOfRoutingShardsWithNullSourceIndex() {
|
1825 | 1862 | Settings indexSettings = Settings.builder()
|
1826 | 1863 | .put("index.version.created", Version.CURRENT)
|
|
0 commit comments