@@ -37,7 +37,7 @@ namespace Tests.XPack.DataStreams
3737 [ SkipVersion ( "<7.9.0" , "Introduced in 7.9.0" ) ]
3838 public class DataStreamsApiTests : CoordinatedIntegrationTestBase < WritableCluster >
3939 {
40- private static readonly Metric Document = new Metric
40+ private static readonly Metric Document = new ( )
4141 {
4242 Timestamp = new DateTime ( 2020 , 8 , 3 , 14 , 0 , 0 , DateTimeKind . Utc ) ,
4343 Accept = 3 ,
@@ -47,13 +47,16 @@ public class DataStreamsApiTests : CoordinatedIntegrationTestBase<WritableCluste
4747 Response = 300 ,
4848 Total = 3
4949 } ;
50-
50+
5151 private const string CreateDataStreamStep = nameof ( CreateDataStreamStep ) ;
5252 private const string IndexStep = nameof ( IndexStep ) ;
5353 private const string GetDataStreamStep = nameof ( GetDataStreamStep ) ;
5454 private const string PutIndexTemplateStep = nameof ( PutIndexTemplateStep ) ;
5555 private const string DataStreamsStatsStep = nameof ( DataStreamsStatsStep ) ;
5656 private const string DeleteDataStreamStep = nameof ( DeleteDataStreamStep ) ;
57+ private const string PrepareIndexStep = nameof ( PrepareIndexStep ) ;
58+ private const string PrepareAliasStep = nameof ( PrepareAliasStep ) ;
59+ private const string MigrateToDataStreamStep = nameof ( MigrateToDataStreamStep ) ;
5760
5861 public DataStreamsApiTests ( WritableCluster cluster , EndpointUsage usage ) : base ( new CoordinatedUsage ( cluster , usage , testOnlyOne : true )
5962 {
@@ -109,10 +112,10 @@ public DataStreamsApiTests(WritableCluster cluster, EndpointUsage usage) : base(
109112 Refresh = Refresh . WaitFor
110113 } ,
111114 ( v , d ) => d . Index ( v ) . Refresh ( Refresh . WaitFor ) ,
112- ( v , c , f ) => c . Index < Metric > ( Document , f ) ,
113- ( v , c , f ) => c . IndexAsync < Metric > ( Document , f ) ,
114- ( v , c , r ) => c . Index < Metric > ( r ) ,
115- ( v , c , r ) => c . IndexAsync < Metric > ( r )
115+ ( v , c , f ) => c . Index ( Document , f ) ,
116+ ( v , c , f ) => c . IndexAsync ( Document , f ) ,
117+ ( v , c , r ) => c . Index ( r ) ,
118+ ( v , c , r ) => c . IndexAsync ( r )
116119 )
117120 } ,
118121 { GetDataStreamStep , u =>
@@ -145,6 +148,48 @@ public DataStreamsApiTests(WritableCluster cluster, EndpointUsage usage) : base(
145148 ( v , c , r ) => c . Indices . DeleteDataStreamAsync ( r )
146149 )
147150 } ,
151+ // Used for migrate step
152+ { PrepareIndexStep , ">= 7.13.0" , u =>
153+ u . Calls < CreateIndexDescriptor , CreateIndexRequest , ICreateIndexRequest , CreateIndexResponse > (
154+ v => new CreateIndexRequest ( $ "my-index{ v } -test")
155+ {
156+ Mappings = new TypeMapping
157+ {
158+ Properties = new Properties
159+ {
160+ { "@timestamp" , new DateNanosProperty ( ) }
161+ }
162+ }
163+ } ,
164+ ( v , d ) => d . Map ( m=> m . Properties ( p=> p . DateNanos ( dn => dn . Name ( "@timestamp" ) ) ) ) ,
165+ ( v , c , f ) => c . Indices . Create ( $ "my-index{ v } -test", f ) ,
166+ ( v , c , f ) => c . Indices . CreateAsync ( $ "my-index{ v } -test", f ) ,
167+ ( v , c , r ) => c . Indices . Create ( r ) ,
168+ ( v , c , r ) => c . Indices . CreateAsync ( r )
169+ )
170+ } ,
171+ // Used for migrate step
172+ { PrepareAliasStep , ">= 7.13.0" , u =>
173+ u . Calls < PutAliasDescriptor , PutAliasRequest , IPutAliasRequest , PutAliasResponse > (
174+ v => new PutAliasRequest ( $ "my-index{ v } -test", $ "{ v } -alias") ,
175+ ( v , d ) => d ,
176+ ( v , c , f ) => c . Indices . PutAlias ( $ "my-index{ v } -test", $ "{ v } -alias", f ) ,
177+ ( v , c , f ) => c . Indices . PutAliasAsync ( $ "my-index{ v } -test", $ "{ v } -alias", f ) ,
178+ ( v , c , r ) => c . Indices . PutAlias ( r ) ,
179+ ( v , c , r ) => c . Indices . PutAliasAsync ( r )
180+ )
181+ } ,
182+ // Migrate to data stream added in 7.13.0
183+ { MigrateToDataStreamStep , ">= 7.13.0" , u =>
184+ u . Calls < MigrateToDataStreamDescriptor , MigrateToDataStreamRequest , IMigrateToDataStreamRequest , MigrateToDataStreamResponse > (
185+ v => new MigrateToDataStreamRequest ( $ "{ v } -alias") ,
186+ ( v , d ) => d ,
187+ ( v , c , f ) => c . Indices . MigrateToDataStream ( $ "{ v } -alias", f ) ,
188+ ( v , c , f ) => c . Indices . MigrateToDataStreamAsync ( $ "{ v } -alias", f ) ,
189+ ( v , c , r ) => c . Indices . MigrateToDataStream ( r ) ,
190+ ( v , c , r ) => c . Indices . MigrateToDataStreamAsync ( r )
191+ )
192+ } ,
148193 } ) { }
149194
150195 [ I ] public async Task CreateDataStreamResponse ( ) => await Assert < CreateDataStreamResponse > ( CreateDataStreamStep , ( v , r ) =>
@@ -199,5 +244,11 @@ [I] public async Task DeleteDataStreamResponse() => await Assert<DeleteDataStrea
199244 r . ShouldBeValid ( ) ;
200245 r . Acknowledged . Should ( ) . BeTrue ( ) ;
201246 } ) ;
247+
248+ [ I ] public async Task MigrateToDataStreamResponse ( ) => await Assert < MigrateToDataStreamResponse > ( MigrateToDataStreamStep , r =>
249+ {
250+ r . ShouldBeValid ( ) ;
251+ r . Acknowledged . Should ( ) . BeTrue ( ) ;
252+ } ) ;
202253 }
203254}
0 commit comments