Skip to content

Commit

Permalink
Reload repo metadata inplace in rate limiter IT
Browse files Browse the repository at this point in the history
Signed-off-by: Bhumika Saini <[email protected]>
  • Loading branch information
Bhumika Saini committed Oct 3, 2023
1 parent 5ecb3a1 commit 779446e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.opensearch.index.mapper.MapperService;
import org.opensearch.indices.replication.common.ReplicationType;
import org.opensearch.repositories.blobstore.BlobStoreRepository;
import org.opensearch.repositories.fs.FsRepository;
import org.opensearch.repositories.fs.ReloadableFsRepository;
import org.opensearch.test.OpenSearchIntegTestCase;
import org.junit.After;

Expand Down Expand Up @@ -210,10 +210,10 @@ public static Settings buildRemoteStoreNodeAttributes(
return buildRemoteStoreNodeAttributes(
segmentRepoName,
segmentRepoPath,
FsRepository.TYPE,
ReloadableFsRepository.TYPE,
translogRepoName,
translogRepoPath,
FsRepository.TYPE,
ReloadableFsRepository.TYPE,
withRateLimiterAttributes
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@
import org.opensearch.action.admin.cluster.remotestore.restore.RestoreRemoteStoreResponse;
import org.opensearch.action.support.PlainActionFuture;
import org.opensearch.cluster.health.ClusterHealthStatus;
import org.opensearch.cluster.metadata.RepositoryMetadata;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.unit.TimeValue;
import org.opensearch.core.common.unit.ByteSizeUnit;
import org.opensearch.repositories.RepositoriesService;
import org.opensearch.repositories.Repository;
import org.opensearch.test.InternalTestCluster;
import org.opensearch.test.OpenSearchIntegTestCase;

Expand Down Expand Up @@ -396,6 +400,17 @@ public void testRateLimitedRemoteDownloads() throws Exception {
shardCount,
buildRemoteStoreNodeAttributes(REPOSITORY_NAME, randomRepoPath(), REPOSITORY_2_NAME, randomRepoPath(), true)
);

// validate inplace repository metadata update
RepositoriesService reposService = internalCluster().getInstance(RepositoriesService.class);
Repository segmentRepo = reposService.repository(REPOSITORY_NAME);
assertEquals("4kb", segmentRepo.getMetadata().settings().get("max_remote_download_bytes_per_sec"));
Settings settings = Settings.builder().put("max_remote_download_bytes_per_sec", 10, ByteSizeUnit.KB).build();
RepositoryMetadata newRepoMetadata = new RepositoryMetadata(REPOSITORY_NAME, "fs", settings);
segmentRepo.validateMetadata(newRepoMetadata);
segmentRepo.reload(newRepoMetadata);
assertEquals("10240b", segmentRepo.getMetadata().settings().get("max_remote_download_bytes_per_sec"));

Map<String, Long> indexStats = indexData(5, false, INDEX_NAME);
assertEquals(shardCount, getNumShards(INDEX_NAME).totalNumShards);
internalCluster().stopRandomNode(InternalTestCluster.nameFilter(primaryNodeName(INDEX_NAME)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
import java.nio.file.Path;
import java.util.Locale;

import static org.junit.Assert.assertTrue;

public class ReloadableFsRepositoryTests extends OpenSearchTestCase {
ReloadableFsRepository repository;
RepositoryMetadata metadata;
Expand Down Expand Up @@ -69,6 +67,7 @@ public void testIsReloadable() {
public void testCompressReload() {
assertEquals(CompressorRegistry.none(), repository.getCompressor());
updateCompressionTypeToDefault();
repository.validateMetadata(metadata);
repository.reload(metadata);
assertEquals(CompressorRegistry.defaultCompressor(), repository.getCompressor());
}
Expand Down Expand Up @@ -99,6 +98,7 @@ public void testCompressionTypeReload() {
.put(FsRepository.BASE_PATH_SETTING.getKey(), "my_base_path")
.build();
metadata = new RepositoryMetadata("test", "fs", settings);
repository.validateMetadata(metadata);
repository.reload(metadata);
assertEquals(CompressorRegistry.getCompressor(ZstdCompressor.NAME.toUpperCase(Locale.ROOT)), repository.getCompressor());
}
Expand Down

0 comments on commit 779446e

Please sign in to comment.