@@ -37,7 +37,7 @@ namespace Tests.XPack.DataStreams
37
37
[ SkipVersion ( "<7.9.0" , "Introduced in 7.9.0" ) ]
38
38
public class DataStreamsApiTests : CoordinatedIntegrationTestBase < WritableCluster >
39
39
{
40
- private static readonly Metric Document = new Metric
40
+ private static readonly Metric Document = new ( )
41
41
{
42
42
Timestamp = new DateTime ( 2020 , 8 , 3 , 14 , 0 , 0 , DateTimeKind . Utc ) ,
43
43
Accept = 3 ,
@@ -47,13 +47,16 @@ public class DataStreamsApiTests : CoordinatedIntegrationTestBase<WritableCluste
47
47
Response = 300 ,
48
48
Total = 3
49
49
} ;
50
-
50
+
51
51
private const string CreateDataStreamStep = nameof ( CreateDataStreamStep ) ;
52
52
private const string IndexStep = nameof ( IndexStep ) ;
53
53
private const string GetDataStreamStep = nameof ( GetDataStreamStep ) ;
54
54
private const string PutIndexTemplateStep = nameof ( PutIndexTemplateStep ) ;
55
55
private const string DataStreamsStatsStep = nameof ( DataStreamsStatsStep ) ;
56
56
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 ) ;
57
60
58
61
public DataStreamsApiTests ( WritableCluster cluster , EndpointUsage usage ) : base ( new CoordinatedUsage ( cluster , usage , testOnlyOne : true )
59
62
{
@@ -109,10 +112,10 @@ public DataStreamsApiTests(WritableCluster cluster, EndpointUsage usage) : base(
109
112
Refresh = Refresh . WaitFor
110
113
} ,
111
114
( 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 )
116
119
)
117
120
} ,
118
121
{ GetDataStreamStep , u =>
@@ -145,6 +148,48 @@ public DataStreamsApiTests(WritableCluster cluster, EndpointUsage usage) : base(
145
148
( v , c , r ) => c . Indices . DeleteDataStreamAsync ( r )
146
149
)
147
150
} ,
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
+ } ,
148
193
} ) { }
149
194
150
195
[ I ] public async Task CreateDataStreamResponse ( ) => await Assert < CreateDataStreamResponse > ( CreateDataStreamStep , ( v , r ) =>
@@ -199,5 +244,11 @@ [I] public async Task DeleteDataStreamResponse() => await Assert<DeleteDataStrea
199
244
r . ShouldBeValid ( ) ;
200
245
r . Acknowledged . Should ( ) . BeTrue ( ) ;
201
246
} ) ;
247
+
248
+ [ I ] public async Task MigrateToDataStreamResponse ( ) => await Assert < MigrateToDataStreamResponse > ( MigrateToDataStreamStep , r =>
249
+ {
250
+ r . ShouldBeValid ( ) ;
251
+ r . Acknowledged . Should ( ) . BeTrue ( ) ;
252
+ } ) ;
202
253
}
203
254
}
0 commit comments