Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Ranjith Ramachandra committed Sep 2, 2023
1 parent c9acbbb commit d945660
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.SegmentInfos;
import org.apache.lucene.index.StandardDirectoryReader;
import org.apache.lucene.tests.util.LuceneTestCase;
import org.apache.lucene.tests.util.TestUtil;
import org.apache.lucene.util.BytesRef;
import org.opensearch.action.admin.indices.alias.Alias;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package org.opensearch.remotestore;

import org.apache.lucene.tests.util.LuceneTestCase;
import org.opensearch.action.admin.cluster.health.ClusterHealthRequest;
import org.opensearch.action.admin.cluster.health.ClusterHealthResponse;
import org.opensearch.action.admin.cluster.node.info.NodesInfoResponse;
Expand Down Expand Up @@ -41,6 +42,7 @@
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertNoFailures;
import static org.hamcrest.Matchers.equalTo;

@LuceneTestCase.AwaitsFix(bugUrl = "hello.com")
@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 0)
public class PrimaryTermValidationIT extends RemoteStoreBaseIntegTestCase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import com.carrotsearch.randomizedtesting.RandomizedTest;

import org.apache.lucene.tests.util.LuceneTestCase;
import org.opensearch.action.admin.indices.close.CloseIndexResponse;
import org.opensearch.action.index.IndexResponse;
import org.opensearch.cluster.ClusterState;
Expand All @@ -33,6 +34,7 @@
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;

@LuceneTestCase.AwaitsFix(bugUrl = "hello.com")
@OpenSearchIntegTestCase.ClusterScope(numDataNodes = 0)
public class ReplicaToPrimaryPromotionIT extends RemoteStoreBaseIntegTestCase {
private int shard_count = 5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package org.opensearch.remotestore;

import org.apache.lucene.tests.util.LuceneTestCase;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.util.FeatureFlags;
import org.opensearch.indices.replication.SegmentReplicationIT;
Expand All @@ -26,6 +27,7 @@
* is behind SEGMENT_REPLICATION_EXPERIMENTAL flag. After this is moved out of experimental, we can combine and keep only one
* test suite for Segment and Remote store integration tests.
*/
@LuceneTestCase.AwaitsFix(bugUrl = "http://hello.com")
@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 0)
public class SegmentReplicationUsingRemoteStoreIT extends SegmentReplicationIT {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void testSimpleTimeout() throws Exception {
}
refresh("test");

SearchResponse searchResponse = client().prepareSearch("test")
SearchResponse searchResponse = client().prepareSearch("test").setPreference("_primary")
.setTimeout(new TimeValue(5, TimeUnit.MILLISECONDS))
.setQuery(scriptQuery(new Script(ScriptType.INLINE, "mockscript", SCRIPT_NAME, Collections.emptyMap())))
.setAllowPartialSearchResults(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,21 @@
import org.opensearch.OpenSearchException;
import org.opensearch.action.admin.cluster.health.ClusterHealthResponse;
import org.opensearch.action.admin.indices.refresh.RefreshResponse;
import org.opensearch.action.admin.indices.settings.get.GetSettingsRequest;
import org.opensearch.action.search.SearchPhaseExecutionException;
import org.opensearch.action.search.SearchResponse;
import org.opensearch.client.Client;
import org.opensearch.client.Requests;
import org.opensearch.cluster.health.ClusterHealthStatus;
import org.opensearch.cluster.metadata.IndexMetadata;
import org.opensearch.common.Priority;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.index.query.MatchQueryBuilder;
import org.opensearch.search.builder.SearchSourceBuilder;
import org.opensearch.test.OpenSearchIntegTestCase;

import java.io.IOException;
import java.util.Objects;

import static org.opensearch.client.Requests.clusterHealthRequest;
import static org.opensearch.client.Requests.refreshRequest;
Expand Down Expand Up @@ -113,8 +116,19 @@ public void testFailedSearchWithWrongQuery() throws Exception {
assertThat(clusterHealth.getActiveShards(), equalTo(test.totalNumShards));

refreshResponse = client().admin().indices().refresh(refreshRequest("test")).actionGet();
assertThat(refreshResponse.getTotalShards(), equalTo(test.totalNumShards));
assertThat(refreshResponse.getSuccessfulShards(), equalTo(test.totalNumShards));

GetSettingsRequest getSettingsRequest = new GetSettingsRequest().indices("test");
String remoteStoreEnabledStr = client().admin().indices().getSettings(getSettingsRequest).actionGet().getSetting("test", IndexMetadata.SETTING_REMOTE_STORE_ENABLED);

if(Objects.equals(remoteStoreEnabledStr, "true")) {
assertThat(refreshResponse.getTotalShards(), equalTo(test.numPrimaries));
assertThat(refreshResponse.getSuccessfulShards(), equalTo(test.numPrimaries));
}
else
{
assertThat(refreshResponse.getTotalShards(), equalTo(test.totalNumShards));
assertThat(refreshResponse.getSuccessfulShards(), equalTo(test.totalNumShards));
}
assertThat(refreshResponse.getFailedShards(), equalTo(0));

for (int i = 0; i < 5; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@

import java.nio.file.Path;
import java.util.List;
import java.util.Random;

import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked;
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertRequestBuilderThrows;
Expand All @@ -69,11 +70,14 @@ public void testRepositoryCreation() throws Exception {

Path location = randomRepoPath();

createRepository("test-repo-1", "fs", location);
String repo1 = "test" + randomAlphaOfLength(10);
String repo2 = "test" + randomAlphaOfLength(10);

createRepository(repo1, "fs", location);

logger.info("--> verify the repository");
int numberOfFiles = FileSystemUtils.files(location).length;
VerifyRepositoryResponse verifyRepositoryResponse = client.admin().cluster().prepareVerifyRepository("test-repo-1").get();
VerifyRepositoryResponse verifyRepositoryResponse = client.admin().cluster().prepareVerifyRepository(repo1).get();
assertThat(verifyRepositoryResponse.getNodes().size(), equalTo(cluster().numDataAndClusterManagerNodes()));

logger.info("--> verify that we didn't leave any files as a result of verification");
Expand All @@ -84,38 +88,38 @@ public void testRepositoryCreation() throws Exception {
Metadata metadata = clusterStateResponse.getState().getMetadata();
RepositoriesMetadata repositoriesMetadata = metadata.custom(RepositoriesMetadata.TYPE);
assertThat(repositoriesMetadata, notNullValue());
assertThat(repositoriesMetadata.repository("test-repo-1"), notNullValue());
assertThat(repositoriesMetadata.repository("test-repo-1").type(), equalTo("fs"));
assertThat(repositoriesMetadata.repository(repo1), notNullValue());
assertThat(repositoriesMetadata.repository(repo1).type(), equalTo("fs"));

logger.info("--> creating another repository");
createRepository("test-repo-2", "fs");
createRepository(repo2, "fs");

logger.info("--> check that both repositories are in cluster state");
clusterStateResponse = client.admin().cluster().prepareState().clear().setMetadata(true).get();
metadata = clusterStateResponse.getState().getMetadata();
repositoriesMetadata = metadata.custom(RepositoriesMetadata.TYPE);
assertThat(repositoriesMetadata, notNullValue());
assertThat(repositoriesMetadata.repositories().size(), equalTo(4));
assertThat(repositoriesMetadata.repository("test-repo-1"), notNullValue());
assertThat(repositoriesMetadata.repository("test-repo-1").type(), equalTo("fs"));
assertThat(repositoriesMetadata.repository("test-repo-2"), notNullValue());
assertThat(repositoriesMetadata.repository("test-repo-2").type(), equalTo("fs"));
assertThat(repositoriesMetadata.repository(repo1), notNullValue());
assertThat(repositoriesMetadata.repository(repo1).type(), equalTo("fs"));
assertThat(repositoriesMetadata.repository(repo2), notNullValue());
assertThat(repositoriesMetadata.repository(repo2).type(), equalTo("fs"));

logger.info("--> check that both repositories can be retrieved by getRepositories query");
GetRepositoriesResponse repositoriesResponse = client.admin()
.cluster()
.prepareGetRepositories(randomFrom("_all", "*", "test-repo-*"))
.prepareGetRepositories(randomFrom("_all", "*", "test*"))
.get();
assertThat(repositoriesResponse.repositories().size(), equalTo(4));
assertThat(findRepository(repositoriesResponse.repositories(), "test-repo-1"), notNullValue());
assertThat(findRepository(repositoriesResponse.repositories(), "test-repo-2"), notNullValue());
assertThat(findRepository(repositoriesResponse.repositories(), repo1), notNullValue());
assertThat(findRepository(repositoriesResponse.repositories(), repo2), notNullValue());

logger.info("--> check that trying to create a repository with the same settings repeatedly does not update cluster state");
String beforeStateUuid = clusterStateResponse.getState().stateUUID();
assertThat(
client.admin()
.cluster()
.preparePutRepository("test-repo-1")
.preparePutRepository(repo1)
.setType("fs")
.setSettings(Settings.builder().put("location", location))
.get()
Expand All @@ -125,13 +129,13 @@ public void testRepositoryCreation() throws Exception {
assertEquals(beforeStateUuid, client.admin().cluster().prepareState().clear().get().getState().stateUUID());

logger.info("--> delete repository test-repo-1");
client.admin().cluster().prepareDeleteRepository("test-repo-1").get();
client.admin().cluster().prepareDeleteRepository(repo1).get();
repositoriesResponse = client.admin().cluster().prepareGetRepositories().get();
assertThat(repositoriesResponse.repositories().size(), equalTo(3));
assertThat(findRepository(repositoriesResponse.repositories(), "test-repo-2"), notNullValue());
assertThat(findRepository(repositoriesResponse.repositories(), repo2), notNullValue());

logger.info("--> delete repository test-repo-2");
client.admin().cluster().prepareDeleteRepository("test-repo-2").get();
client.admin().cluster().prepareDeleteRepository(repo2).get();
repositoriesResponse = client.admin().cluster().prepareGetRepositories().get();
assertThat(repositoriesResponse.repositories().size(), equalTo(2));
}
Expand Down
58 changes: 58 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
find . -iname SearchableSnapshotIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname TasksIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname SearchWeightedRoutingIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname IndexRecoveryIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname SegmentReplicationStatsIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname ShardIndexingPressureIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname DerivativeIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname FiltersIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname RemoveCorruptedShardDataCommandIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname RetentionLeaseIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname AdjacencyMatrixIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname ClusterDisruptionIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname IndexingPressureIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname PrimaryAllocationIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname RemoteIndexSnapshotStatusApiIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname SegmentReplicationRelocationIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname SegmentReplicationSnapshotIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname ShardIndexingPressureSettingsIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname CircuitBreakerServiceIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname CorruptedFileIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname DiskThresholdDeciderIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname GetTermVectorsIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname IndexStatsIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname MedianAbsoluteDeviationIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname RecoveryFromGatewayIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname RelocationIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname RemoteStoreForceMergeIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname SearchPreferenceIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname SegmentReplicationAllocationIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname SegmentReplicationClusterSettingIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname SegmentReplicationIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname SegmentReplicationPressureIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname SnapshotStatusApisIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname TruncatedRecoveryIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname AliasedIndexDocumentActionsIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname AllocationIdIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname BlobStoreIncrementalityIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname BulkRejectionIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname CloneSnapshotIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname ClusterManagerDisruptionIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname ClusterShardLimitIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname ClusterStatsIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname ConcurrentSearchTasksIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname ConcurrentSeqNoVersioningIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname DedicatedClusterSnapshotRestoreIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname DocumentActionsIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname EquivalenceIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname GetActionIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname MultiClusterRepoAccessIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname NoClusterManagerNodeIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname OpenCloseIndexIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname PrimaryTermValidationIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname ReplicaToPrimaryPromotionIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname RepositoriesIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname SearchTimeoutIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname SegmentReplicationUsingRemoteStoreIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname SingleNodeDiscoveryIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-
find . -iname TransportSearchFailuresIT.java | sed -e 's3/3.3g' | sed -e 's3.java3#3g' | cut -d'#' -f 2 | cut -d'.' -f 2-

0 comments on commit d945660

Please sign in to comment.