From e235a0ac53d067b35025a02ecf264c7ccb00fe69 Mon Sep 17 00:00:00 2001 From: conorbros Date: Mon, 30 Oct 2023 16:43:48 +1100 Subject: [PATCH] fix opensearch codec bug --- .../tests/opensearch_int_tests/mod.rs | 18 +++++++++++++++++- shotover/src/codec/opensearch.rs | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/shotover-proxy/tests/opensearch_int_tests/mod.rs b/shotover-proxy/tests/opensearch_int_tests/mod.rs index be39351e8..2fcd3814f 100644 --- a/shotover-proxy/tests/opensearch_int_tests/mod.rs +++ b/shotover-proxy/tests/opensearch_int_tests/mod.rs @@ -2,12 +2,14 @@ use crate::shotover_process; use opensearch::{ auth::Credentials, cert::CertificateValidation, - http::response::Response, http::{ + headers::{HeaderName, HeaderValue}, + response::Response, transport::{SingleNodeConnectionPool, TransportBuilder}, Method, StatusCode, Url, }, indices::{IndicesCreateParts, IndicesDeleteParts, IndicesExistsParts}, + nodes::NodesInfoParts, params::Refresh, BulkOperation, BulkParts, DeleteParts, Error, IndexParts, OpenSearch, SearchParts, }; @@ -224,6 +226,20 @@ async fn opensearch_test_suite(client: &OpenSearch) { test_bulk(client).await; test_delete_index(client).await; + + // request a large message without compression that has to be processed in multiple batches on the codec side + let _ = assert_ok_and_get_json( + client + .nodes() + .info(NodesInfoParts::None) + .header( + HeaderName::from_lowercase(b"accept-encoding").unwrap(), + HeaderValue::from_str("").unwrap(), + ) + .send() + .await, + ) + .await; } #[tokio::test(flavor = "multi_thread")] diff --git a/shotover/src/codec/opensearch.rs b/shotover/src/codec/opensearch.rs index 57db1debb..6a45beb98 100644 --- a/shotover/src/codec/opensearch.rs +++ b/shotover/src/codec/opensearch.rs @@ -210,6 +210,7 @@ impl Decoder for OpenSearchDecoder { } if src.len() < content_length { + self.state = State::ReadingBody(http_headers, content_length); return Ok(None); }