diff --git a/src/test/java/org/mariadb/jdbc/integration/MultiHostTest.java b/src/test/java/org/mariadb/jdbc/integration/MultiHostTest.java index 71f89c9e7..84cf0a4fe 100644 --- a/src/test/java/org/mariadb/jdbc/integration/MultiHostTest.java +++ b/src/test/java/org/mariadb/jdbc/integration/MultiHostTest.java @@ -250,10 +250,13 @@ public void masterFailover() throws Exception { String url = mDefUrl.replaceAll( - "//([^/]*)/", + "//([^/]*)/" + database, String.format( - "//address=(host=localhost)(port=9999)(type=master),address=(host=localhost)(port=%s)(type=master),address=(host=%s)(port=%s)(type=master)/", - proxy.getLocalPort(), hostAddress.host, hostAddress.port)); + "//address=(host=localhost)(port=9999)(type=master),address=(host=localhost)(port=%s)(type=master),address=(host=%s)(port=%s)(type=master)/" + + database, + proxy.getLocalPort(), + hostAddress.host, + hostAddress.port)); url = url.replaceAll("jdbc:mariadb:", "jdbc:mariadb:sequential:"); if (conf.sslMode() == SslMode.VERIFY_FULL) { url = url.replaceAll("sslMode=verify-full", "sslMode=verify-ca"); @@ -281,7 +284,7 @@ public void masterFailover() throws Exception { stmt.execute("START TRANSACTION"); stmt.execute("SET @con=1"); - proxy.restart(100); + proxy.restart(100, true); try { ResultSet rs = stmt.executeQuery("SELECT @con"); if (rs.next()) { diff --git a/src/test/java/org/mariadb/jdbc/integration/tools/TcpProxy.java b/src/test/java/org/mariadb/jdbc/integration/tools/TcpProxy.java index 7cd68067b..a942554de 100644 --- a/src/test/java/org/mariadb/jdbc/integration/tools/TcpProxy.java +++ b/src/test/java/org/mariadb/jdbc/integration/tools/TcpProxy.java @@ -29,7 +29,7 @@ public TcpProxy(String host, int remoteport) throws IOException { } public void stop() { - socket.kill(); + socket.kill(false); } public void setDelay(int delay) { @@ -46,7 +46,11 @@ public void removeDelay() { * @param sleepTime sleep time in milliseconds */ public void restart(long sleepTime) { - socket.kill(); + restart(sleepTime, false); + } + + public void restart(long sleepTime, boolean rst) { + socket.kill(rst); logger.trace("host proxy port " + socket.getLocalport() + " for " + host + " started"); Executors.newSingleThreadScheduledExecutor().schedule(socket, sleepTime, TimeUnit.MILLISECONDS); } diff --git a/src/test/java/org/mariadb/jdbc/integration/tools/TcpProxySocket.java b/src/test/java/org/mariadb/jdbc/integration/tools/TcpProxySocket.java index 24ca8990b..208a56d84 100644 --- a/src/test/java/org/mariadb/jdbc/integration/tools/TcpProxySocket.java +++ b/src/test/java/org/mariadb/jdbc/integration/tools/TcpProxySocket.java @@ -49,10 +49,11 @@ public void setDelay(int delay) { } /** Kill proxy. */ - public void kill() { + public void kill(boolean rst) { stop = true; try { if (server != null) { + if (rst) server.setSoLinger(true, 0); server.close(); } } catch (IOException e) { @@ -60,6 +61,7 @@ public void kill() { } try { if (client != null) { + if (rst) client.setSoLinger(true, 0); client.close(); } } catch (IOException e) {