From b0c747b4902775d515f4dc217ba9ca588e3be929 Mon Sep 17 00:00:00 2001 From: Hector Ventura Date: Thu, 17 Sep 2026 00:44:49 -0500 Subject: [PATCH] test(ecr): read the manifest response body before the response completes (#3801) EcrRegistryDataPlaneTest.immutableTagRejectsReplacementBeforeItReachesTheRegistry failed intermittently with "No content to map due to end-of-input". Its putManifest helper returned the HttpClientResponse once the headers arrived, and the test asked for the body afterwards from its own thread. The error body is small enough to arrive with the headers, so the event loop had often finished the response already and the late body() yielded an empty buffer. The helper now reads the body inside the response's own future chain and returns the status code and body together. The data plane itself was correct. --- .../ecr/registry/EcrRegistryDataPlaneTest.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/test/java/io/github/hectorvent/floci/services/ecr/registry/EcrRegistryDataPlaneTest.java b/src/test/java/io/github/hectorvent/floci/services/ecr/registry/EcrRegistryDataPlaneTest.java index 948a756a17..7a85eec03a 100644 --- a/src/test/java/io/github/hectorvent/floci/services/ecr/registry/EcrRegistryDataPlaneTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/ecr/registry/EcrRegistryDataPlaneTest.java @@ -167,11 +167,9 @@ class EcrRegistryDataPlaneTest { assertEquals(201, putManifest(dataPlane.actualPort()).statusCode()); - var rejected = putManifest(dataPlane.actualPort()); + ManifestResponse rejected = putManifest(dataPlane.actualPort()); assertEquals(400, rejected.statusCode()); - String responseBody = rejected.body() - .toCompletionStage().toCompletableFuture().get(2, TimeUnit.SECONDS).toString(); - JsonObject json = new JsonObject(responseBody); + JsonObject json = new JsonObject(rejected.body()); JsonArray errors = json.getJsonArray("errors"); assertNotNull(errors); assertEquals(1, errors.size()); @@ -192,7 +190,10 @@ class EcrRegistryDataPlaneTest { } } - private io.vertx.core.http.HttpClientResponse putManifest(int port) throws Exception { + private record ManifestResponse(int statusCode, String body) { + } + + private ManifestResponse putManifest(int port) throws Exception { HttpClient client = vertx.createHttpClient(); return client.request(new RequestOptions() .setHost("127.0.0.1") @@ -204,6 +205,11 @@ class EcrRegistryDataPlaneTest { request.setChunked(true); return request.send(Buffer.buffer("{}")); }) + // Read the body inside the response's own future chain. A body() registered from + // the test thread after get() races the event loop, which may already have + // delivered the whole response, and then yields an empty buffer. + .compose(response -> response.body() + .map(body -> new ManifestResponse(response.statusCode(), body.toString()))) .toCompletionStage().toCompletableFuture().get(2, TimeUnit.SECONDS); } }