34
34
import org .opensearch .client .opensearch .cat .segments .SegmentsRecord ;
35
35
import org .opensearch .client .opensearch .cat .shards .ShardsRecord ;
36
36
import org .opensearch .client .opensearch .core .IndexResponse ;
37
- import org .opensearch .client .opensearch .core .InfoResponse ;
38
37
import org .opensearch .client .opensearch .core .pit .CreatePitResponse ;
39
38
import org .opensearch .client .opensearch .indices .CreateIndexResponse ;
40
39
@@ -238,15 +237,8 @@ public void testCatSegments() throws Exception {
238
237
239
238
@ Test
240
239
public void testCatPitSegments () throws Exception {
241
- InfoResponse info = javaClient ().info ();
242
- String version = info .version ().number ();
243
- if (version .contains ("SNAPSHOT" )) {
244
- version = version .split ("-" )[0 ];
245
- }
246
- assumeTrue (
247
- "The PIT is supported in OpenSearch 2.4.0 and later" ,
248
- Version .fromString (version ).onOrAfter (Version .fromString ("2.4.0" ))
249
- );
240
+ final Version version = getServerVersion ();
241
+ assumeTrue ("The PIT is supported in OpenSearch 2.4.0 and later" , version .onOrAfter (Version .V_2_4_0 ));
250
242
createIndex ("cat-pit-segments-test-index" );
251
243
252
244
final IndexResponse index = javaClient ().index (
@@ -264,7 +256,7 @@ public void testCatPitSegments() throws Exception {
264
256
265
257
assertNotNull ("PitSegmentsResponse.segments() is null" , PitSegmentsResponse .valueBody ());
266
258
267
- if (Version . fromString ( version ) .onOrAfter (Version .fromString ( "2.10.0" ) )) {
259
+ if (version .onOrAfter (Version .V_2_10_0 )) {
268
260
assertTrue ("PitSegmentsResponse.segments().size() == 0" , PitSegmentsResponse .valueBody ().isEmpty ());
269
261
} else {
270
262
assertTrue ("PitSegmentsResponse.segments().size() == 0" , PitSegmentsResponse .valueBody ().size () > 0 );
0 commit comments