Skip to content

Commit

Permalink
Address comments for tests
Browse files Browse the repository at this point in the history
Signed-off-by: Arpit Bandejiya <abandeji@amazon.com>
  • Loading branch information
Arpit-Bandejiya committed Jul 17, 2024
1 parent 69ec401 commit 8e5e031
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1019,10 +1019,10 @@ ClusterState readClusterStateInParallel(

LatchedActionListener<IndexRoutingTable> routingTableLatchedActionListener = new LatchedActionListener<>(
ActionListener.wrap(response -> {
logger.debug("Successfully read cluster state component from remote");
logger.debug(() -> new ParameterizedMessage("Successfully read index-routing for index {}", response.getIndex().getName()));
readIndexRoutingTableResults.add(response);
}, ex -> {
logger.error("Failed to read cluster state from remote", ex);
logger.error(() -> new ParameterizedMessage("Failed to read index-routing from remote"), ex);
exceptionList.add(ex);
}),
latch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ private void setPathHashAlgoSetting(RemoteStoreEnums.PathHashAlgorithm pathHashA
}

// For testing only
public RemoteStoreEnums.PathType getPathTypeSetting() {
protected RemoteStoreEnums.PathType getPathTypeSetting() {
return pathType;
}

// For testing only
public RemoteStoreEnums.PathHashAlgorithm getPathHashAlgoSetting() {
protected RemoteStoreEnums.PathHashAlgorithm getPathHashAlgoSetting() {
return pathHashAlgo;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.opensearch.core.compress.NoneCompressor;
import org.opensearch.core.index.Index;
import org.opensearch.gateway.remote.ClusterMetadataManifest;
import org.opensearch.gateway.remote.RemoteClusterStateUtils;
import org.opensearch.index.remote.RemoteStoreEnums;
import org.opensearch.index.remote.RemoteStorePathStrategy;
import org.opensearch.index.remote.RemoteStoreUtils;
Expand Down Expand Up @@ -61,15 +62,17 @@

import static org.opensearch.common.util.FeatureFlags.REMOTE_PUBLICATION_EXPERIMENTAL;
import static org.opensearch.gateway.remote.ClusterMetadataManifestTests.randomUploadedIndexMetadataList;
import static org.opensearch.gateway.remote.RemoteClusterStateUtils.CLUSTER_STATE_PATH_TOKEN;
import static org.opensearch.gateway.remote.RemoteClusterStateUtils.DELIMITER;
import static org.opensearch.gateway.remote.RemoteClusterStateUtils.PATH_DELIMITER;
import static org.opensearch.gateway.remote.routingtable.RemoteIndexRoutingTable.INDEX_ROUTING_FILE;
import static org.opensearch.gateway.remote.routingtable.RemoteIndexRoutingTable.INDEX_ROUTING_METADATA_PREFIX;
import static org.opensearch.gateway.remote.routingtable.RemoteIndexRoutingTable.INDEX_ROUTING_TABLE;
import static org.opensearch.gateway.remote.routingtable.RemoteIndexRoutingTable.INDEX_ROUTING_TABLE_FORMAT;
import static org.opensearch.index.remote.RemoteStoreEnums.PathHashAlgorithm.FNV_1A_BASE64;
import static org.opensearch.index.remote.RemoteStoreEnums.PathType.HASHED_PREFIX;
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_ROUTING_TABLE_REPOSITORY_NAME_ATTRIBUTE_KEY;
import static org.hamcrest.Matchers.lessThanOrEqualTo;
import static org.mockito.ArgumentMatchers.anyIterable;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.any;
Expand Down Expand Up @@ -112,7 +115,7 @@ public void setup() {
when(blobStoreRepository.getCompressor()).thenReturn(new DeflateCompressor());
blobStore = mock(BlobStore.class);
blobContainer = mock(BlobContainer.class);
when(repositoriesService.repository(anyString())).thenReturn(blobStoreRepository);
when(repositoriesService.repository("routing_repository")).thenReturn(blobStoreRepository);
when(blobStoreRepository.blobStore()).thenReturn(blobStore);
when(blobStore.blobContainer(any())).thenReturn(blobContainer);
Settings nodeSettings = Settings.builder().put(REMOTE_PUBLICATION_EXPERIMENTAL, "true").build();
Expand Down Expand Up @@ -552,11 +555,25 @@ public void testGetAsyncIndexRoutingReadAction() throws Exception {
public void testGetAsyncIndexRoutingWriteAction() throws Exception {
String indexName = randomAlphaOfLength(randomIntBetween(1, 50));
ClusterState clusterState = createClusterState(indexName);
Iterable<String> remotePath = HASHED_PREFIX.path(
RemoteStorePathStrategy.PathInput.builder()
.basePath(
new BlobPath().add("base-path")
.add(RemoteClusterStateUtils.encodeString(ClusterName.DEFAULT.toString()))
.add(CLUSTER_STATE_PATH_TOKEN)
.add(clusterState.metadata().clusterUUID())
.add(INDEX_ROUTING_TABLE)
)
.indexUUID(clusterState.getRoutingTable().indicesRouting().get(indexName).getIndex().getUUID())
.build(),
FNV_1A_BASE64
);

doAnswer(invocationOnMock -> {
invocationOnMock.getArgument(4, ActionListener.class).onResponse(null);
return null;
}).when(blobStoreTransferService)
.uploadBlob(any(InputStream.class), anyIterable(), anyString(), eq(WritePriority.URGENT), any(ActionListener.class));
.uploadBlob(any(InputStream.class), eq(remotePath), anyString(), eq(WritePriority.URGENT), any(ActionListener.class));

TestCapturingListener<ClusterMetadataManifest.UploadedMetadata> listener = new TestCapturingListener<>();
CountDownLatch latch = new CountDownLatch(1);
Expand Down

0 comments on commit 8e5e031

Please sign in to comment.