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.
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-09-17 00:44:49 -05:00
1 parent 9cd27190ff
commit b0c747b490
1 file changed
+11 -5
@@ -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);
}
}