22// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
33// See the LICENSE file in the project root for more information
44
5- using System ;
5+ using System . Collections . Generic ;
66using System . Linq ;
77using System . Threading . Tasks ;
88using Elastic . Elasticsearch . Xunit . XunitPlumbing ;
@@ -21,6 +21,7 @@ public class PointInTimeApiTests : CoordinatedIntegrationTestBase<ReadOnlyCluste
2121 {
2222 private const string OpenPointInTimeStep = nameof ( OpenPointInTimeStep ) ;
2323 private const string SearchPointInTimeStep = nameof ( SearchPointInTimeStep ) ;
24+ private const string SearchPointInTimeWithSortStep = nameof ( SearchPointInTimeWithSortStep ) ;
2425 private const string ClosePointInTimeStep = nameof ( ClosePointInTimeStep ) ;
2526
2627 public PointInTimeApiTests ( ReadOnlyCluster cluster , EndpointUsage usage ) : base ( new CoordinatedUsage ( cluster , usage )
@@ -60,6 +61,31 @@ public PointInTimeApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(
6061 uniqueValueSelector : values => values . ExtendedValue < string > ( "pitId" )
6162 )
6263 } ,
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+ } ,
6389 {
6490 ClosePointInTimeStep , u =>
6591 u . Calls < ClosePointInTimeDescriptor , ClosePointInTimeRequest , IClosePointInTimeRequest , ClosePointInTimeResponse > (
@@ -74,13 +100,13 @@ public PointInTimeApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(
74100 }
75101 } ) { }
76102
77- [ I ] public async Task OpenPointInTimeResponse ( ) => await Assert < OpenPointInTimeResponse > ( OpenPointInTimeStep , ( v , r ) =>
103+ [ I ] public async Task OpenPointInTimeResponse ( ) => await Assert < OpenPointInTimeResponse > ( OpenPointInTimeStep , r =>
78104 {
79105 r . ShouldBeValid ( ) ;
80106 r . Id . Should ( ) . NotBeNullOrEmpty ( ) ;
81107 } ) ;
82108
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 =>
84110 {
85111 r . ShouldBeValid ( ) ;
86112 r . PointInTimeId . Should ( ) . NotBeNullOrEmpty ( ) ;
@@ -93,7 +119,15 @@ [I] public async Task SearchPointInTimeResponse() => await Assert<SearchResponse
93119 r . Took . Should ( ) . BeGreaterOrEqualTo ( 0 ) ;
94120 } ) ;
95121
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 =>
97131 {
98132 r . ShouldBeValid ( ) ;
99133 r . Succeeded . Should ( ) . BeTrue ( ) ;
0 commit comments