mirror of
https://github.com/floci-io/floci.git
synced 2026-12-04 02:28:08 -05:00
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.
This commit is contained in:
1 parent
981469e987
commit
ccf7264d90
1 file changed
+9
-9
@@ -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
|
||||
|
||||
Reference in new issue
Block a user