Skip to content

Commit

Permalink
Fix failures in S3RepositoryPluginTests
Browse files Browse the repository at this point in the history
Signed-off-by: Ashish Singh <[email protected]>
  • Loading branch information
ashking94 committed Dec 18, 2024
1 parent 7ada6c4 commit 1db7150
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package org.opensearch.repositories.s3;

import org.opensearch.cluster.service.ClusterService;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.unit.SizeUnit;
import org.opensearch.common.unit.SizeValue;
Expand All @@ -25,6 +26,8 @@
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class S3RepositoryPluginTests extends OpenSearchTestCase {

Expand All @@ -37,8 +40,6 @@ public void testGetExecutorBuilders() throws IOException {
ThreadPool threadPool = null;
try (S3RepositoryPlugin plugin = new S3RepositoryPlugin(settings, configPath)) {
List<ExecutorBuilder<?>> executorBuilders = plugin.getExecutorBuilders(settings);
assertNotNull(executorBuilders);
assertFalse(executorBuilders.isEmpty());
threadPool = new ThreadPool(settings, executorBuilders.toArray(new ExecutorBuilder<?>[0]));
final Executor executor = threadPool.executor(URGENT_FUTURE_COMPLETION);
assertNotNull(executor);
Expand All @@ -57,6 +58,12 @@ public void testGetExecutorBuilders() throws IOException {
assertThat(info.getMax(), equalTo(size));
assertThat(openSearchThreadPoolExecutor.getMaximumPoolSize(), equalTo(size));

ClusterService clusterService = mock(ClusterService.class);
when(clusterService.getSettings()).thenReturn(Settings.EMPTY);
plugin.createComponents(null, clusterService, threadPool, null, null, null, null, null, null, null, null);
assertNotNull(executorBuilders);
assertFalse(executorBuilders.isEmpty());

final int availableProcessors = Runtime.getRuntime().availableProcessors();
if (processors > availableProcessors) {
assertWarnings(
Expand Down

0 comments on commit 1db7150

Please sign in to comment.