|  | 
| 11 | 11 | 
 | 
| 12 | 12 | import org.elasticsearch.ElasticsearchParseException; | 
| 13 | 13 | import org.elasticsearch.TransportVersion; | 
| 14 |  | -import org.elasticsearch.TransportVersions; | 
| 15 | 14 | import org.elasticsearch.common.io.stream.BytesStreamOutput; | 
| 16 | 15 | import org.elasticsearch.common.io.stream.Writeable.Reader; | 
| 17 | 16 | import org.elasticsearch.test.AbstractWireSerializingTestCase; | 
|  | 
| 22 | 21 | import java.util.List; | 
| 23 | 22 | import java.util.function.Function; | 
| 24 | 23 | 
 | 
|  | 24 | +import static org.elasticsearch.TransportVersions.BYTE_SIZE_VALUE_ALWAYS_USES_BYTES_90; | 
|  | 25 | +import static org.elasticsearch.TransportVersions.INITIAL_ELASTICSEARCH_9_0; | 
|  | 26 | +import static org.elasticsearch.TransportVersions.V_8_16_0; | 
| 25 | 27 | import static org.hamcrest.Matchers.containsString; | 
| 26 | 28 | import static org.hamcrest.Matchers.equalTo; | 
| 27 | 29 | import static org.hamcrest.Matchers.is; | 
| @@ -520,44 +522,43 @@ protected void assertEqualInstances(ByteSizeValue expectedInstance, ByteSizeValu | 
| 520 | 522 | 
 | 
| 521 | 523 |     public void testBWCTransportFormat() throws IOException { | 
| 522 | 524 |         var tenMegs = ByteSizeValue.ofMb(10); | 
| 523 |  | -        try (BytesStreamOutput expected = new BytesStreamOutput(); BytesStreamOutput actual = new BytesStreamOutput()) { | 
| 524 |  | -            expected.writeZLong(10); | 
| 525 |  | -            ByteSizeUnit.MB.writeTo(expected); | 
| 526 |  | -            actual.setTransportVersion(TransportVersions.V_8_16_0); | 
| 527 |  | -            tenMegs.writeTo(actual); | 
| 528 |  | -            assertArrayEquals( | 
| 529 |  | -                "Size denominated in the desired unit for backward compatibility", | 
| 530 |  | -                expected.bytes().array(), | 
| 531 |  | -                actual.bytes().array() | 
| 532 |  | -            ); | 
|  | 525 | +        for (var tv : List.of(V_8_16_0, INITIAL_ELASTICSEARCH_9_0)) { | 
|  | 526 | +            try (BytesStreamOutput expected = new BytesStreamOutput(); BytesStreamOutput actual = new BytesStreamOutput()) { | 
|  | 527 | +                expected.writeZLong(10); | 
|  | 528 | +                ByteSizeUnit.MB.writeTo(expected); | 
|  | 529 | +                actual.setTransportVersion(tv); | 
|  | 530 | +                tenMegs.writeTo(actual); | 
|  | 531 | +                assertArrayEquals( | 
|  | 532 | +                    "Size denominated in the desired unit for backward compatibility", | 
|  | 533 | +                    expected.bytes().array(), | 
|  | 534 | +                    actual.bytes().array() | 
|  | 535 | +                ); | 
|  | 536 | +            } | 
| 533 | 537 |         } | 
| 534 | 538 |     } | 
| 535 | 539 | 
 | 
| 536 |  | -    /** | 
| 537 |  | -     * @see TransportVersions#REVERT_BYTE_SIZE_VALUE_ALWAYS_USES_BYTES_1 | 
| 538 |  | -     */ | 
| 539 |  | -    @AwaitsFix(bugUrl = "https://elasticco.atlassian.net/browse/ES-10585") | 
| 540 | 540 |     public void testTwoDigitTransportRoundTrips() throws IOException { | 
| 541 |  | -        TransportVersion tv = TransportVersion.current(); | 
| 542 |  | -        for (var desiredUnit : ByteSizeUnit.values()) { | 
| 543 |  | -            if (desiredUnit == ByteSizeUnit.BYTES) { | 
| 544 |  | -                continue; | 
| 545 |  | -            } | 
| 546 |  | -            checkTransportRoundTrip(ByteSizeValue.parseBytesSizeValue("23" + desiredUnit.getSuffix(), "test"), tv); | 
| 547 |  | -            for (int tenths = 1; tenths <= 9; tenths++) { | 
| 548 |  | -                checkTransportRoundTrip(ByteSizeValue.parseBytesSizeValue("23." + tenths + desiredUnit.getSuffix(), "test"), tv); | 
| 549 |  | -                for (int hundredths = 1; hundredths <= 9; hundredths++) { | 
| 550 |  | -                    checkTransportRoundTrip( | 
| 551 |  | -                        ByteSizeValue.parseBytesSizeValue("23." + tenths + hundredths + desiredUnit.getSuffix(), "test"), | 
| 552 |  | -                        tv | 
| 553 |  | -                    ); | 
|  | 541 | +        for (var tv : List.of(TransportVersion.current(), BYTE_SIZE_VALUE_ALWAYS_USES_BYTES_90)) { | 
|  | 542 | +            for (var desiredUnit : ByteSizeUnit.values()) { | 
|  | 543 | +                if (desiredUnit == ByteSizeUnit.BYTES) { | 
|  | 544 | +                    continue; | 
|  | 545 | +                } | 
|  | 546 | +                checkTransportRoundTrip(ByteSizeValue.parseBytesSizeValue("23" + desiredUnit.getSuffix(), "test"), tv); | 
|  | 547 | +                for (int tenths = 1; tenths <= 9; tenths++) { | 
|  | 548 | +                    checkTransportRoundTrip(ByteSizeValue.parseBytesSizeValue("23." + tenths + desiredUnit.getSuffix(), "test"), tv); | 
|  | 549 | +                    for (int hundredths = 1; hundredths <= 9; hundredths++) { | 
|  | 550 | +                        checkTransportRoundTrip( | 
|  | 551 | +                            ByteSizeValue.parseBytesSizeValue("23." + tenths + hundredths + desiredUnit.getSuffix(), "test"), | 
|  | 552 | +                            tv | 
|  | 553 | +                        ); | 
|  | 554 | +                    } | 
| 554 | 555 |                 } | 
| 555 | 556 |             } | 
| 556 | 557 |         } | 
| 557 | 558 |     } | 
| 558 | 559 | 
 | 
| 559 | 560 |     public void testIntegerTransportRoundTrips() throws IOException { | 
| 560 |  | -        for (var tv : List.of(TransportVersion.current(), TransportVersions.V_8_16_0)) { | 
|  | 561 | +        for (var tv : List.of(TransportVersion.current(), V_8_16_0)) { | 
| 561 | 562 |             checkTransportRoundTrip(ByteSizeValue.ONE, tv); | 
| 562 | 563 |             checkTransportRoundTrip(ByteSizeValue.ZERO, tv); | 
| 563 | 564 |             checkTransportRoundTrip(ByteSizeValue.MINUS_ONE, tv); | 
|  | 
0 commit comments