Skip to content

Commit

Permalink
Pass S3RepositoryTests
Browse files Browse the repository at this point in the history
Signed-off-by: Bhumika Saini <[email protected]>
  • Loading branch information
Bhumika Saini committed Sep 19, 2023
1 parent d30113f commit ced330e
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 @@ -44,7 +44,6 @@
import org.opensearch.common.logging.DeprecationLogger;
import org.opensearch.common.settings.SecureSetting;
import org.opensearch.common.settings.Setting;
import org.opensearch.common.settings.Settings;
import org.opensearch.core.action.ActionListener;
import org.opensearch.core.common.Strings;
import org.opensearch.core.common.settings.SecureString;
Expand Down Expand Up @@ -427,8 +426,7 @@ public void reload(RepositoryMetadata newRepositoryMetadata, boolean compress) {
repositoryMetadata = newRepositoryMetadata;

// Reload configs for S3RepositoryPlugin
Settings settings = clusterService.getSettings();
final Map<String, S3ClientSettings> clientsSettings = S3ClientSettings.load(settings, pluginConfigPath);
final Map<String, S3ClientSettings> clientsSettings = S3ClientSettings.load(repositoryMetadata.settings(), pluginConfigPath);
service.refreshAndClearCache(clientsSettings);
s3AsyncService.refreshAndClearCache(clientsSettings);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ public void refreshAndClearCache(Map<String, S3ClientSettings> clientsSettings)
public void close() {}
}

private static class DummyS3AsyncService extends S3AsyncService {
DummyS3AsyncService(Path configPath) {
super(configPath);
}
}

public void testInvalidChunkBufferSizeSettings() {
// chunk < buffer should fail
final Settings s1 = bufferAndChunkSettings(10, 5);
Expand Down Expand Up @@ -143,7 +149,7 @@ private S3Repository createS3Repo(RepositoryMetadata metadata) {
null,
null,
null,
null,
new DummyS3AsyncService(configPath()),
false
) {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,8 @@ protected BlobStoreRepository(
final ClusterService clusterService,
final RecoverySettings recoverySettings
) {
reload(repositoryMetadata, compress);
// Read RepositoryMetadata as the first step
readRepositoryMetadata(repositoryMetadata, compress);

isSystemRepository = SYSTEM_REPOSITORY_SETTING.get(metadata.settings());
this.namedXContentRegistry = namedXContentRegistry;
Expand All @@ -423,6 +424,16 @@ protected BlobStoreRepository(

@Override
public void reload(RepositoryMetadata repositoryMetadata, boolean compress) {
readRepositoryMetadata(repositoryMetadata, compress);
}

/**
* Reloads the values derived from the Repository Metadata
*
* @param repositoryMetadata RepositoryMetadata instance to derive the values from
* @param compress boolean representing whether compression is to be used
*/
private void readRepositoryMetadata(RepositoryMetadata repositoryMetadata, boolean compress) {
this.metadata = repositoryMetadata;

supportURLRepo = SUPPORT_URL_REPO.get(metadata.settings());
Expand Down

0 comments on commit ced330e

Please sign in to comment.