Class OpenSearchIntegTestCase

java.lang.Object
org.junit.Assert
org.apache.lucene.tests.util.LuceneTestCase
org.opensearch.test.OpenSearchTestCase
org.opensearch.test.OpenSearchIntegTestCase
Direct Known Subclasses:
OpenSearchBlobStoreRepositoryIntegTestCase, ParameterizedDynamicSettingsOpenSearchIntegTestCase, ParameterizedStaticSettingsOpenSearchIntegTestCase, RemoteStoreBaseIntegTestCase

@SuppressFileSystems("ExtrasFS") public abstract class OpenSearchIntegTestCase extends OpenSearchTestCase
OpenSearchIntegTestCase is an abstract base class to run integration tests against a JVM private OpenSearch Cluster. The test class supports 2 different cluster scopes.

The most common test scope is OpenSearchIntegTestCase.Scope.SUITE which shares a cluster per test suite.

If the test methods need specific node settings or change persistent and/or transient cluster settings OpenSearchIntegTestCase.Scope.TEST should be used. To configure a scope for the test cluster the OpenSearchIntegTestCase.ClusterScope annotation should be used, here is an example:


 @NodeScope(scope=Scope.TEST) public class SomeIT extends OpenSearchIntegTestCase {
 public void testMethod() {}
 }
 

If no OpenSearchIntegTestCase.ClusterScope annotation is present on an integration test the default scope is OpenSearchIntegTestCase.Scope.SUITE

A test cluster creates a set of nodes in the background before the test starts. The number of nodes in the cluster is determined at random and can change across tests. The OpenSearchIntegTestCase.ClusterScope allows configuring the initial number of nodes that are created before the tests start.

 @NodeScope(scope=Scope.SUITE, numDataNodes=3)
 public class SomeIT extends OpenSearchIntegTestCase {
 public void testMethod() {}
 }
 

Note, the OpenSearchIntegTestCase uses randomized settings on a cluster and index level. For instance each test might use different directory implementation for each test or will return a random client to one of the nodes in the cluster for each call to client(). Test failures might only be reproducible if the correct system properties are passed to the test execution environment.

This class supports the following system properties (passed with -Dkey=value to the application)

  • -D"tests.enable_mock_modules" - a boolean value to enable or disable mock modules. This is useful to test the system without asserting modules that to make sure they don't hide any bugs in production.
  • - a random seed used to initialize the index random context.
  • Field Details

    • SYSPROP_THIRDPARTY

      public static final String SYSPROP_THIRDPARTY
      Property that controls whether ThirdParty Integration tests are run (not the default).
      See Also:
    • CODECS

      public static final List<String> CODECS
      The lucene_default Codec is not added to the list as it internally maps to Asserting Codec. The override to fetch the CompletionFieldMapper.CompletionFieldType postings format is not available for this codec.
    • SUITE_CLUSTER_NODE_PREFIX

      public static final String SUITE_CLUSTER_NODE_PREFIX
      node names of the corresponding clusters will start with these prefixes
      See Also:
    • TEST_CLUSTER_NODE_PREFIX

      public static final String TEST_CLUSTER_NODE_PREFIX
      See Also:
    • TESTS_CLUSTER

      public static final String TESTS_CLUSTER
      Key used to eventually switch to using an external cluster and provide its transport addresses
      See Also:
    • INDEX_TEST_SEED_SETTING

      public static final org.opensearch.common.settings.Setting<Long> INDEX_TEST_SEED_SETTING
      Key used to retrieve the index random seed from the index settings on a running node. The value of this seed can be used to initialize a random context for a specific index. It's set once per test via a generic index template.
    • TESTS_ENABLE_MOCK_MODULES

      public static final String TESTS_ENABLE_MOCK_MODULES
      A boolean value to enable or disable mock modules. This is useful to test the system without asserting modules that to make sure they don't hide any bugs in production.
      See Also:
    • testClusterRule

      public static org.opensearch.test.OpenSearchTestClusterRule testClusterRule
    • DEFAULT_MIN_NUM_SHARDS

      protected static final int DEFAULT_MIN_NUM_SHARDS
      Default minimum number of shards for an index
      See Also:
    • DEFAULT_MAX_NUM_SHARDS

      protected static final int DEFAULT_MAX_NUM_SHARDS
      Default maximum number of shards for an index
      See Also:
    • TESTS_CLUSTER_NAME

      public static final String TESTS_CLUSTER_NAME
      Key to provide the cluster name
      See Also:
    • REMOTE_BACKED_STORAGE_REPOSITORY_NAME

      protected static final String REMOTE_BACKED_STORAGE_REPOSITORY_NAME
      See Also:
    • prefixModeVerificationEnable

      protected static Boolean prefixModeVerificationEnable
    • translogPathFixedPrefix

      protected static Boolean translogPathFixedPrefix
    • segmentsPathFixedPrefix

      protected static Boolean segmentsPathFixedPrefix
    • snapshotShardPathFixedPrefix

      protected static Boolean snapshotShardPathFixedPrefix
  • Constructor Details

    • OpenSearchIntegTestCase

      public OpenSearchIntegTestCase()
  • Method Details

    • beforeClass

      public static void beforeClass() throws Exception
      Throws:
      Exception
    • enableWarningsCheck

      protected final boolean enableWarningsCheck()
      Description copied from class: OpenSearchTestCase
      Whether or not we check after each test whether it has left warnings behind. That happens if any deprecated feature or syntax was used by the test and the test didn't assert on it using OpenSearchTestCase.assertWarnings(String...).
      Overrides:
      enableWarningsCheck in class OpenSearchTestCase
    • randomIndexTemplate

      protected void randomIndexTemplate()
      Creates a randomized index template. This template is used to pass in randomized settings on a per index basis. Allows to enable/disable the randomization for number of shards and replicas
    • setRandomIndexSettings

      protected org.opensearch.common.settings.Settings.Builder setRandomIndexSettings(Random random, org.opensearch.common.settings.Settings.Builder builder)
    • excludeTemplates

      protected Set<String> excludeTemplates()
      Returns:
      An exclude set of index templates that will not be removed in between tests.
    • beforeIndexDeletion

      protected void beforeIndexDeletion() throws Exception
      Throws:
      Exception
    • cluster

      public static TestCluster cluster()
    • isInternalCluster

      public static boolean isInternalCluster()
    • internalCluster

      public static InternalTestCluster internalCluster()
    • clusterService

      public org.opensearch.cluster.service.ClusterService clusterService()
    • client

      public static org.opensearch.transport.client.Client client()
    • client

      public static org.opensearch.transport.client.Client client(@Nullable String node)
    • dataNodeClient

      public static org.opensearch.transport.client.Client dataNodeClient()
    • clients

      public static Iterable<org.opensearch.transport.client.Client> clients()
    • minimumNumberOfShards

      protected int minimumNumberOfShards()
    • maximumNumberOfShards

      protected int maximumNumberOfShards()
    • numberOfShards

      protected int numberOfShards()
    • minimumNumberOfReplicas

      protected int minimumNumberOfReplicas()
    • maximumNumberOfReplicas

      protected int maximumNumberOfReplicas()
    • numberOfReplicas

      protected int numberOfReplicas()
    • setDisruptionScheme

      public void setDisruptionScheme(ServiceDisruptionScheme scheme)
    • isolateClusterManagerDisruption

      protected static NetworkDisruption isolateClusterManagerDisruption(NetworkDisruption.NetworkLinkDisruptionType disruptionType)
      Creates a disruption that isolates the current cluster-manager node from all other nodes in the cluster.
      Parameters:
      disruptionType - type of disruption to create
      Returns:
      disruption
    • indexSettings

      public org.opensearch.common.settings.Settings indexSettings()
      Returns a settings object used in createIndex(String...) and prepareCreate(String) and friends. This method can be overwritten by subclasses to set defaults for the indices that are created by the test. By default it returns a settings object that sets a random number of shards. Number of shards and replicas can be controlled through specific methods.
    • featureFlagSettings

      protected org.opensearch.common.settings.Settings featureFlagSettings()
      Setting all feature flag settings at base IT, which can be overridden later by individual IT classes.
      Returns:
      Feature flag settings.
    • triggerRemoteStateRestore

      protected boolean triggerRemoteStateRestore()
      Represent if it needs to trigger remote state restore or not. For tests with remote store enabled domain, it will be overridden to true.
      Returns:
      if needs to perform remote state restore or not
    • performRemoteStoreTestAction

      protected void performRemoteStoreTestAction()
      For tests with remote cluster state, it will reset the cluster and cluster state will be restored from remote.
    • createIndex

      public final void createIndex(String... names)
      Creates one or more indices and asserts that the indices are acknowledged. If one of the indices already exists this method will fail and wipe all the indices created so far.
    • createIndex

      public final void createIndex(String name, org.opensearch.common.settings.Settings indexSettings)
      creates an index with the given setting
    • createIndex

      public final void createIndex(String name, org.opensearch.common.settings.Settings indexSettings, String mapping)
      creates an index with the given setting and mapping
    • createIndex

      public final void createIndex(String name, org.opensearch.cluster.metadata.Context context)
      creates an index with the given setting
    • prepareCreate

      public final org.opensearch.action.admin.indices.create.CreateIndexRequestBuilder prepareCreate(String index)
      Creates a new CreateIndexRequestBuilder with the settings obtained from indexSettings().
    • prepareCreate

      public final org.opensearch.action.admin.indices.create.CreateIndexRequestBuilder prepareCreate(String index, int numNodes)
      Creates a new CreateIndexRequestBuilder with the settings obtained from indexSettings(). The index that is created with this builder will only be allowed to allocate on the number of nodes passed to this method.

      This method uses allocation deciders to filter out certain nodes to allocate the created index on. It defines allocation rules based on index.routing.allocation.exclude._name.

    • prepareCreate

      public org.opensearch.action.admin.indices.create.CreateIndexRequestBuilder prepareCreate(String index, org.opensearch.common.settings.Settings.Builder settingsBuilder)
      Creates a new CreateIndexRequestBuilder with the settings obtained from indexSettings(), augmented by the given builder
    • prepareCreate

      public org.opensearch.action.admin.indices.create.CreateIndexRequestBuilder prepareCreate(String index, int numNodes, org.opensearch.common.settings.Settings.Builder settingsBuilder)
      Creates a new CreateIndexRequestBuilder with the settings obtained from indexSettings(). The index that is created with this builder will only be allowed to allocate on the number of nodes passed to this method.

      This method uses allocation deciders to filter out certain nodes to allocate the created index on. It defines allocation rules based on index.routing.allocation.exclude._name.

    • waitNoPendingTasksOnAll

      public void waitNoPendingTasksOnAll() throws Exception
      Waits until all nodes have no pending tasks.
      Throws:
      Exception
    • assertResultsAndLogOnFailure

      public void assertResultsAndLogOnFailure(long expectedResults, org.opensearch.action.search.SearchResponse searchResponse)
      Ensures the result counts are as expected, and logs the results if different
    • allowNodes

      public void allowNodes(String index, int n)
      Restricts the given index to be allocated on n nodes using the allocation deciders. Yet if the shards can't be allocated on any other node shards for this index will remain allocated on more than n nodes.
    • ensureGreen

      public org.opensearch.cluster.health.ClusterHealthStatus ensureGreen(String... indices)
      Ensures the cluster has a green state via the cluster health API. This method will also wait for relocations. It is useful to ensure that all action on the cluster have finished and all shards that were currently relocating are now allocated and started.
    • ensureGreen

      public org.opensearch.cluster.health.ClusterHealthStatus ensureGreen(org.opensearch.common.unit.TimeValue timeout, String... indices)
      Ensures the cluster has a green state via the cluster health API. This method will also wait for relocations. It is useful to ensure that all action on the cluster have finished and all shards that were currently relocating are now allocated and started.
      Parameters:
      timeout - time out value to set on ClusterHealthRequest
    • ensureGreen

      public org.opensearch.cluster.health.ClusterHealthStatus ensureGreen(org.opensearch.common.unit.TimeValue timeout, boolean waitForNoRelocatingShards, String... indices)
    • ensureYellow

      public org.opensearch.cluster.health.ClusterHealthStatus ensureYellow(String... indices)
      Ensures the cluster has a yellow state via the cluster health API.
    • ensureRed

      public org.opensearch.cluster.health.ClusterHealthStatus ensureRed(String... indices)
      Ensures the cluster has a red state via the cluster health API.
    • ensureYellowAndNoInitializingShards

      public org.opensearch.cluster.health.ClusterHealthStatus ensureYellowAndNoInitializingShards(String... indices)
      Ensures the cluster has a yellow state via the cluster health API and ensures the that cluster has no initializing shards for the given indices
    • waitForRelocation

      public org.opensearch.cluster.health.ClusterHealthStatus waitForRelocation()
      Waits for all relocating shards to become active using the cluster health API.
    • waitForRelocation

      public org.opensearch.cluster.health.ClusterHealthStatus waitForRelocation(org.opensearch.cluster.health.ClusterHealthStatus status)
      Waits for all relocating shards to become active and the cluster has reached the given health status using the cluster health API.
    • waitForDocs

      public void waitForDocs(long numDocs, BackgroundIndexer indexer) throws Exception
      Waits until at least a give number of document is visible for searchers
      Parameters:
      numDocs - number of documents to wait for
      indexer - a BackgroundIndexer. It will be first checked for documents indexed. This saves on unneeded searches.
      Throws:
      Exception
    • waitForIndexed

      public void waitForIndexed(long numDocs, BackgroundIndexer indexer) throws Exception
      Waits until at least a give number of document is indexed by indexer
      Parameters:
      numDocs - number of documents to wait for
      indexer - a BackgroundIndexer. It will be first checked for documents indexed. This saves on unneeded searches.
      Throws:
      Exception
    • logClusterState

      public void logClusterState()
      Prints the current cluster state as debug logging.
    • ensureClusterSizeConsistency

      protected void ensureClusterSizeConsistency()
    • ensureClusterStateConsistency

      protected void ensureClusterStateConsistency() throws IOException
      Verifies that all nodes that have the same version of the cluster state as cluster-manager have same cluster state
      Throws:
      IOException
    • ensureClusterStateCanBeReadByNodeTool

      protected void ensureClusterStateCanBeReadByNodeTool() throws IOException
      Throws:
      IOException
    • ensureSearchable

      protected org.opensearch.cluster.health.ClusterHealthStatus ensureSearchable(String... indices)
      Ensures the cluster is in a searchable state for the given indices. This means a searchable copy of each shard is available on the cluster.
    • ensureStableCluster

      protected void ensureStableCluster(int nodeCount)
    • ensureStableCluster

      protected void ensureStableCluster(int nodeCount, org.opensearch.common.unit.TimeValue timeValue)
    • ensureStableCluster

      protected void ensureStableCluster(int nodeCount, @Nullable String viaNode)
    • ensureStableCluster

      protected void ensureStableCluster(int nodeCount, org.opensearch.common.unit.TimeValue timeValue, boolean local, @Nullable String viaNode)
    • ensureFullyConnectedCluster

      protected void ensureFullyConnectedCluster()
      Ensures that all nodes in the cluster are connected to each other.

      Some network disruptions may leave nodes that are not the cluster-manager disconnected from each other. NodeConnectionsService will eventually reconnect but it's handy to be able to ensure this happens faster

    • index

      @Deprecated protected final org.opensearch.action.index.IndexResponse index(String index, String type, org.opensearch.core.xcontent.XContentBuilder source)
      Deprecated.
      Syntactic sugar for:
         client().prepareIndex(index, type).setSource(source).execute().actionGet();
       
    • index

      protected final org.opensearch.action.index.IndexResponse index(String index, String type, String id, Map<String,Object> source)
      Syntactic sugar for:
         client().prepareIndex(index, type).setSource(source).execute().actionGet();
       
    • index

      @Deprecated protected final org.opensearch.action.index.IndexResponse index(String index, String type, String id, org.opensearch.core.xcontent.XContentBuilder source)
      Deprecated.
      Syntactic sugar for:
         return client().prepareIndex(index, type, id).setSource(source).execute().actionGet();
       
    • index

      @Deprecated protected final org.opensearch.action.index.IndexResponse index(String index, String type, String id, Object... source)
      Deprecated.
      Syntactic sugar for:
         return client().prepareIndex(index, type, id).setSource(source).execute().actionGet();
       
    • index

      @Deprecated protected final org.opensearch.action.index.IndexResponse index(String index, String type, String id, String source)
      Deprecated.
      Syntactic sugar for:
         return client().prepareIndex(index, type, id).setSource(source).execute().actionGet();
       

      where source is a JSON String.

    • refresh

      protected final org.opensearch.action.admin.indices.refresh.RefreshResponse refresh(String... indices)
      Waits for relocations and refreshes all indices in the cluster.
      See Also:
    • flushAndRefresh

      protected final void flushAndRefresh(String... indices)
      Flushes and refreshes all indices in the cluster
    • flush

      protected final org.opensearch.action.admin.indices.flush.FlushResponse flush(String... indices)
      Flush some or all indices in the cluster.
    • forceMerge

      protected org.opensearch.action.admin.indices.forcemerge.ForceMergeResponse forceMerge()
      Waits for all relocations and force merge all indices in the cluster to 1 segment.
    • forceMerge

      protected org.opensearch.action.admin.indices.forcemerge.ForceMergeResponse forceMerge(int maxNumSegments)
    • indexExists

      protected static boolean indexExists(String index)
      Returns true iff the given index exists otherwise false
    • enableAllocation

      protected final void enableAllocation(String... indices)
      Syntactic sugar for enabling allocation for indices
    • disableAllocation

      protected final void disableAllocation(String... indices)
      Syntactic sugar for disabling allocation for indices
    • admin

      protected org.opensearch.transport.client.AdminClient admin()
      Returns a random admin client. This client can be a node pointing to any of the nodes in the cluster.
    • clusterAdmin

      protected org.opensearch.transport.client.ClusterAdminClient clusterAdmin()
      Returns a random cluster admin client. This client can be pointing to any of the nodes in the cluster.
    • indexRandom

      public void indexRandom(boolean forceRefresh, org.opensearch.action.index.IndexRequestBuilder... builders) throws InterruptedException
      Convenience method that forwards to indexRandom(boolean, List).
      Throws:
      InterruptedException
    • indexRandom

      public void indexRandom(boolean forceRefresh, boolean dummyDocuments, org.opensearch.action.index.IndexRequestBuilder... builders) throws InterruptedException
      Throws:
      InterruptedException
    • indexRandom

      public void indexRandom(boolean forceRefresh, List<org.opensearch.action.index.IndexRequestBuilder> builders) throws InterruptedException
      Indexes the given IndexRequestBuilder instances randomly. It shuffles the given builders and either indexes them in a blocking or async fashion. This is very useful to catch problems that relate to internal document ids or index segment creations. Some features might have bug when a given document is the first or the last in a segment or if only one document is in a segment etc. This method prevents issues like this by randomizing the index layout.
      Parameters:
      forceRefresh - if true all involved indices are refreshed once the documents are indexed. Additionally if true some empty dummy documents are may be randomly inserted into the document list and deleted once all documents are indexed. This is useful to produce deleted documents on the server side.
      builders - the documents to index.
      Throws:
      InterruptedException
      See Also:
    • indexRandom

      public void indexRandom(boolean forceRefresh, boolean dummyDocuments, List<org.opensearch.action.index.IndexRequestBuilder> builders) throws InterruptedException
      Indexes the given IndexRequestBuilder instances randomly. It shuffles the given builders and either indexes them in a blocking or async fashion. This is very useful to catch problems that relate to internal document ids or index segment creations. Some features might have bug when a given document is the first or the last in a segment or if only one document is in a segment etc. This method prevents issues like this by randomizing the index layout.
      Parameters:
      forceRefresh - if true all involved indices are refreshed once the documents are indexed.
      dummyDocuments - if true some empty dummy documents may be randomly inserted into the document list and deleted once all documents are indexed. This is useful to produce deleted documents on the server side.
      builders - the documents to index.
      Throws:
      InterruptedException
    • indexRandom

      public void indexRandom(boolean forceRefresh, boolean dummyDocuments, boolean maybeFlush, List<org.opensearch.action.index.IndexRequestBuilder> builders) throws InterruptedException
      Indexes the given IndexRequestBuilder instances randomly. It shuffles the given builders and either indexes them in a blocking or async fashion. This is very useful to catch problems that relate to internal document ids or index segment creations. Some features might have bug when a given document is the first or the last in a segment or if only one document is in a segment etc. This method prevents issues like this by randomizing the index layout.
      Parameters:
      forceRefresh - if true all involved indices are refreshed once the documents are indexed.
      dummyDocuments - if true some empty dummy documents may be randomly inserted into the document list and deleted once all documents are indexed. This is useful to produce deleted documents on the server side.
      maybeFlush - if true this method may randomly execute full flushes after index operations.
      builders - the documents to index.
      Throws:
      InterruptedException
    • indexRandomForMultipleSlices

      protected void indexRandomForMultipleSlices(String... indices) throws InterruptedException
      Throws:
      InterruptedException
    • disableIndexBlock

      public static void disableIndexBlock(String index, String block)
      Disables an index block for the specified index
    • enableIndexBlock

      public static void enableIndexBlock(String index, String block)
      Enables an index block for the specified index
    • setClusterReadOnly

      public static void setClusterReadOnly(boolean value)
      Sets or unsets the cluster read_only mode
    • clearScroll

      public void clearScroll(String... scrollIds)
      Clears the given scroll Ids
    • nodeSettings

      protected org.opensearch.common.settings.Settings nodeSettings(int nodeOrdinal)
      This method is used to obtain settings for the Nth node in the cluster. Nodes in this cluster are associated with an ordinal number such that nodes can be started with specific configurations. This method might be called multiple times with the same ordinal and is expected to return the same value for each invocation. In other words subclasses must ensure this method is idempotent.
    • useRandomReplicationStrategy

      protected boolean useRandomReplicationStrategy()
      Used for selecting random replication strategy, either DOCUMENT or SEGMENT. This method must be overridden by subclass to use random replication strategy. Should be used only on test classes where replication strategy is not critical for tests.
    • nodeConfigPath

      protected Path nodeConfigPath(int nodeOrdinal)
    • nodePlugins

      protected Collection<Class<? extends org.opensearch.plugins.Plugin>> nodePlugins()
      Returns a collection of plugins that should be loaded on each node.
    • additionalNodePlugins

      protected Collection<org.opensearch.plugins.PluginInfo> additionalNodePlugins()
      Returns a collection of plugins that should be loaded on each node.
    • externalClusterClientSettings

      protected org.opensearch.common.settings.Settings externalClusterClientSettings()
    • ignoreExternalCluster

      protected boolean ignoreExternalCluster()
    • buildTestCluster

      protected TestCluster buildTestCluster(OpenSearchIntegTestCase.Scope scope, long seed) throws IOException
      Throws:
      IOException
    • addMockTransportService

      protected boolean addMockTransportService()
      Iff this returns true mock transport implementations are used for the test runs. Otherwise not mock transport impls are used. The default is true.
    • addMockIndexStorePlugin

      protected boolean addMockIndexStorePlugin()
    • addMockHttpTransport

      protected boolean addMockHttpTransport()
      Returns true iff this test cluster should use a dummy http transport
    • addMockInternalEngine

      protected boolean addMockInternalEngine()
      Returns true if this test cluster can use a mock internal engine. Defaults to true.
    • addMockGeoShapeFieldMapper

      protected boolean addMockGeoShapeFieldMapper()
      Returns true iff this test cluster should use a dummy geo_shape field mapper
    • addMockTelemetryPlugin

      protected boolean addMockTelemetryPlugin()
      Returns true if this test cluster should have tracing enabled with MockTelemetryPlugin Disabling this for now as the existing way of strict check do not support multiple nodes internal cluster.
      Returns:
      boolean.
    • getClientWrapper

      protected Function<org.opensearch.transport.client.Client, org.opensearch.transport.client.Client> getClientWrapper()
      Returns a function that allows to wrap / filter all clients that are exposed by the test cluster. This is useful for debugging or request / response pre and post processing. It also allows to intercept all calls done by the test framework. By default this method returns an identity function Function.identity().
    • getMockPlugins

      protected Collection<Class<? extends org.opensearch.plugins.Plugin>> getMockPlugins()
      Return the mock plugins the cluster should use
    • randomRepoPath

      public Path randomRepoPath()
      Returns path to a random directory that can be used to create a temporary file system repo
    • randomRepoPath

      public static Path randomRepoPath(org.opensearch.common.settings.Settings settings)
      Returns path to a random directory that can be used to create a temporary file system repo
    • getNumShards

      protected OpenSearchIntegTestCase.NumShards getNumShards(String index)
    • assertAllShardsOnNodes

      public Set<String> assertAllShardsOnNodes(String index, String... pattern)
      Asserts that all shards are allocated on nodes matching the given node pattern.
    • assertSortedSegments

      public void assertSortedSegments(String indexName, org.apache.lucene.search.Sort expectedIndexSort)
      Asserts that all segments are sorted with the provided Sort.
    • afterClass

      public static void afterClass() throws Exception
      Throws:
      Exception
    • routingKeyForShard

      protected String routingKeyForShard(String index, int shard)
      Compute a routing key that will route documents to the shard-th shard of the provided index.
    • xContentRegistry

      protected org.opensearch.core.xcontent.NamedXContentRegistry xContentRegistry()
      Description copied from class: OpenSearchTestCase
      The NamedXContentRegistry to use for this test. Subclasses should override and use liberally.
      Overrides:
      xContentRegistry in class OpenSearchTestCase
    • forbidPrivateIndexSettings

      protected boolean forbidPrivateIndexSettings()
    • getRestClient

      protected static org.opensearch.client.RestClient getRestClient()
      Returns an instance of RestClient pointing to the current test cluster. Creates a new client if the method is invoked for the first time in the context of the current test scope. The returned client gets automatically closed when needed, it shouldn't be closed as part of tests otherwise it cannot be reused by other tests anymore.
    • setupSuiteScopeCluster

      protected void setupSuiteScopeCluster() throws Exception
      This method is executed iff the test is annotated with OpenSearchIntegTestCase.SuiteScopeTestCase before the first test of this class is executed.
      Throws:
      Exception
      See Also:
    • resolveIndex

      public static org.opensearch.core.index.Index resolveIndex(String index)
    • resolveCustomDataPath

      public static String resolveCustomDataPath(String index)
    • willSufferDebian8MemoryProblem

      protected boolean willSufferDebian8MemoryProblem()
      On Debian 8 the "memory" subsystem is not mounted by default when cgroups are enabled, and this confuses many versions of Java prior to Java 15. Tests that rely on machine memory being accurately determined will not work on such setups, and can use this method for selective muting. See https://github.com/elastic/elasticsearch/issues/67089 and https://github.com/elastic/elasticsearch/issues/66885
    • manageReplicaBalanceSetting

      public void manageReplicaBalanceSetting(boolean apply)
    • manageReplicaSettingForDefaultReplica

      public void manageReplicaSettingForDefaultReplica(boolean apply)
    • primaryNodeName

      protected String primaryNodeName(String indexName)
    • primaryNodeName

      protected String primaryNodeName(String indexName, int shardId)
    • replicaNodeName

      protected String replicaNodeName(String indexName)
    • getClusterState

      protected org.opensearch.cluster.ClusterState getClusterState()
    • refreshAndWaitForReplication

      protected org.opensearch.action.admin.indices.refresh.RefreshResponse refreshAndWaitForReplication(String... indices)
      Refreshes the indices in the cluster and waits until active/started replica shards are caught up with primary shard only when Segment Replication is enabled. This doesn't wait for inactive/non-started replica shards to become active/started.
    • isMigratingToRemoteStore

      public boolean isMigratingToRemoteStore()
    • waitForReplication

      protected void waitForReplication(String... indices)
      Waits until active/started replica shards are caught up with primary shard only when Segment Replication is enabled. This doesn't wait for inactive/non-started replica shards to become active/started.
    • isSegmentReplicationEnabledForIndex

      protected boolean isSegmentReplicationEnabledForIndex(String index)
      Checks if Segment Replication is enabled on Index.
    • getIndexShard

      protected org.opensearch.index.shard.IndexShard getIndexShard(org.opensearch.cluster.routing.ShardRouting routing, String indexName)
    • getIndexShard

      protected org.opensearch.index.shard.IndexShard getIndexShard(String node, org.opensearch.core.index.shard.ShardId shardId, String indexName)
      Fetch IndexShard by shardId, multiple shards per node allowed.
    • getLatestSegmentInfoVersion

      protected long getLatestSegmentInfoVersion(org.opensearch.index.shard.IndexShard shard)
      Fetch latest segment info snapshot version of an index.
    • createRepository

      protected void createRepository(String repoName, String type, org.opensearch.common.settings.Settings.Builder settings, String timeout)
    • createRepository

      protected void createRepository(String repoName, String type, org.opensearch.common.settings.Settings.Builder settings)
    • updateRepository

      protected void updateRepository(String repoName, String type, org.opensearch.common.settings.Settings.Builder settings)
    • getNodeSettings

      public org.opensearch.common.settings.Settings getNodeSettings()
    • putRepository

      public static void putRepository(org.opensearch.transport.client.ClusterAdminClient adminClient, String repoName, String type, org.opensearch.common.settings.Settings.Builder settings)
    • putRepository

      public static void putRepository(org.opensearch.transport.client.ClusterAdminClient adminClient, String repoName, String type, String timeout, org.opensearch.common.settings.Settings.Builder settings)
    • putRepository

      public static void putRepository(org.opensearch.transport.client.ClusterAdminClient adminClient, String repoName, String type, boolean verify, org.opensearch.common.settings.Settings.Builder settings)
    • putRepositoryWithNoSettingOverrides

      public static void putRepositoryWithNoSettingOverrides(org.opensearch.transport.client.ClusterAdminClient adminClient, String repoName, String type, boolean verify, org.opensearch.common.settings.Settings.Builder settings)
    • putRepository

      public static void putRepository(org.opensearch.transport.client.ClusterAdminClient adminClient, String repoName, String type, org.opensearch.common.settings.Settings.Builder settings, org.opensearch.core.action.ActionListener<org.opensearch.action.support.clustermanager.AcknowledgedResponse> listener)
    • putRepositoryRequestBuilder

      public static org.opensearch.action.admin.cluster.repositories.put.PutRepositoryRequestBuilder putRepositoryRequestBuilder(org.opensearch.transport.client.ClusterAdminClient adminClient, String repoName, String type, boolean verify, org.opensearch.common.settings.Settings.Builder settings, String timeout, boolean finalSettings)
    • remoteStoreClusterSettings

      public static org.opensearch.common.settings.Settings remoteStoreClusterSettings(String name, Path path)
    • remoteStoreClusterSettings

      public static org.opensearch.common.settings.Settings remoteStoreClusterSettings(String segmentRepoName, Path segmentRepoPath, String segmentRepoType, String translogRepoName, Path translogRepoPath, String translogRepoType)
    • remoteStoreClusterSettings

      public static org.opensearch.common.settings.Settings remoteStoreClusterSettings(String segmentRepoName, Path segmentRepoPath, String segmentRepoType, String translogRepoName, Path translogRepoPath, String translogRepoType, String routingTableRepoName, Path routingTableRepoPath, String routingTableRepoType)
    • remoteStoreClusterSettings

      public static org.opensearch.common.settings.Settings remoteStoreClusterSettings(String segmentRepoName, Path segmentRepoPath, String translogRepoName, Path translogRepoPath)
    • remoteStoreClusterSettings

      public static org.opensearch.common.settings.Settings remoteStoreClusterSettings(String segmentRepoName, Path segmentRepoPath, String translogRepoName, Path translogRepoPath, String remoteRoutingTableRepoName, Path remoteRoutingTableRepoPath)
    • buildRemoteStoreNodeAttributes

      public static org.opensearch.common.settings.Settings buildRemoteStoreNodeAttributes(String segmentRepoName, Path segmentRepoPath, String translogRepoName, Path translogRepoPath, boolean withRateLimiterAttributes)
    • buildRemoteStoreNodeAttributes

      public static org.opensearch.common.settings.Settings buildRemoteStoreNodeAttributes(String segmentRepoName, Path segmentRepoPath, String translogRepoName, Path translogRepoPath, String remoteRoutingTableRepoName, Path remoteRoutingTableRepoPath, boolean withRateLimiterAttributes)
    • buildRemoteStateNodeAttributes

      public static org.opensearch.common.settings.Settings buildRemoteStateNodeAttributes(String stateRepoName, Path stateRepoPath, String stateRepoType)
    • buildRemoteStoreNodeAttributes

      protected static org.opensearch.common.settings.Settings buildRemoteStoreNodeAttributes(String segmentRepoName, Path segmentRepoPath, String segmentRepoType, String translogRepoName, Path translogRepoPath, String translogRepoType, String routingTableRepoName, Path routingTableRepoPath, String routingTableRepoType, boolean withRateLimiterAttributes)
    • buildRemotePublicationNodeAttributes

      protected org.opensearch.common.settings.Settings buildRemotePublicationNodeAttributes(@NonNull String remoteStateRepoName, @NonNull String remoteStateRepoType, @NonNull String routingTableRepoName, @NonNull String routingTableRepoType)
    • resolvePath

      public static String resolvePath(org.opensearch.repositories.IndexId indexId, String shardId)