@@ -17,7 +17,7 @@ namespace Tests.XPack.DataStreams
17
17
[ SkipVersion ( "<7.9.0" , "Introduced in 7.9.0" ) ]
18
18
public class DataStreamsApiTests : CoordinatedIntegrationTestBase < WritableCluster >
19
19
{
20
- private static readonly Metric Document = new Metric
20
+ private static readonly Metric Document = new ( )
21
21
{
22
22
Timestamp = new DateTime ( 2020 , 8 , 3 , 14 , 0 , 0 , DateTimeKind . Utc ) ,
23
23
Accept = 3 ,
@@ -27,13 +27,16 @@ public class DataStreamsApiTests : CoordinatedIntegrationTestBase<WritableCluste
27
27
Response = 300 ,
28
28
Total = 3
29
29
} ;
30
-
30
+
31
31
private const string CreateDataStreamStep = nameof ( CreateDataStreamStep ) ;
32
32
private const string IndexStep = nameof ( IndexStep ) ;
33
33
private const string GetDataStreamStep = nameof ( GetDataStreamStep ) ;
34
34
private const string PutIndexTemplateStep = nameof ( PutIndexTemplateStep ) ;
35
35
private const string DataStreamsStatsStep = nameof ( DataStreamsStatsStep ) ;
36
36
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 ) ;
37
40
38
41
public DataStreamsApiTests ( WritableCluster cluster , EndpointUsage usage ) : base ( new CoordinatedUsage ( cluster , usage , testOnlyOne : true )
39
42
{
@@ -89,10 +92,10 @@ public DataStreamsApiTests(WritableCluster cluster, EndpointUsage usage) : base(
89
92
Refresh = Refresh . WaitFor
90
93
} ,
91
94
( 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 )
96
99
)
97
100
} ,
98
101
{ GetDataStreamStep , u =>
@@ -125,6 +128,48 @@ public DataStreamsApiTests(WritableCluster cluster, EndpointUsage usage) : base(
125
128
( v , c , r ) => c . Indices . DeleteDataStreamAsync ( r )
126
129
)
127
130
} ,
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
+ } ,
128
173
} ) { }
129
174
130
175
[ I ] public async Task CreateDataStreamResponse ( ) => await Assert < CreateDataStreamResponse > ( CreateDataStreamStep , ( v , r ) =>
@@ -179,5 +224,11 @@ [I] public async Task DeleteDataStreamResponse() => await Assert<DeleteDataStrea
179
224
r . ShouldBeValid ( ) ;
180
225
r . Acknowledged . Should ( ) . BeTrue ( ) ;
181
226
} ) ;
227
+
228
+ [ I ] public async Task MigrateToDataStreamResponse ( ) => await Assert < MigrateToDataStreamResponse > ( MigrateToDataStreamStep , r =>
229
+ {
230
+ r . ShouldBeValid ( ) ;
231
+ r . Acknowledged . Should ( ) . BeTrue ( ) ;
232
+ } ) ;
182
233
}
183
234
}
0 commit comments