2
2
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3
3
// See the LICENSE file in the project root for more information
4
4
5
- using System ;
5
+ using System . Collections . Generic ;
6
6
using System . Linq ;
7
7
using System . Threading . Tasks ;
8
8
using Elastic . Elasticsearch . Xunit . XunitPlumbing ;
@@ -21,6 +21,7 @@ public class PointInTimeApiTests : CoordinatedIntegrationTestBase<ReadOnlyCluste
21
21
{
22
22
private const string OpenPointInTimeStep = nameof ( OpenPointInTimeStep ) ;
23
23
private const string SearchPointInTimeStep = nameof ( SearchPointInTimeStep ) ;
24
+ private const string SearchPointInTimeWithSortStep = nameof ( SearchPointInTimeWithSortStep ) ;
24
25
private const string ClosePointInTimeStep = nameof ( ClosePointInTimeStep ) ;
25
26
26
27
public PointInTimeApiTests ( ReadOnlyCluster cluster , EndpointUsage usage ) : base ( new CoordinatedUsage ( cluster , usage )
@@ -60,6 +61,31 @@ public PointInTimeApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(
60
61
uniqueValueSelector : values => values . ExtendedValue < string > ( "pitId" )
61
62
)
62
63
} ,
64
+ {
65
+ SearchPointInTimeWithSortStep , ">=7.12.0" , u =>
66
+ u . Calls < SearchDescriptor < Project > , SearchRequest < Project > , ISearchRequest < Project > , ISearchResponse < Project > > (
67
+ v => new SearchRequest < Project >
68
+ {
69
+ Size = 1 ,
70
+ Query = new QueryContainer ( new MatchAllQuery ( ) ) ,
71
+ PointInTime = new Nest . PointInTime ( v , "1m" ) ,
72
+ Sort = new List < ISort >
73
+ {
74
+ FieldSort . ShardDocumentOrderDescending
75
+ }
76
+ } ,
77
+ ( v , d ) => d
78
+ . Size ( 1 )
79
+ . Query ( q => q . MatchAll ( ) )
80
+ . PointInTime ( v , p => p . KeepAlive ( "1m" ) )
81
+ . Sort ( s => s . Descending ( SortSpecialField . ShardDocumentOrder ) ) ,
82
+ ( v , c , f ) => c . Search ( f ) ,
83
+ ( v , c , f ) => c . SearchAsync ( f ) ,
84
+ ( v , c , r ) => c . Search < Project > ( r ) ,
85
+ ( v , c , r ) => c . SearchAsync < Project > ( r ) ,
86
+ uniqueValueSelector : values => values . ExtendedValue < string > ( "pitId" )
87
+ )
88
+ } ,
63
89
{
64
90
ClosePointInTimeStep , u =>
65
91
u . Calls < ClosePointInTimeDescriptor , ClosePointInTimeRequest , IClosePointInTimeRequest , ClosePointInTimeResponse > (
@@ -74,13 +100,13 @@ public PointInTimeApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(
74
100
}
75
101
} ) { }
76
102
77
- [ I ] public async Task OpenPointInTimeResponse ( ) => await Assert < OpenPointInTimeResponse > ( OpenPointInTimeStep , ( v , r ) =>
103
+ [ I ] public async Task OpenPointInTimeResponse ( ) => await Assert < OpenPointInTimeResponse > ( OpenPointInTimeStep , r =>
78
104
{
79
105
r . ShouldBeValid ( ) ;
80
106
r . Id . Should ( ) . NotBeNullOrEmpty ( ) ;
81
107
} ) ;
82
108
83
- [ I ] public async Task SearchPointInTimeResponse ( ) => await Assert < SearchResponse < Project > > ( SearchPointInTimeStep , ( v , r ) =>
109
+ [ I ] public async Task SearchPointInTimeResponse ( ) => await Assert < SearchResponse < Project > > ( SearchPointInTimeStep , r =>
84
110
{
85
111
r . ShouldBeValid ( ) ;
86
112
r . PointInTimeId . Should ( ) . NotBeNullOrEmpty ( ) ;
@@ -93,7 +119,15 @@ [I] public async Task SearchPointInTimeResponse() => await Assert<SearchResponse
93
119
r . Took . Should ( ) . BeGreaterOrEqualTo ( 0 ) ;
94
120
} ) ;
95
121
96
- [ I ] public async Task ClosePointInTimeResponse ( ) => await Assert < ClosePointInTimeResponse > ( ClosePointInTimeStep , ( v , r ) =>
122
+ [ I ] public async Task SearchPointInTimeWithSortResponse ( ) => await Assert < SearchResponse < Project > > ( SearchPointInTimeWithSortStep , r =>
123
+ {
124
+ r . ShouldBeValid ( ) ;
125
+ r . PointInTimeId . Should ( ) . NotBeNullOrEmpty ( ) ;
126
+ r . Total . Should ( ) . BeGreaterThan ( 0 ) ;
127
+ r . Hits . Count . Should ( ) . BeGreaterThan ( 0 ) ;
128
+ } ) ;
129
+
130
+ [ I ] public async Task ClosePointInTimeResponse ( ) => await Assert < ClosePointInTimeResponse > ( ClosePointInTimeStep , r =>
97
131
{
98
132
r . ShouldBeValid ( ) ;
99
133
r . Succeeded . Should ( ) . BeTrue ( ) ;
0 commit comments