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