@@ -18,7 +18,7 @@ namespace Tests.XPack.DataStreams
1818 [ SkipVersion ( "<7.9.0" , "Introduced in 7.9.0" ) ]
1919 public class DataStreamsApiTests : CoordinatedIntegrationTestBase < WritableCluster >
2020 {
21- private static readonly Metric Document = new Metric
21+ private static readonly Metric Document = new ( )
2222 {
2323 Timestamp = new DateTime ( 2020 , 8 , 3 , 14 , 0 , 0 , DateTimeKind . Utc ) ,
2424 Accept = 3 ,
@@ -28,13 +28,16 @@ public class DataStreamsApiTests : CoordinatedIntegrationTestBase<WritableCluste
2828 Response = 300 ,
2929 Total = 3
3030 } ;
31-
31+
3232 private const string CreateDataStreamStep = nameof ( CreateDataStreamStep ) ;
3333 private const string IndexStep = nameof ( IndexStep ) ;
3434 private const string GetDataStreamStep = nameof ( GetDataStreamStep ) ;
3535 private const string PutIndexTemplateStep = nameof ( PutIndexTemplateStep ) ;
3636 private const string DataStreamsStatsStep = nameof ( DataStreamsStatsStep ) ;
3737 private const string DeleteDataStreamStep = nameof ( DeleteDataStreamStep ) ;
38+ private const string PrepareIndexStep = nameof ( PrepareIndexStep ) ;
39+ private const string PrepareAliasStep = nameof ( PrepareAliasStep ) ;
40+ private const string MigrateToDataStreamStep = nameof ( MigrateToDataStreamStep ) ;
3841
3942 public DataStreamsApiTests ( WritableCluster cluster , EndpointUsage usage ) : base ( new CoordinatedUsage ( cluster , usage , testOnlyOne : true )
4043 {
@@ -90,10 +93,10 @@ public DataStreamsApiTests(WritableCluster cluster, EndpointUsage usage) : base(
9093 Refresh = Refresh . WaitFor
9194 } ,
9295 ( v , d ) => d . Index ( v ) . Refresh ( Refresh . WaitFor ) ,
93- ( v , c , f ) => c . Index < Metric > ( Document , f ) ,
94- ( v , c , f ) => c . IndexAsync < Metric > ( Document , f ) ,
95- ( v , c , r ) => c . Index < Metric > ( r ) ,
96- ( v , c , r ) => c . IndexAsync < Metric > ( r )
96+ ( v , c , f ) => c . Index ( Document , f ) ,
97+ ( v , c , f ) => c . IndexAsync ( Document , f ) ,
98+ ( v , c , r ) => c . Index ( r ) ,
99+ ( v , c , r ) => c . IndexAsync ( r )
97100 )
98101 } ,
99102 { GetDataStreamStep , u =>
@@ -126,6 +129,48 @@ public DataStreamsApiTests(WritableCluster cluster, EndpointUsage usage) : base(
126129 ( v , c , r ) => c . Indices . DeleteDataStreamAsync ( r )
127130 )
128131 } ,
132+ // Used for migrate step
133+ { PrepareIndexStep , ">= 7.13.0" , u =>
134+ u . Calls < CreateIndexDescriptor , CreateIndexRequest , ICreateIndexRequest , CreateIndexResponse > (
135+ v => new CreateIndexRequest ( $ "my-index{ v } -test")
136+ {
137+ Mappings = new TypeMapping
138+ {
139+ Properties = new Properties
140+ {
141+ { "@timestamp" , new DateNanosProperty ( ) }
142+ }
143+ }
144+ } ,
145+ ( v , d ) => d . Map ( m=> m . Properties ( p=> p . DateNanos ( dn => dn . Name ( "@timestamp" ) ) ) ) ,
146+ ( v , c , f ) => c . Indices . Create ( $ "my-index{ v } -test", f ) ,
147+ ( v , c , f ) => c . Indices . CreateAsync ( $ "my-index{ v } -test", f ) ,
148+ ( v , c , r ) => c . Indices . Create ( r ) ,
149+ ( v , c , r ) => c . Indices . CreateAsync ( r )
150+ )
151+ } ,
152+ // Used for migrate step
153+ { PrepareAliasStep , ">= 7.13.0" , u =>
154+ u . Calls < PutAliasDescriptor , PutAliasRequest , IPutAliasRequest , PutAliasResponse > (
155+ v => new PutAliasRequest ( $ "my-index{ v } -test", $ "{ v } -alias") ,
156+ ( v , d ) => d ,
157+ ( v , c , f ) => c . Indices . PutAlias ( $ "my-index{ v } -test", $ "{ v } -alias", f ) ,
158+ ( v , c , f ) => c . Indices . PutAliasAsync ( $ "my-index{ v } -test", $ "{ v } -alias", f ) ,
159+ ( v , c , r ) => c . Indices . PutAlias ( r ) ,
160+ ( v , c , r ) => c . Indices . PutAliasAsync ( r )
161+ )
162+ } ,
163+ // Migrate to data stream added in 7.13.0
164+ { MigrateToDataStreamStep , ">= 7.13.0" , u =>
165+ u . Calls < MigrateToDataStreamDescriptor , MigrateToDataStreamRequest , IMigrateToDataStreamRequest , MigrateToDataStreamResponse > (
166+ v => new MigrateToDataStreamRequest ( $ "{ v } -alias") ,
167+ ( v , d ) => d ,
168+ ( v , c , f ) => c . Indices . MigrateToDataStream ( $ "{ v } -alias", f ) ,
169+ ( v , c , f ) => c . Indices . MigrateToDataStreamAsync ( $ "{ v } -alias", f ) ,
170+ ( v , c , r ) => c . Indices . MigrateToDataStream ( r ) ,
171+ ( v , c , r ) => c . Indices . MigrateToDataStreamAsync ( r )
172+ )
173+ } ,
129174 } ) { }
130175
131176 [ I ] public async Task CreateDataStreamResponse ( ) => await Assert < CreateDataStreamResponse > ( CreateDataStreamStep , ( v , r ) =>
@@ -180,5 +225,11 @@ [I] public async Task DeleteDataStreamResponse() => await Assert<DeleteDataStrea
180225 r . ShouldBeValid ( ) ;
181226 r . Acknowledged . Should ( ) . BeTrue ( ) ;
182227 } ) ;
228+
229+ [ I ] public async Task MigrateToDataStreamResponse ( ) => await Assert < MigrateToDataStreamResponse > ( MigrateToDataStreamStep , r =>
230+ {
231+ r . ShouldBeValid ( ) ;
232+ r . Acknowledged . Should ( ) . BeTrue ( ) ;
233+ } ) ;
183234 }
184235}
0 commit comments