@@ -28,6 +28,14 @@ protected SnapshotStats createTestInstance() {
2828 long incrementalSize = ((long ) randomIntBetween (0 , Integer .MAX_VALUE )) * 2 ;
2929 long totalSize = ((long ) randomIntBetween (0 , Integer .MAX_VALUE )) * 2 ;
3030 long processedSize = ((long ) randomIntBetween (0 , Integer .MAX_VALUE )) * 2 ;
31+
32+ // toXContent() omits the "processed" sub-object if processedFileCount == incrementalFileCount, so here we increase the probability
33+ // of that scenario so we can make sure the processed values are set as expected in fromXContent().
34+ if (randomBoolean ()) {
35+ processedFileCount = incrementalFileCount ;
36+ processedSize = incrementalSize ;
37+ }
38+
3139 return new SnapshotStats (
3240 startTime ,
3341 time ,
@@ -40,26 +48,6 @@ protected SnapshotStats createTestInstance() {
4048 );
4149 }
4250
43- public void testXContentSerializationWhenProcessedFileCountEqualsIncrementalFileCount () throws IOException {
44- final var instance = createTestInstance ();
45- final var incrementalSameAsProcessed = new SnapshotStats (
46- instance .getStartTime (),
47- instance .getTime (),
48- instance .getIncrementalFileCount (),
49- instance .getTotalFileCount (),
50- instance .getIncrementalFileCount (), // processedFileCount
51- instance .getIncrementalSize (),
52- instance .getTotalSize (),
53- instance .getIncrementalSize () // processedSize
54- );
55- // toXContent() omits the "processed" sub-object in this case, make sure the processed values are set as expected in fromXContent().
56- testFromXContent (() -> incrementalSameAsProcessed );
57- }
58-
59- public void testXContentSerializationForEmptyStats () throws IOException {
60- testFromXContent (SnapshotStats ::new );
61- }
62-
6351 @ Override
6452 protected SnapshotStats doParseInstance (XContentParser parser ) throws IOException {
6553 return fromXContent (parser );
0 commit comments