Class AbstractSnapshotIntegTestCase

java.lang.Object
org.junit.Assert
org.apache.lucene.util.LuceneTestCase
org.elasticsearch.test.ESTestCase
org.elasticsearch.test.ESIntegTestCase
org.elasticsearch.snapshots.AbstractSnapshotIntegTestCase

public abstract class AbstractSnapshotIntegTestCase extends ESIntegTestCase
  • Field Details

    • RANDOM_SNAPSHOT_NAME_PREFIX

      public static final String RANDOM_SNAPSHOT_NAME_PREFIX
      See Also:
    • OLD_VERSION_SNAPSHOT_PREFIX

      public static final String OLD_VERSION_SNAPSHOT_PREFIX
      See Also:
    • LARGE_SNAPSHOT_POOL_SETTINGS

      protected static final org.elasticsearch.common.settings.Settings LARGE_SNAPSHOT_POOL_SETTINGS
    • SINGLE_SHARD_NO_REPLICA

      public static final org.elasticsearch.common.settings.Settings SINGLE_SHARD_NO_REPLICA
  • Constructor Details

    • AbstractSnapshotIntegTestCase

      public AbstractSnapshotIntegTestCase()
  • Method Details

    • nodeSettings

      protected org.elasticsearch.common.settings.Settings nodeSettings(int nodeOrdinal, org.elasticsearch.common.settings.Settings otherSettings)
      Description copied from class: ESIntegTestCase
      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.
      Overrides:
      nodeSettings in class ESIntegTestCase
    • nodePlugins

      protected Collection<Class<? extends org.elasticsearch.plugins.Plugin>> nodePlugins()
      Description copied from class: ESIntegTestCase
      Returns a collection of plugins that should be loaded on each node.
      Overrides:
      nodePlugins in class ESIntegTestCase
    • assertConsistentHistoryInLuceneIndex

      public void assertConsistentHistoryInLuceneIndex() throws Exception
      Throws:
      Exception
    • verifyNoLeakedListeners

      public void verifyNoLeakedListeners() throws Exception
      Throws:
      Exception
    • assertRepoConsistency

      public void assertRepoConsistency()
    • disableRepoConsistencyCheck

      protected void disableRepoConsistencyCheck(String reason)
    • getRepositoryData

      protected org.elasticsearch.repositories.RepositoryData getRepositoryData(String repoName, org.elasticsearch.Version version)
    • getRepositoryData

      protected org.elasticsearch.repositories.RepositoryData getRepositoryData(String repository)
    • getRepositoryData

      protected org.elasticsearch.repositories.RepositoryData getRepositoryData(org.elasticsearch.repositories.Repository repository)
    • getFailureCount

      public static long getFailureCount(String repository)
    • assertFileCount

      public static void assertFileCount(Path dir, int expectedCount) throws IOException
      Throws:
      IOException
    • numberOfFiles

      public static int numberOfFiles(Path dir) throws IOException
      Throws:
      IOException
    • stopNode

      protected void stopNode(String node) throws IOException
      Throws:
      IOException
    • startDataNodeWithLargeSnapshotPool

      protected static String startDataNodeWithLargeSnapshotPool()
    • waitForBlock

      public void waitForBlock(String node, String repository) throws Exception
      Throws:
      Exception
    • blockMasterFromFinalizingSnapshotOnIndexFile

      public static void blockMasterFromFinalizingSnapshotOnIndexFile(String repositoryName)
    • blockMasterOnWriteIndexFile

      public static void blockMasterOnWriteIndexFile(String repositoryName)
    • blockMasterFromDeletingIndexNFile

      public static void blockMasterFromDeletingIndexNFile(String repositoryName)
    • blockMasterFromFinalizingSnapshotOnSnapFile

      public static void blockMasterFromFinalizingSnapshotOnSnapFile(String repositoryName)
    • blockMasterOnAnyDataFile

      public static void blockMasterOnAnyDataFile(String repositoryName)
    • blockMasterOnShardLevelSnapshotFile

      public static void blockMasterOnShardLevelSnapshotFile(String repositoryName, String indexId)
    • getRepositoryOnMaster

      public static <T extends org.elasticsearch.repositories.Repository> T getRepositoryOnMaster(String repositoryName)
    • getRepositoryOnNode

      protected static <T extends org.elasticsearch.repositories.Repository> T getRepositoryOnNode(String repositoryName, String nodeName)
    • blockNodeWithIndex

      public static String blockNodeWithIndex(String repositoryName, String indexName)
    • blockNodeOnAnyFiles

      public static void blockNodeOnAnyFiles(String repository, String nodeName)
    • blockDataNode

      public static void blockDataNode(String repository, String nodeName)
    • blockAndFailDataNode

      public static void blockAndFailDataNode(String repository, String nodeName)
    • blockAllDataNodes

      public static void blockAllDataNodes(String repository)
    • unblockAllDataNodes

      public static void unblockAllDataNodes(String repository)
    • failReadsAllDataNodes

      public static void failReadsAllDataNodes(String repository)
    • waitForBlockOnAnyDataNode

      public static void waitForBlockOnAnyDataNode(String repository) throws InterruptedException
      Throws:
      InterruptedException
    • unblockNode

      public void unblockNode(String repository, String node)
    • createRepository

      protected void createRepository(String repoName, String type, org.elasticsearch.common.settings.Settings.Builder settings, boolean verify)
    • createRepository

      public static void createRepository(org.apache.logging.log4j.Logger logger, String repoName, String type, org.elasticsearch.common.settings.Settings.Builder settings, boolean verify)
    • createRepository

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

      protected void createRepository(String repoName, String type, Path location)
    • createRepository

      protected void createRepository(String repoName, String type)
    • createRepositoryNoVerify

      protected void createRepositoryNoVerify(String repoName, String type)
    • createRepository

      public static void createRepository(org.apache.logging.log4j.Logger logger, String repoName, String type)
    • randomRepositorySettings

      public static org.elasticsearch.common.settings.Settings.Builder randomRepositorySettings()
    • indexSettingsNoReplicas

      protected static org.elasticsearch.common.settings.Settings.Builder indexSettingsNoReplicas(int shards)
    • maybeInitWithOldSnapshotVersion

      protected void maybeInitWithOldSnapshotVersion(String repoName, Path repoPath) throws Exception
      Randomly write an empty snapshot of an older version to an empty repository to simulate an older repository metadata format.
      Throws:
      Exception
    • initWithSnapshotVersion

      protected String initWithSnapshotVersion(String repoName, Path repoPath, org.elasticsearch.Version version) throws Exception
      Workaround to simulate BwC situation: taking a snapshot without indices here so that we don't create any new version shard generations (the existence of which would short-circuit checks for the repo containing old version snapshots)
      Throws:
      Exception
    • createFullSnapshot

      protected org.elasticsearch.snapshots.SnapshotInfo createFullSnapshot(String repoName, String snapshotName)
    • createFullSnapshot

      public static org.elasticsearch.snapshots.SnapshotInfo createFullSnapshot(org.apache.logging.log4j.Logger logger, String repoName, String snapshotName)
    • createSnapshot

      protected org.elasticsearch.snapshots.SnapshotInfo createSnapshot(String repositoryName, String snapshot, List<String> indices, List<String> featureStates)
    • createSnapshot

      protected org.elasticsearch.snapshots.SnapshotInfo createSnapshot(String repositoryName, String snapshot, List<String> indices)
    • createIndexWithRandomDocs

      protected void createIndexWithRandomDocs(String indexName, int docCount) throws InterruptedException
      Throws:
      InterruptedException
    • indexRandomDocs

      protected void indexRandomDocs(String index, int numdocs) throws InterruptedException
      Throws:
      InterruptedException
    • getCountForIndex

      protected long getCountForIndex(String indexName)
    • assertDocCount

      protected void assertDocCount(String index, long count)
    • addBwCFailedSnapshot

      protected void addBwCFailedSnapshot(String repoName, String snapshotName, Map<String,Object> metadata) throws Exception
      Adds a snapshot in state SnapshotState.FAILED to the given repository.
      Parameters:
      repoName - repository to add snapshot to
      snapshotName - name for the new failed snapshot
      metadata - snapshot metadata to write (as returned by SnapshotInfo.userMetadata())
      Throws:
      Exception
    • awaitNDeletionsInProgress

      protected void awaitNDeletionsInProgress(int count) throws Exception
      Throws:
      Exception
    • awaitNoMoreRunningOperations

      protected void awaitNoMoreRunningOperations() throws Exception
      Throws:
      Exception
    • awaitNoMoreRunningOperations

      protected void awaitNoMoreRunningOperations(String viaNode) throws Exception
      Throws:
      Exception
    • awaitClusterState

      protected void awaitClusterState(Predicate<org.elasticsearch.cluster.ClusterState> statePredicate) throws Exception
      Throws:
      Exception
    • awaitClusterState

      public static void awaitClusterState(org.apache.logging.log4j.Logger logger, Predicate<org.elasticsearch.cluster.ClusterState> statePredicate) throws Exception
      Throws:
      Exception
    • awaitClusterState

      public static void awaitClusterState(org.apache.logging.log4j.Logger logger, String viaNode, Predicate<org.elasticsearch.cluster.ClusterState> statePredicate) throws Exception
      Throws:
      Exception
    • startFullSnapshotBlockedOnDataNode

      protected org.elasticsearch.action.ActionFuture<org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse> startFullSnapshotBlockedOnDataNode(String snapshotName, String repoName, String dataNode) throws Exception
      Throws:
      Exception
    • startFullSnapshot

      protected org.elasticsearch.action.ActionFuture<org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse> startFullSnapshot(String repoName, String snapshotName)
    • startFullSnapshot

      protected org.elasticsearch.action.ActionFuture<org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse> startFullSnapshot(String repoName, String snapshotName, boolean partial)
    • startFullSnapshot

      public static org.elasticsearch.action.ActionFuture<org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse> startFullSnapshot(org.apache.logging.log4j.Logger logger, String repoName, String snapshotName, boolean partial)
    • awaitNumberOfSnapshotsInProgress

      protected void awaitNumberOfSnapshotsInProgress(int count) throws Exception
      Throws:
      Exception
    • awaitNumberOfSnapshotsInProgress

      public static void awaitNumberOfSnapshotsInProgress(org.apache.logging.log4j.Logger logger, int count) throws Exception
      Throws:
      Exception
    • assertSuccessful

      protected org.elasticsearch.snapshots.SnapshotInfo assertSuccessful(org.elasticsearch.action.ActionFuture<org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse> future) throws Exception
      Throws:
      Exception
    • assertSuccessful

      public static org.elasticsearch.snapshots.SnapshotInfo assertSuccessful(org.apache.logging.log4j.Logger logger, org.elasticsearch.action.ActionFuture<org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse> future) throws Exception
      Throws:
      Exception
    • createIndexWithContent

      protected void createIndexWithContent(String indexName)
    • createIndexWithContent

      protected void createIndexWithContent(String indexName, org.elasticsearch.common.settings.Settings indexSettings)
    • startDeleteSnapshot

      protected org.elasticsearch.action.ActionFuture<org.elasticsearch.action.support.master.AcknowledgedResponse> startDeleteSnapshot(String repoName, String snapshotName)
    • startDeleteSnapshots

      protected org.elasticsearch.action.ActionFuture<org.elasticsearch.action.support.master.AcknowledgedResponse> startDeleteSnapshots(String repoName, List<String> snapshotNames, String viaNode)
    • updateClusterState

      protected static void updateClusterState(Function<org.elasticsearch.cluster.ClusterState,org.elasticsearch.cluster.ClusterState> updater) throws Exception
      Throws:
      Exception
    • getSnapshot

      protected org.elasticsearch.snapshots.SnapshotInfo getSnapshot(String repository, String snapshot)
    • snapshotThreadPoolStats

      protected static org.elasticsearch.threadpool.ThreadPoolStats.Stats snapshotThreadPoolStats(String node)
    • awaitMasterFinishRepoOperations

      protected void awaitMasterFinishRepoOperations() throws Exception
      Throws:
      Exception
    • createNSnapshots

      protected List<String> createNSnapshots(String repoName, int count) throws Exception
      Throws:
      Exception
    • createNSnapshots

      public static List<String> createNSnapshots(org.apache.logging.log4j.Logger logger, String repoName, int count) throws Exception
      Throws:
      Exception
    • forEachFileRecursively

      public static void forEachFileRecursively(Path path, org.elasticsearch.common.CheckedBiConsumer<Path,BasicFileAttributes,IOException> forEach) throws IOException
      Throws:
      IOException
    • assertSnapshotListSorted

      public static void assertSnapshotListSorted(List<org.elasticsearch.snapshots.SnapshotInfo> snapshotInfos, @Nullable org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsRequest.SortBy sort, org.elasticsearch.search.sort.SortOrder sortOrder)
    • randomUserMetadata

      @Nullable public static Map<String,Object> randomUserMetadata()
      Randomly either generates some random snapshot user metadata or returns null.
      Returns:
      random snapshot user metadata or null
    • matchAllPattern

      public static String[] matchAllPattern()