Skip to content

Add undeclared Azure settings, modify test to exercise them #118634

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/118634.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 118634
summary: "Add undeclared Azure settings, modify test to exercise them"
area: Snapshot/Restore
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.elasticsearch.common.unit.ByteSizeUnit;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.core.SuppressForbidden;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.repositories.RepositoriesService;
Expand All @@ -41,6 +42,7 @@
import org.elasticsearch.telemetry.Measurement;
import org.elasticsearch.telemetry.TestTelemetryPlugin;
import org.elasticsearch.test.BackgroundIndexer;
import org.elasticsearch.threadpool.ThreadPool;

import java.io.ByteArrayInputStream;
import java.io.IOException;
Expand All @@ -53,6 +55,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Predicate;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
Expand All @@ -75,6 +78,8 @@ public class AzureBlobStoreRepositoryTests extends ESMockAPIBasedRepositoryInteg
protected static final String DEFAULT_ACCOUNT_NAME = "account";
protected static final Predicate<String> LIST_PATTERN = Pattern.compile("GET /[a-zA-Z0-9]+/[a-zA-Z0-9]+\\?.+").asMatchPredicate();
protected static final Predicate<String> GET_BLOB_PATTERN = Pattern.compile("GET /[a-zA-Z0-9]+/[a-zA-Z0-9]+/.+").asMatchPredicate();
private static final AtomicInteger MAX_CONNECTION_SETTING = new AtomicInteger(-1);
private static final AtomicInteger EVENT_LOOP_THREAD_COUNT_SETTING = new AtomicInteger(-1);

@Override
protected String repositoryType() {
Expand Down Expand Up @@ -132,9 +137,17 @@ protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {

// see com.azure.storage.blob.BlobUrlParts.parseIpUrl
final String endpoint = "ignored;DefaultEndpointsProtocol=http;BlobEndpoint=" + httpServerUrl() + "/" + accountName;

// The first node configured sets these for all nodes
MAX_CONNECTION_SETTING.compareAndSet(-1, randomIntBetween(10, 30));
EVENT_LOOP_THREAD_COUNT_SETTING.compareAndSet(-1, randomIntBetween(1, 3));
return Settings.builder()
.put(super.nodeSettings(nodeOrdinal, otherSettings))
.put(AzureStorageSettings.ENDPOINT_SUFFIX_SETTING.getConcreteSettingForNamespace("test").getKey(), endpoint)
.put(AzureClientProvider.EVENT_LOOP_THREAD_COUNT.getKey(), EVENT_LOOP_THREAD_COUNT_SETTING.get())
.put(AzureClientProvider.MAX_OPEN_CONNECTIONS.getKey(), MAX_CONNECTION_SETTING.get())
.put(AzureClientProvider.MAX_IDLE_TIME.getKey(), TimeValue.timeValueSeconds(randomIntBetween(10, 30)))
.put(AzureClientProvider.OPEN_CONNECTION_TIMEOUT.getKey(), TimeValue.timeValueSeconds(randomIntBetween(10, 30)))
.setSecureSettings(secureSettings)
.build();
}
Expand Down Expand Up @@ -262,6 +275,16 @@ private boolean isPutBlockList(String request) {
}
}

public void testSettingsTakeEffect() {
AzureClientProvider azureClientProvider = internalCluster().getInstance(AzureClientProvider.class);
assertEquals(MAX_CONNECTION_SETTING.get(), azureClientProvider.getConnectionProvider().maxConnections());
ThreadPool nodeThreadPool = internalCluster().getInstance(ThreadPool.class);
assertEquals(
EVENT_LOOP_THREAD_COUNT_SETTING.get(),
nodeThreadPool.info(AzureRepositoryPlugin.NETTY_EVENT_LOOP_THREAD_POOL_NAME).getMax()
);
}

public void testLargeBlobCountDeletion() throws Exception {
int numberOfBlobs = randomIntBetween(257, 2000);
try (BlobStore store = newBlobStore()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@ protected void doStop() {
@Override
protected void doClose() {}

// visible for testing
ConnectionProvider getConnectionProvider() {
return connectionProvider;
}

static class RequestMetrics {
private volatile long totalRequestTimeNanos = 0;
private volatile int requestCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ AzureStorageService createAzureStorageService(Settings settingsToUse, AzureClien
@Override
public List<Setting<?>> getSettings() {
return Arrays.asList(
AzureClientProvider.EVENT_LOOP_THREAD_COUNT,
AzureClientProvider.MAX_OPEN_CONNECTIONS,
AzureClientProvider.OPEN_CONNECTION_TIMEOUT,
AzureClientProvider.MAX_IDLE_TIME,
AzureStorageSettings.ACCOUNT_SETTING,
AzureStorageSettings.KEY_SETTING,
AzureStorageSettings.SAS_TOKEN_SETTING,
Expand Down