|
18 | 18 | import org.elasticsearch.common.settings.Settings; |
19 | 19 | import org.elasticsearch.common.util.MockPageCacheRecycler; |
20 | 20 | import org.elasticsearch.common.util.concurrent.ThreadContext; |
21 | | -import org.elasticsearch.core.UpdateForV9; |
22 | 21 | import org.elasticsearch.test.ESTestCase; |
23 | 22 | import org.elasticsearch.test.TransportVersionUtils; |
24 | 23 | import org.elasticsearch.transport.InboundDecoder.ChannelType; |
@@ -126,105 +125,6 @@ public void testDecode() throws IOException { |
126 | 125 |
|
127 | 126 | } |
128 | 127 |
|
129 | | - @UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) // can delete test in v9 |
130 | | - public void testDecodePreHeaderSizeVariableInt() throws IOException { |
131 | | - Compression.Scheme compressionScheme = randomFrom(Compression.Scheme.DEFLATE, Compression.Scheme.DEFLATE, null); |
132 | | - String action = "test-request"; |
133 | | - long requestId = randomNonNegativeLong(); |
134 | | - final TransportVersion preHeaderVariableInt = TransportHandshaker.V7_HANDSHAKE_VERSION; |
135 | | - final String contentValue = randomAlphaOfLength(100); |
136 | | - // 8.0 is only compatible with handshakes on a pre-variable int version |
137 | | - final OutboundMessage message = new OutboundMessage.Request( |
138 | | - threadContext, |
139 | | - new TestRequest(contentValue), |
140 | | - preHeaderVariableInt, |
141 | | - action, |
142 | | - requestId, |
143 | | - true, |
144 | | - compressionScheme |
145 | | - ); |
146 | | - |
147 | | - try (RecyclerBytesStreamOutput os = new RecyclerBytesStreamOutput(recycler)) { |
148 | | - final BytesReference totalBytes = message.serialize(os); |
149 | | - int partialHeaderSize = TcpHeader.headerSize(preHeaderVariableInt); |
150 | | - |
151 | | - InboundDecoder decoder = new InboundDecoder(recycler); |
152 | | - final ArrayList<Object> fragments = new ArrayList<>(); |
153 | | - final ReleasableBytesReference releasable1 = wrapAsReleasable(totalBytes); |
154 | | - int bytesConsumed = decoder.decode(releasable1, fragments::add); |
155 | | - assertEquals(partialHeaderSize, bytesConsumed); |
156 | | - assertTrue(releasable1.hasReferences()); |
157 | | - |
158 | | - final Header header = (Header) fragments.get(0); |
159 | | - assertEquals(requestId, header.getRequestId()); |
160 | | - assertEquals(preHeaderVariableInt, header.getVersion()); |
161 | | - if (compressionScheme == null) { |
162 | | - assertFalse(header.isCompressed()); |
163 | | - } else { |
164 | | - assertTrue(header.isCompressed()); |
165 | | - } |
166 | | - assertTrue(header.isHandshake()); |
167 | | - assertTrue(header.isRequest()); |
168 | | - assertTrue(header.needsToReadVariableHeader()); |
169 | | - fragments.clear(); |
170 | | - |
171 | | - final BytesReference bytes2 = totalBytes.slice(bytesConsumed, totalBytes.length() - bytesConsumed); |
172 | | - final ReleasableBytesReference releasable2 = wrapAsReleasable(bytes2); |
173 | | - int bytesConsumed2 = decoder.decode(releasable2, fragments::add); |
174 | | - if (compressionScheme == null) { |
175 | | - assertEquals(2, fragments.size()); |
176 | | - } else { |
177 | | - assertEquals(3, fragments.size()); |
178 | | - final Object body = fragments.get(1); |
179 | | - assertThat(body, instanceOf(ReleasableBytesReference.class)); |
180 | | - ((ReleasableBytesReference) body).close(); |
181 | | - } |
182 | | - assertEquals(InboundDecoder.END_CONTENT, fragments.get(fragments.size() - 1)); |
183 | | - assertEquals(totalBytes.length() - bytesConsumed, bytesConsumed2); |
184 | | - } |
185 | | - } |
186 | | - |
187 | | - public void testDecodeHandshakeV7Compatibility() throws IOException { |
188 | | - String action = "test-request"; |
189 | | - long requestId = randomNonNegativeLong(); |
190 | | - final String headerKey = randomAlphaOfLength(10); |
191 | | - final String headerValue = randomAlphaOfLength(20); |
192 | | - threadContext.putHeader(headerKey, headerValue); |
193 | | - TransportVersion handshakeCompat = TransportHandshaker.V7_HANDSHAKE_VERSION; |
194 | | - OutboundMessage message = new OutboundMessage.Request( |
195 | | - threadContext, |
196 | | - new TestRequest(randomAlphaOfLength(100)), |
197 | | - handshakeCompat, |
198 | | - action, |
199 | | - requestId, |
200 | | - true, |
201 | | - null |
202 | | - ); |
203 | | - |
204 | | - try (RecyclerBytesStreamOutput os = new RecyclerBytesStreamOutput(recycler)) { |
205 | | - final BytesReference bytes = message.serialize(os); |
206 | | - int totalHeaderSize = TcpHeader.headerSize(handshakeCompat); |
207 | | - |
208 | | - InboundDecoder decoder = new InboundDecoder(recycler); |
209 | | - final ArrayList<Object> fragments = new ArrayList<>(); |
210 | | - final ReleasableBytesReference releasable1 = wrapAsReleasable(bytes); |
211 | | - int bytesConsumed = decoder.decode(releasable1, fragments::add); |
212 | | - assertEquals(totalHeaderSize, bytesConsumed); |
213 | | - assertTrue(releasable1.hasReferences()); |
214 | | - |
215 | | - final Header header = (Header) fragments.get(0); |
216 | | - assertEquals(requestId, header.getRequestId()); |
217 | | - assertEquals(handshakeCompat, header.getVersion()); |
218 | | - assertFalse(header.isCompressed()); |
219 | | - assertTrue(header.isHandshake()); |
220 | | - assertTrue(header.isRequest()); |
221 | | - // TODO: On 9.0 this will be true because all compatible versions with contain the variable header int |
222 | | - assertTrue(header.needsToReadVariableHeader()); |
223 | | - fragments.clear(); |
224 | | - } |
225 | | - |
226 | | - } |
227 | | - |
228 | 128 | public void testDecodeHandshakeV8Compatibility() throws IOException { |
229 | 129 | doHandshakeCompatibilityTest(TransportHandshaker.V8_HANDSHAKE_VERSION, null); |
230 | 130 | doHandshakeCompatibilityTest(TransportHandshaker.V8_HANDSHAKE_VERSION, Compression.Scheme.DEFLATE); |
@@ -453,46 +353,6 @@ public void testCompressedDecode() throws IOException { |
453 | 353 |
|
454 | 354 | } |
455 | 355 |
|
456 | | - public void testCompressedDecodeHandshakeCompatibility() throws IOException { |
457 | | - String action = "test-request"; |
458 | | - long requestId = randomNonNegativeLong(); |
459 | | - final String headerKey = randomAlphaOfLength(10); |
460 | | - final String headerValue = randomAlphaOfLength(20); |
461 | | - threadContext.putHeader(headerKey, headerValue); |
462 | | - TransportVersion handshakeCompat = TransportHandshaker.V7_HANDSHAKE_VERSION; |
463 | | - OutboundMessage message = new OutboundMessage.Request( |
464 | | - threadContext, |
465 | | - new TestRequest(randomAlphaOfLength(100)), |
466 | | - handshakeCompat, |
467 | | - action, |
468 | | - requestId, |
469 | | - true, |
470 | | - Compression.Scheme.DEFLATE |
471 | | - ); |
472 | | - |
473 | | - try (RecyclerBytesStreamOutput os = new RecyclerBytesStreamOutput(recycler)) { |
474 | | - final BytesReference bytes = message.serialize(os); |
475 | | - int totalHeaderSize = TcpHeader.headerSize(handshakeCompat); |
476 | | - |
477 | | - InboundDecoder decoder = new InboundDecoder(recycler); |
478 | | - final ArrayList<Object> fragments = new ArrayList<>(); |
479 | | - final ReleasableBytesReference releasable1 = wrapAsReleasable(bytes); |
480 | | - int bytesConsumed = decoder.decode(releasable1, fragments::add); |
481 | | - assertEquals(totalHeaderSize, bytesConsumed); |
482 | | - assertTrue(releasable1.hasReferences()); |
483 | | - |
484 | | - final Header header = (Header) fragments.get(0); |
485 | | - assertEquals(requestId, header.getRequestId()); |
486 | | - assertEquals(handshakeCompat, header.getVersion()); |
487 | | - assertTrue(header.isCompressed()); |
488 | | - assertTrue(header.isHandshake()); |
489 | | - assertTrue(header.isRequest()); |
490 | | - // TODO: On 9.0 this will be true because all compatible versions with contain the variable header int |
491 | | - assertTrue(header.needsToReadVariableHeader()); |
492 | | - fragments.clear(); |
493 | | - } |
494 | | - } |
495 | | - |
496 | 356 | public void testVersionIncompatibilityDecodeException() throws IOException { |
497 | 357 | String action = "test-request"; |
498 | 358 | long requestId = randomNonNegativeLong(); |
|
0 commit comments