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