Class DataStreamTestHelper

java.lang.Object
org.elasticsearch.cluster.metadata.DataStreamTestHelper

public final class DataStreamTestHelper extends Object
  • Constructor Details

    • DataStreamTestHelper

      public DataStreamTestHelper()
  • Method Details

    • newInstance

      public static DataStream newInstance(String name, List<Index> indices)
    • newInstance

      public static DataStream newInstance(String name, List<Index> indices, List<Index> failureIndices)
    • newInstance

      public static DataStream newInstance(String name, List<Index> indices, long generation, Map<String,Object> metadata)
    • newInstance

      public static DataStream newInstance(String name, List<Index> indices, long generation, Map<String,Object> metadata, boolean replicated)
    • newInstance

      public static DataStream newInstance(String name, List<Index> indices, long generation, Map<String,Object> metadata, boolean replicated, @Nullable DataStreamLifecycle lifecycle)
    • newInstance

      public static DataStream newInstance(String name, List<Index> indices, long generation, Map<String,Object> metadata, boolean replicated, @Nullable DataStreamLifecycle lifecycle, @Nullable DataStreamAutoShardingEvent autoShardingEvent)
    • newInstance

      public static DataStream newInstance(String name, List<Index> indices, long generation, Map<String,Object> metadata, boolean replicated, @Nullable DataStreamLifecycle lifecycle, List<Index> failureStores)
    • newInstance

      public static DataStream newInstance(String name, List<Index> indices, long generation, Map<String,Object> metadata, boolean replicated, DataStreamLifecycle lifecycle, List<Index> failureStores, DataStreamOptions dataStreamOptions)
    • getLegacyDefaultBackingIndexName

      public static String getLegacyDefaultBackingIndexName(String dataStreamName, long generation, long epochMillis)
    • getLegacyDefaultBackingIndexName

      public static String getLegacyDefaultBackingIndexName(String dataStreamName, long generation)
    • createFirstBackingIndex

      public static IndexMetadata.Builder createFirstBackingIndex(String dataStreamName)
    • createFirstBackingIndex

      public static IndexMetadata.Builder createFirstBackingIndex(String dataStreamName, long epochMillis)
    • createBackingIndex

      public static IndexMetadata.Builder createBackingIndex(String dataStreamName, int generation)
    • createBackingIndex

      public static IndexMetadata.Builder createBackingIndex(String dataStreamName, int generation, long epochMillis)
    • createFirstFailureStore

      public static IndexMetadata.Builder createFirstFailureStore(String dataStreamName)
    • createFirstFailureStore

      public static IndexMetadata.Builder createFirstFailureStore(String dataStreamName, long epochMillis)
    • createFailureStore

      public static IndexMetadata.Builder createFailureStore(String dataStreamName, int generation)
    • createFailureStore

      public static IndexMetadata.Builder createFailureStore(String dataStreamName, int generation, long epochMillis)
    • getIndexMetadataBuilderForIndex

      public static IndexMetadata.Builder getIndexMetadataBuilderForIndex(Index index)
    • generateMapping

      public static String generateMapping(String timestampFieldName)
    • generateTsdbMapping

      public static String generateTsdbMapping()
    • generateMapping

      public static String generateMapping(String timestampFieldName, String type)
    • randomIndexInstances

      public static List<Index> randomIndexInstances()
      Returns:
      a list of random indices. NOTE: the list can be empty, if you do not want an empty list use randomNonEmptyIndexInstances()
    • randomNonEmptyIndexInstances

      public static List<Index> randomNonEmptyIndexInstances()
    • randomIndexInstances

      public static List<Index> randomIndexInstances(int min, int max)
    • randomInstance

      public static DataStream randomInstance()
    • randomInstance

      public static DataStream randomInstance(boolean failureStore)
    • randomInstance

      public static DataStream randomInstance(String name)
    • randomInstance

      public static DataStream randomInstance(LongSupplier timeProvider)
    • randomInstance

      public static DataStream randomInstance(LongSupplier timeProvider, boolean failureStore)
    • randomInstance

      public static DataStream randomInstance(String dataStreamName, LongSupplier timeProvider, boolean failureStore)
    • randomInstance

      public static DataStream randomInstance(String dataStreamName, LongSupplier timeProvider, boolean failureStore, boolean system)
    • randomAliasInstance

      public static DataStreamAlias randomAliasInstance()
    • randomGlobalRetention

      @Nullable public static DataStreamGlobalRetention randomGlobalRetention()
    • getProjectWithDataStreams

      public static ProjectMetadata getProjectWithDataStreams(List<org.elasticsearch.core.Tuple<String,Integer>> dataStreams, List<String> indexNames)
      Constructs ClusterState with the specified data streams and indices.
      Parameters:
      dataStreams - The names of the data streams to create with their respective number of backing indices
      indexNames - The names of indices to create that do not back any data streams
    • getProjectWithDataStreams

      public static ProjectMetadata getProjectWithDataStreams(List<org.elasticsearch.core.Tuple<String,Integer>> dataStreams, List<String> indexNames, long currentTime, Settings settings, int replicas)
    • getProjectWithDataStreams

      public static ProjectMetadata getProjectWithDataStreams(List<org.elasticsearch.core.Tuple<String,Integer>> dataStreams, List<String> indexNames, long currentTime, Settings settings, int replicas, boolean replicated, Boolean storeFailures)
    • getProjectWithDataStreams

      @Deprecated(forRemoval=true) public static ProjectMetadata getProjectWithDataStreams(ProjectId projectId, List<org.elasticsearch.core.Tuple<String,Integer>> dataStreams, List<String> indexNames, long currentTime, Settings settings, int replicas, boolean replicated, Boolean storeFailures)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getClusterStateWithDataStream

      @Deprecated(forRemoval=true) public static ClusterState getClusterStateWithDataStream(String dataStream, List<org.elasticsearch.core.Tuple<Instant,Instant>> timeSlices)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getClusterStateWithDataStream

      public static ClusterState getClusterStateWithDataStream(ProjectId projectId, String dataStream, List<org.elasticsearch.core.Tuple<Instant,Instant>> timeSlices)
    • getProjectWithDataStream

      public static ProjectMetadata getProjectWithDataStream(ProjectId projectId, String dataStream, List<org.elasticsearch.core.Tuple<Instant,Instant>> timeSlices)
    • getClusterStateWithDataStream

      public static void getClusterStateWithDataStream(ProjectMetadata.Builder builder, String dataStreamName, List<org.elasticsearch.core.Tuple<Instant,Instant>> timeSlices)
    • createIndexMetadata

      public static IndexMetadata createIndexMetadata(String name, boolean hidden, Settings settings, int replicas)
    • backingIndexPattern

      public static String backingIndexPattern(String dataStreamName, long generation)
    • backingIndexEqualTo

      public static org.hamcrest.Matcher<String> backingIndexEqualTo(String dataStreamName, int generation)
      Checks if the index name provided starts with the prefix ".ds-", continues with the data stream name till the next `-`, and after the last `-` it ends with a number that matches the generation.
      Parameters:
      dataStreamName -
      generation -
      Returns:
      the matcher
    • dataStreamIndexEqualTo

      public static org.hamcrest.Matcher<String> dataStreamIndexEqualTo(String dataStreamName, int generation, boolean failureStore)
      Checks if the index name provided starts with the prefix ".ds-" when failure store is false and ".fs-" when true, continues with the data stream name till the next `-`, and after the last `-` it ends with a number that matches the generation.
      Parameters:
      dataStreamName -
      generation -
      failureStore - , determines the prefix, ".ds-" when failure store is false and ".fs-" when true
      Returns:
      the matcher
    • getMetadataRolloverService

      public static MetadataRolloverService getMetadataRolloverService(DataStream dataStream, ThreadPool testThreadPool, Set<IndexSettingProvider> providers, org.elasticsearch.xcontent.NamedXContentRegistry registry, TelemetryProvider telemetryProvider) throws Exception
      Throws:
      Exception
    • getDataStreamTimestampFieldMapper

      public static MetadataFieldMapper getDataStreamTimestampFieldMapper()
    • mockIndicesServices

      public static IndicesService mockIndicesServices(MappingLookup mappingLookup) throws Exception
      Throws:
      Exception
    • createDataStreamOptionsTemplate

      public static DataStreamOptions.Template createDataStreamOptionsTemplate(Boolean failureStoreEnabled)