Skip to content

Commit

Permalink
Refactor existing tests
Browse files Browse the repository at this point in the history
Signed-off-by: Ashish Singh <ssashish@amazon.com>
  • Loading branch information
ashking94 committed Apr 15, 2024
1 parent f7c34b8 commit 723ead9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@
import org.opensearch.gateway.GatewayMetaState.RemotePersistedState;
import org.opensearch.gateway.PersistedClusterStateService.Writer;
import org.opensearch.gateway.remote.ClusterMetadataManifest;
import org.opensearch.gateway.remote.IndexCreationPreIndexMetadataUploadListener;
import org.opensearch.gateway.remote.RemoteClusterStateService;
import org.opensearch.gateway.remote.RemotePersistenceStats;
import org.opensearch.index.recovery.RemoteStoreRestoreService;
import org.opensearch.index.recovery.RemoteStoreRestoreService.RemoteRestoreResult;
import org.opensearch.index.remote.RemoteUploadPathIndexCreationListener;
import org.opensearch.node.Node;
import org.opensearch.repositories.RepositoriesService;
import org.opensearch.repositories.fs.FsRepository;
Expand All @@ -89,7 +89,6 @@
import java.util.List;
import java.util.Locale;
import java.util.Optional;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;
Expand Down Expand Up @@ -475,32 +474,22 @@ public void testDataOnlyNodePersistence() throws Exception {
);
Supplier<RemoteClusterStateService> remoteClusterStateServiceSupplier = () -> {
if (isRemoteStoreClusterStateEnabled(settings)) {
Supplier<RepositoriesService> repositoriesServiceSupplier = () -> new RepositoriesService(
settings,
clusterService,
transportService,
Collections.emptyMap(),
Collections.emptyMap(),
transportService.getThreadPool()
);
return new RemoteClusterStateService(
nodeEnvironment.nodeId(),
() -> new RepositoriesService(
settings,
clusterService,
transportService,
Collections.emptyMap(),
Collections.emptyMap(),
transportService.getThreadPool()
),
repositoriesServiceSupplier,
settings,
new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS),
() -> 0L,
threadPool,
new IndexCreationPreIndexMetadataUploadListener() {
@Override
public int latchCount(List<IndexMetadata> newIndexMetadataList) {
return 0;
}

@Override
public void run(List<IndexMetadata> newIndexMetadataList, CountDownLatch latch, List<Exception> exceptionList)
throws IOException {

}
}
new RemoteUploadPathIndexCreationListener(settings, repositoriesServiceSupplier)
);
} else {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.gateway.remote.ClusterMetadataManifest.UploadedIndexMetadata;
import org.opensearch.index.remote.RemoteStoreUtils;
import org.opensearch.index.remote.RemoteUploadPathIndexCreationListener;
import org.opensearch.indices.IndicesModule;
import org.opensearch.repositories.FilterRepository;
import org.opensearch.repositories.RepositoriesService;
Expand Down Expand Up @@ -155,18 +156,7 @@ public void setup() {
clusterSettings,
() -> 0L,
threadPool,
new IndexCreationPreIndexMetadataUploadListener() {
@Override
public int latchCount(List<IndexMetadata> newIndexMetadataList) {
return 0;
}

@Override
public void run(List<IndexMetadata> newIndexMetadataList, CountDownLatch latch, List<Exception> exceptionList)
throws IOException {

}
}
new RemoteUploadPathIndexCreationListener(settings, repositoriesServiceSupplier)
);
}

Expand Down Expand Up @@ -194,18 +184,7 @@ public void testFailInitializationWhenRemoteStateDisabled() {
new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS),
() -> 0L,
threadPool,
new IndexCreationPreIndexMetadataUploadListener() {
@Override
public int latchCount(List<IndexMetadata> newIndexMetadataList) {
return 0;
}

@Override
public void run(List<IndexMetadata> newIndexMetadataList, CountDownLatch latch, List<Exception> exceptionList)
throws IOException {

}
}
new RemoteUploadPathIndexCreationListener(settings, repositoriesServiceSupplier)
)
);
}
Expand Down

0 comments on commit 723ead9

Please sign in to comment.