|  | 
| 16 | 16 | import org.elasticsearch.common.Strings; | 
| 17 | 17 | import org.elasticsearch.common.bytes.BytesArray; | 
| 18 | 18 | import org.elasticsearch.common.io.stream.BytesStreamOutput; | 
|  | 19 | +import org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput; | 
|  | 20 | +import org.elasticsearch.common.io.stream.StreamInput; | 
| 19 | 21 | import org.elasticsearch.common.io.stream.StreamOutput; | 
| 20 | 22 | import org.elasticsearch.common.util.ArrayUtils; | 
| 21 | 23 | import org.elasticsearch.core.TimeValue; | 
|  | 24 | +import org.elasticsearch.core.UpdateForV9; | 
| 22 | 25 | import org.elasticsearch.index.query.QueryBuilder; | 
| 23 | 26 | import org.elasticsearch.index.query.QueryBuilders; | 
| 24 | 27 | import org.elasticsearch.index.query.TermQueryBuilder; | 
| @@ -102,6 +105,23 @@ public void testSerialization() throws Exception { | 
| 102 | 105 |         assertNotSame(deserializedRequest, searchRequest); | 
| 103 | 106 |     } | 
| 104 | 107 | 
 | 
|  | 108 | +    @UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA)  // this can be removed when the affected transport version constants are collapsed | 
|  | 109 | +    public void testSerializationConstants() throws Exception { | 
|  | 110 | +        SearchRequest searchRequest = createSearchRequest(); | 
|  | 111 | + | 
|  | 112 | +        // something serialized with previous version to remove, should read correctly with the reversion | 
|  | 113 | +        try (BytesStreamOutput output = new BytesStreamOutput()) { | 
|  | 114 | +            output.setTransportVersion(TransportVersionUtils.getPreviousVersion(TransportVersions.REMOVE_MIN_COMPATIBLE_SHARD_NODE)); | 
|  | 115 | +            searchRequest.writeTo(output); | 
|  | 116 | +            try (StreamInput in = new NamedWriteableAwareStreamInput(output.bytes().streamInput(), namedWriteableRegistry)) { | 
|  | 117 | +                in.setTransportVersion(TransportVersions.REVERT_REMOVE_MIN_COMPATIBLE_SHARD_NODE); | 
|  | 118 | +                SearchRequest copiedRequest = new SearchRequest(in); | 
|  | 119 | +                assertEquals(copiedRequest, searchRequest); | 
|  | 120 | +                assertEquals(copiedRequest.hashCode(), searchRequest.hashCode()); | 
|  | 121 | +            } | 
|  | 122 | +        } | 
|  | 123 | +    } | 
|  | 124 | + | 
| 105 | 125 |     public void testSerializationMultiKNN() throws Exception { | 
| 106 | 126 |         SearchRequest searchRequest = createSearchRequest(); | 
| 107 | 127 |         if (searchRequest.source() == null) { | 
|  | 
0 commit comments