From 779446e93c495eb2d58566e9c8cee2ba9b7ad6b9 Mon Sep 17 00:00:00 2001 From: Bhumika Saini Date: Tue, 3 Oct 2023 19:57:20 +0530 Subject: [PATCH] Reload repo metadata inplace in rate limiter IT Signed-off-by: Bhumika Saini --- .../remotestore/RemoteStoreBaseIntegTestCase.java | 6 +++--- .../remotestore/RemoteStoreRestoreIT.java | 15 +++++++++++++++ .../fs/ReloadableFsRepositoryTests.java | 4 ++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreBaseIntegTestCase.java b/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreBaseIntegTestCase.java index 157f8e41fee24..fcc4b6afd059a 100644 --- a/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreBaseIntegTestCase.java +++ b/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreBaseIntegTestCase.java @@ -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; @@ -210,10 +210,10 @@ public static Settings buildRemoteStoreNodeAttributes( return buildRemoteStoreNodeAttributes( segmentRepoName, segmentRepoPath, - FsRepository.TYPE, + ReloadableFsRepository.TYPE, translogRepoName, translogRepoPath, - FsRepository.TYPE, + ReloadableFsRepository.TYPE, withRateLimiterAttributes ); } diff --git a/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreRestoreIT.java b/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreRestoreIT.java index 65335f444a2df..47522720cc017 100644 --- a/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreRestoreIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreRestoreIT.java @@ -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; @@ -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 indexStats = indexData(5, false, INDEX_NAME); assertEquals(shardCount, getNumShards(INDEX_NAME).totalNumShards); internalCluster().stopRandomNode(InternalTestCluster.nameFilter(primaryNodeName(INDEX_NAME))); diff --git a/server/src/test/java/org/opensearch/repositories/fs/ReloadableFsRepositoryTests.java b/server/src/test/java/org/opensearch/repositories/fs/ReloadableFsRepositoryTests.java index a1c9f582438a9..db2cf9c3e9582 100644 --- a/server/src/test/java/org/opensearch/repositories/fs/ReloadableFsRepositoryTests.java +++ b/server/src/test/java/org/opensearch/repositories/fs/ReloadableFsRepositoryTests.java @@ -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; @@ -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()); } @@ -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()); }