From ccf7264d90169dc21a877f2bde0d2f512083dfea Mon Sep 17 00:00:00 2001 From: Jackson Price <59149601+jprice8@users.noreply.github.com> Date: Thu, 3 Dec 2026 08:54:28 -0600 Subject: [PATCH] test(redshift): check for extra COPY and UNLOAD response bytes (#10078) Three Redshift COPY and UNLOAD error tests waited 400 ms for a socket read to time out after ReadyForQuery. Once the simulator returns and its fake backend has finished, the test now shuts down the writing half of the socket and checks for end of stream, so any extra response byte arrives before EOF and fails the assertion. --- .../redshift/proxy/S3CopySimulatorTest.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/test/java/io/floci/aws/services/redshift/proxy/S3CopySimulatorTest.java b/src/test/java/io/floci/aws/services/redshift/proxy/S3CopySimulatorTest.java index f6f28bb438..fd8a74f67e 100644 --- a/src/test/java/io/floci/aws/services/redshift/proxy/S3CopySimulatorTest.java +++ b/src/test/java/io/floci/aws/services/redshift/proxy/S3CopySimulatorTest.java @@ -23,7 +23,6 @@ import java.io.OutputStream; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; -import java.net.SocketTimeoutException; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; @@ -432,6 +431,12 @@ class S3CopySimulatorTest { }); } + private void assertNoMoreClientBytes() throws IOException { + // The simulator has returned. Half-closing its output puts EOF after any buffered response bytes. + simClient.shutdownOutput(); + assertEquals(-1, testClient.getInputStream().read(), "unexpected data after ReadyForQuery"); + } + private void joinBackend(Thread t) throws InterruptedException { t.join(); Throwable failure = backendFailure.get(); @@ -1013,8 +1018,7 @@ class S3CopySimulatorTest { PostgresWireDecoder in = new PostgresWireDecoder(testClient.getInputStream()); assertEquals('E', in.nextMessage().type()); assertEquals('Z', in.nextMessage().type()); - testClient.setSoTimeout(400); - assertThrows(SocketTimeoutException.class, () -> testClient.getInputStream().read()); + assertNoMoreClientBytes(); } @Test @@ -1131,9 +1135,7 @@ class S3CopySimulatorTest { PostgresWireDecoder in = new PostgresWireDecoder(testClient.getInputStream()); assertEquals('E', in.nextMessage().type()); assertEquals('Z', in.nextMessage().type()); - testClient.setSoTimeout(400); - assertThrows(SocketTimeoutException.class, () -> testClient.getInputStream().read(), - "no leftover or duplicate messages should reach client"); + assertNoMoreClientBytes(); } finally { S3CopySimulator.UNLOAD_TARGET_FILE_BYTES = saved; } @@ -1733,9 +1735,7 @@ class S3CopySimulatorTest { PostgresWireDecoder in = new PostgresWireDecoder(testClient.getInputStream()); assertEquals('E', in.nextMessage().type()); assertEquals('Z', in.nextMessage().type()); - testClient.setSoTimeout(400); - assertThrows(SocketTimeoutException.class, () -> testClient.getInputStream().read(), - "no second response should follow"); + assertNoMoreClientBytes(); } @Test