From f1a8e1c76e526ce7579386d19568a6109ba6d211 Mon Sep 17 00:00:00 2001 From: kolzeq Date: Sat, 5 Dec 2015 16:16:59 +0100 Subject: [PATCH 1/2] [misc] delete test loggin dependency, since it cause error on travis with openjdk ( due to https://bugs.openjdk.java.net/browse/JDK-8044306) --- pom.xml | 12 --------- src/test/java/org/mariadb/jdbc/BaseTest.java | 25 +++++++---------- .../java/org/mariadb/jdbc/BigQueryTest.java | 2 +- .../mariadb/jdbc/CallableStatementTest.java | 7 +++-- .../org/mariadb/jdbc/ConnectionPoolTest.java | 2 +- .../java/org/mariadb/jdbc/ConnectionTest.java | 10 +++---- .../java/org/mariadb/jdbc/DataSourceTest.java | 2 +- src/test/java/org/mariadb/jdbc/DateTest.java | 1 - .../java/org/mariadb/jdbc/DriverTest.java | 6 ++--- src/test/java/org/mariadb/jdbc/MultiTest.java | 27 ------------------- .../jdbc/ServerPrepareStatementTest.java | 5 +--- src/test/java/org/mariadb/jdbc/SslTest.java | 1 - .../jdbc/TimezoneDaylightSavingTimeTest.java | 6 +---- .../jdbc/failover/AuroraFailoverTest.java | 6 ++--- .../jdbc/failover/BaseMultiHostTest.java | 14 +++------- .../jdbc/failover/BaseReplication.java | 13 --------- .../jdbc/failover/GaleraFailoverTest.java | 3 --- .../failover/LoadBalanceFailoverTest.java | 3 --- .../failover/ReplicationFailoverTest.java | 8 ------ .../jdbc/failover/SequentialFailoverTest.java | 7 ----- .../org/mariadb/jdbc/failover/TcpProxy.java | 4 --- .../mariadb/jdbc/failover/TcpProxySocket.java | 6 ----- src/test/resources/logback.xml | 25 ----------------- 23 files changed, 30 insertions(+), 165 deletions(-) delete mode 100644 src/test/resources/logback.xml diff --git a/pom.xml b/pom.xml index d9d4dfdc2..18985e955 100644 --- a/pom.xml +++ b/pom.xml @@ -324,18 +324,6 @@ 4.12 test - - ch.qos.logback - logback-classic - 1.1.3 - test - - - org.slf4j - slf4j-api - 1.7.12 - test - net.java.dev.jna jna diff --git a/src/test/java/org/mariadb/jdbc/BaseTest.java b/src/test/java/org/mariadb/jdbc/BaseTest.java index c6fedcf2e..0bc67a764 100644 --- a/src/test/java/org/mariadb/jdbc/BaseTest.java +++ b/src/test/java/org/mariadb/jdbc/BaseTest.java @@ -6,8 +6,6 @@ import org.junit.rules.TestWatcher; import org.junit.runner.Description; import org.mariadb.jdbc.internal.protocol.Protocol; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.lang.reflect.Method; import java.net.InetAddress; @@ -25,7 +23,6 @@ */ @Ignore public class BaseTest { - protected static final Logger log = LoggerFactory.getLogger(BaseTest.class); protected static final String mDefUrl = "jdbc:mysql://localhost:3306/testj?user=root"; protected static String connU; protected static String connUri; @@ -44,13 +41,13 @@ public class BaseTest { public TestRule watcher = new TestWatcher() { protected void succeeded(Description description) { if (testSingleHost) { - log.debug("finished test success : " + description.getClassName() + "." + description.getMethodName()); + System.out.println("finished test success : " + description.getClassName() + "." + description.getMethodName()); } } protected void failed(Throwable throwable, Description description) { if (testSingleHost) { - log.debug("finished test failed : " + description.getClassName() + "." + description.getMethodName()); + System.out.println("finished test failed : " + description.getClassName() + "." + description.getMethodName()); } } }; @@ -71,9 +68,6 @@ public static void beforeClassBaseTest() throws SQLException { username = urlParser.getUsername(); password = urlParser.getPassword(); - log.trace("Properties parsed from JDBC URL - hostname: " + hostname + ", port: " + port + ", database: " - + database + ", username: " + username + ", password: " + password); - setUri(); sharedConnection = DriverManager.getConnection(connUri); @@ -126,7 +120,7 @@ public static void afterClassBaseTest() throws SQLException { // common function for logging information static void logInfo(String message) { - log.info(message); + System.out.println(message); } /** @@ -282,11 +276,12 @@ boolean checkMaxAllowedPacket(String testName) throws SQLException { int innodbLogFileSize = rs.getInt(1); if (maxAllowedPacket < 16 * 1024 * 1024) { - log.info("test '" + testName + "' skipped due to server variable max_allowed_packet < 16M"); + + System.out.println("test '" + testName + "' skipped due to server variable max_allowed_packet < 16M"); return false; } if (innodbLogFileSize < 16 * 1024 * 1024) { - log.info("test '" + testName + "' skipped due to server variable innodb_log_file_size < 16M"); + System.out.println("test '" + testName + "' skipped due to server variable innodb_log_file_size < 16M"); return false; } return true; @@ -304,11 +299,11 @@ boolean checkMaxAllowedPacketMore40m(String testName) throws SQLException { if (maxAllowedPacket < 40 * 1024 * 1024) { - log.info("test '" + testName + "' skipped due to server variable max_allowed_packet < 40M"); + System.out.println("test '" + testName + "' skipped due to server variable max_allowed_packet < 40M"); return false; } if (innodbLogFileSize < 160 * 1024 * 1024) { - log.info("test '" + testName + "' skipped due to server variable innodb_log_file_size < 160M"); + System.out.println("test '" + testName + "' skipped due to server variable innodb_log_file_size < 160M"); return false; } @@ -335,7 +330,7 @@ boolean hasSuperPrivilege(String testName) throws SQLException { rs.close(); if (!superPrivilege) { - log.info("test '" + testName + "' skipped because user '" + username + "' doesn't have SUPER privileges"); + System.out.println("test '" + testName + "' skipped because user '" + username + "' doesn't have SUPER privileges"); } return superPrivilege; @@ -355,7 +350,7 @@ boolean isLocalConnection(String testName) { } if (isLocal == false) { - log.info("test '" + testName + "' skipped because connection is not local"); + System.out.println("test '" + testName + "' skipped because connection is not local"); } return isLocal; diff --git a/src/test/java/org/mariadb/jdbc/BigQueryTest.java b/src/test/java/org/mariadb/jdbc/BigQueryTest.java index b637fdb11..126416c1f 100644 --- a/src/test/java/org/mariadb/jdbc/BigQueryTest.java +++ b/src/test/java/org/mariadb/jdbc/BigQueryTest.java @@ -97,7 +97,7 @@ public void testError() throws SQLException { rs = connection.createStatement().executeQuery(request); rs.next(); - log.trace(String.valueOf(rs.getString(1).length())); + System.out.println(String.valueOf(rs.getString(1).length())); } finally { connection.close(); } diff --git a/src/test/java/org/mariadb/jdbc/CallableStatementTest.java b/src/test/java/org/mariadb/jdbc/CallableStatementTest.java index f9a9d3719..7b75f6ff4 100644 --- a/src/test/java/org/mariadb/jdbc/CallableStatementTest.java +++ b/src/test/java/org/mariadb/jdbc/CallableStatementTest.java @@ -109,14 +109,13 @@ public void getProcedures() throws SQLException { ResultSetMetaData md = rs.getMetaData(); for (int i = 1; i <= md.getColumnCount(); i++) { - log.trace(md.getColumnLabel(i)); + md.getColumnLabel(i); } - while (rs.next()) { + while (rs.next()) { for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { - log.trace(rs.getObject(i) + " "); + rs.getObject(i); } - } } diff --git a/src/test/java/org/mariadb/jdbc/ConnectionPoolTest.java b/src/test/java/org/mariadb/jdbc/ConnectionPoolTest.java index 5dff48259..b20cd53e1 100644 --- a/src/test/java/org/mariadb/jdbc/ConnectionPoolTest.java +++ b/src/test/java/org/mariadb/jdbc/ConnectionPoolTest.java @@ -111,7 +111,7 @@ public void run() { stmt.execute("insert into t3 values('hello" + Thread.currentThread().getId() + "-" + i + "')"); conn.close(); } catch (SQLException e) { - log.debug(e.getSQLState()); + //eat exception } } } diff --git a/src/test/java/org/mariadb/jdbc/ConnectionTest.java b/src/test/java/org/mariadb/jdbc/ConnectionTest.java index 2b7bdee80..cdc450a50 100644 --- a/src/test/java/org/mariadb/jdbc/ConnectionTest.java +++ b/src/test/java/org/mariadb/jdbc/ConnectionTest.java @@ -90,7 +90,7 @@ public void abortTest() throws SQLException { try { securityManager.checkPermission(sqlPermission); } catch (SecurityException se) { - log.info("test 'abortTest' skipped due to missing policy"); + System.out.println("test 'abortTest' skipped due to missing policy"); return; } } @@ -132,7 +132,7 @@ public void networkTimeoutTest() throws SQLException { try { securityManager.checkPermission(sqlPermission); } catch (SecurityException se) { - log.warn("test 'setNetworkTimeout' skipped due to missing policy"); + System.out.println("test 'setNetworkTimeout' skipped due to missing policy"); return; } } @@ -191,7 +191,6 @@ public void checkMaxAllowedPacket() throws Throwable, SQLException, UnsupportedE ResultSet rs = statement.executeQuery("show variables like 'max_allowed_packet'"); rs.next(); int maxAllowedPacket = rs.getInt(2); - log.trace("max_allowed_packet DB" + maxAllowedPacket); //Create a SQL stream bigger than maxAllowedPacket StringBuilder sb = new StringBuilder(); @@ -207,7 +206,7 @@ public void checkMaxAllowedPacket() throws Throwable, SQLException, UnsupportedE statement.executeUpdate("INSERT INTO dummy VALUES " + sb.toString()); fail("The previous statement should throw an SQLException"); } catch (OutOfMemoryError e) { - log.warn("skip test 'maxAllowedPackedExceptionIsPrettyTest' - not enough memory"); + System.out.println("skip test 'maxAllowedPackedExceptionIsPrettyTest' - not enough memory"); Assume.assumeNoException(e); } catch (SQLException e) { assertTrue(e.getMessage().contains("max_allowed_packet")); @@ -227,10 +226,9 @@ public void checkMaxAllowedPacket() throws Throwable, SQLException, UnsupportedE preparedStatement.executeBatch(); fail("The previous statement should throw an SQLException"); } catch (OutOfMemoryError e) { - log.warn("skip second test 'maxAllowedPackedExceptionIsPrettyTest' - not enough memory"); + System.out.println("skip second test 'maxAllowedPackedExceptionIsPrettyTest' - not enough memory"); Assume.assumeNoException(e); } catch (SQLException e) { - log.trace("normal SQlExeption " + e.getMessage()); assertTrue(e.getMessage().contains("max_allowed_packet")); } catch (Exception e) { fail("The previous statement should throw an SQLException not a general Exception"); diff --git a/src/test/java/org/mariadb/jdbc/DataSourceTest.java b/src/test/java/org/mariadb/jdbc/DataSourceTest.java index 5c3874be9..ef40e2862 100644 --- a/src/test/java/org/mariadb/jdbc/DataSourceTest.java +++ b/src/test/java/org/mariadb/jdbc/DataSourceTest.java @@ -116,7 +116,7 @@ public void setPortTest() throws SQLException { ds.getConnection(username, password); Assert.fail(); } catch (SQLException e) { - log.trace("port error : " + e.getMessage()); + //normal error } } diff --git a/src/test/java/org/mariadb/jdbc/DateTest.java b/src/test/java/org/mariadb/jdbc/DateTest.java index 837490baf..86eb4c836 100644 --- a/src/test/java/org/mariadb/jdbc/DateTest.java +++ b/src/test/java/org/mariadb/jdbc/DateTest.java @@ -398,7 +398,6 @@ public void serverTimezone() throws Exception { java.sql.Timestamp ts = rs.getTimestamp(1); long differenceToServer = ts.getTime() - now.getTime(); long diff = Math.abs(differenceToServer - totalOffset); - log.trace("diff : " + diff); /* query take less than a second but taking in account server and client time second diff ... */ assertTrue(diff < 5000); diff --git a/src/test/java/org/mariadb/jdbc/DriverTest.java b/src/test/java/org/mariadb/jdbc/DriverTest.java index 70db33ffc..7931818d5 100644 --- a/src/test/java/org/mariadb/jdbc/DriverTest.java +++ b/src/test/java/org/mariadb/jdbc/DriverTest.java @@ -1095,11 +1095,11 @@ public void namedpipe() throws Exception { if (rs.getBoolean(1)) { namedPipeName = rs.getString(2); } else { - log.info("test 'namedpipe' skipped"); + System.out.println("test 'namedpipe' skipped"); } } catch (SQLException e) { //named pipe not found, - log.info("test 'namedpipe' skipped"); + System.out.println("test 'namedpipe' skipped"); } //skip test if no namedPipeName was obtained because then we do not use a socket connection @@ -1148,7 +1148,7 @@ public void localSocket() throws Exception { if (!rs.next()) { return; } - log.info("os:" + rs.getString(1) + " path:" + rs.getString(2)); + System.out.println("os:" + rs.getString(1) + " path:" + rs.getString(2)); String os = rs.getString(1); if (os.toLowerCase().startsWith("win")) { return; diff --git a/src/test/java/org/mariadb/jdbc/MultiTest.java b/src/test/java/org/mariadb/jdbc/MultiTest.java index 2c0812256..f6ae849de 100644 --- a/src/test/java/org/mariadb/jdbc/MultiTest.java +++ b/src/test/java/org/mariadb/jdbc/MultiTest.java @@ -75,7 +75,6 @@ public void rewriteSelectQueryServerPrepared() throws Throwable { @Test public void basicTest() throws SQLException { - log.trace("basicTest begin"); Connection connection = null; try { connection = setConnection("&allowMultiQueries=true"); @@ -94,7 +93,6 @@ public void basicTest() throws SQLException { } assertTrue(count > 0); assertFalse(statement.getMoreResults()); - log.trace("basicTest end"); } finally { connection.close(); } @@ -102,7 +100,6 @@ public void basicTest() throws SQLException { @Test public void updateTest() throws SQLException { - log.trace("updateTest begin"); Connection connection = null; try { connection = setConnection("&allowMultiQueries=true"); @@ -110,7 +107,6 @@ public void updateTest() throws SQLException { statement.execute("update MultiTestt5 set test='a " + System.currentTimeMillis() + "' where id = 2;select * from MultiTestt2;"); int updateNb = statement.getUpdateCount(); - log.trace("statement.getUpdateCount() " + updateNb); assertTrue(updateNb == 2); assertTrue(statement.getMoreResults()); ResultSet rs = statement.getResultSet(); @@ -120,7 +116,6 @@ public void updateTest() throws SQLException { } assertTrue(count > 0); assertFalse(statement.getMoreResults()); - log.trace("updateTest end"); } finally { connection.close(); } @@ -128,7 +123,6 @@ public void updateTest() throws SQLException { @Test public void updateTest2() throws SQLException { - log.trace("updateTest2 begin"); Connection connection = null; try { connection = setConnection("&allowMultiQueries=true"); @@ -144,9 +138,7 @@ public void updateTest2() throws SQLException { statement.getMoreResults(); int updateNb = statement.getUpdateCount(); - log.trace("statement.getUpdateCount() " + updateNb); assertEquals(2, updateNb); - log.trace("updateTest2 end"); } finally { connection.close(); } @@ -154,7 +146,6 @@ public void updateTest2() throws SQLException { @Test public void selectTest() throws SQLException { - log.trace("selectTest begin"); Connection connection = null; try { connection = setConnection("&allowMultiQueries=true"); @@ -172,7 +163,6 @@ public void selectTest() throws SQLException { count++; } assertTrue(count > 0); - log.trace("selectTest end"); } finally { connection.close(); } @@ -180,7 +170,6 @@ public void selectTest() throws SQLException { @Test public void setMaxRowsMulti() throws Exception { - log.trace("setMaxRowsMulti begin"); Connection connection = null; try { connection = setConnection("&allowMultiQueries=true"); @@ -211,7 +200,6 @@ public void setMaxRowsMulti() throws Exception { } rs.close(); assertEquals(1, cnt); - log.trace("setMaxRowsMulti end"); } finally { connection.close(); } @@ -224,17 +212,13 @@ public void setMaxRowsMulti() throws Exception { */ @Test public void rewriteBatchedStatementsDisabledInsertionTest() throws SQLException { - log.trace("rewriteBatchedStatementsDisabledInsertionTest begin"); verifyInsertBehaviorBasedOnRewriteBatchedStatements(Boolean.FALSE, 3000, 3000); - log.trace("rewriteBatchedStatementsDisabledInsertionTest end"); } @Test public void rewriteBatchedStatementsEnabledInsertionTest() throws SQLException { - log.trace("rewriteBatchedStatementsEnabledInsertionTest begin"); //On batch mode, single insert query will be sent to MariaDB server. verifyInsertBehaviorBasedOnRewriteBatchedStatements(Boolean.TRUE, 3000, 1); - log.trace("rewriteBatchedStatementsEnabledInsertionTest end"); } @@ -367,7 +351,6 @@ public void rewriteBatchedStatementsWithQueryFirstAndLAst() throws SQLException */ @Test public void rewriteBatchedStatementsSemicolon() throws SQLException { - log.trace("rewriteBatchedStatementsSemicolon begin"); // set the rewrite batch statements parameter Properties props = new Properties(); props.setProperty("rewriteBatchedStatements", "true"); @@ -420,7 +403,6 @@ public void rewriteBatchedStatementsSemicolon() throws SQLException { assertEquals(4, retrieveSessionVariableFromServer(tmpConnection, "Com_insert") - secondCurrentInsert); } finally { - log.trace("rewriteBatchedStatementsSemicolon end"); if (tmpConnection != null) { tmpConnection.close(); } @@ -473,7 +455,6 @@ public void semicolonTest() throws SQLException { */ @Test public void rewriteBatchedStatementsUpdateTest() throws SQLException { - log.trace("rewriteBatchedStatementsUpdateTest begin"); // set the rewrite batch statements parameter Properties props = new Properties(); props.setProperty("rewriteBatchedStatements", "true"); @@ -503,7 +484,6 @@ public void rewriteBatchedStatementsUpdateTest() throws SQLException { verifyUpdateCount(tmpConnection, cycles); //1000 update commande launched assertEquals(cycles * 2, totalUpdates); // 2000 rows updates } finally { - log.trace("rewriteBatchedStatementsUpdateTest end"); if (tmpConnection != null) { tmpConnection.close(); } @@ -518,7 +498,6 @@ public void rewriteBatchedStatementsUpdateTest() throws SQLException { */ @Test public void testMultipleExecuteBatch() throws SQLException { - log.trace("testMultipleExecuteBatch begin"); // set the rewrite batch statements parameter Properties props = new Properties(); props.setProperty("rewriteBatchedStatements", "true"); @@ -548,7 +527,6 @@ public void testMultipleExecuteBatch() throws SQLException { updateCounts = preparedStatement.executeBatch(); assertEquals(1, updateCounts.length); } finally { - log.trace("testMultipleExecuteBatch end"); if (tmpConnection != null) { tmpConnection.close(); } @@ -557,7 +535,6 @@ public void testMultipleExecuteBatch() throws SQLException { @Test public void rewriteBatchedStatementsInsertWithDuplicateRecordsTest() throws SQLException { - log.trace("rewriteBatchedStatementsInsertWithDuplicateRecordsTest begin"); Properties props = new Properties(); props.setProperty("rewriteBatchedStatements", "true"); props.setProperty("allowMultiQueries", "true"); @@ -581,7 +558,6 @@ public void rewriteBatchedStatementsInsertWithDuplicateRecordsTest() throws SQLE verifyInsertCount(tmpConnection, 1); verifyUpdateCount(tmpConnection, 0); } finally { - log.trace("rewriteBatchedStatementsInsertWithDuplicateRecordsTest end"); if (tmpConnection != null) { tmpConnection.close(); } @@ -590,7 +566,6 @@ public void rewriteBatchedStatementsInsertWithDuplicateRecordsTest() throws SQLE @Test public void updateCountTest() throws SQLException { - log.trace("updateCountTest begin"); Properties props = new Properties(); props.setProperty("rewriteBatchedStatements", "true"); props.setProperty("allowMultiQueries", "true"); @@ -634,13 +609,11 @@ public void updateCountTest() throws SQLException { sqlUpdate.addBatch(); int[] updateCounts = sqlUpdate.executeBatch(); - log.trace("updateCounts : " + updateCounts.length); Assert.assertEquals(3, updateCounts.length); Assert.assertEquals(1, updateCounts[0]); Assert.assertEquals(0, updateCounts[1]); Assert.assertEquals(2, updateCounts[2]); } finally { - log.trace("updateCountTest end"); if (tmpConnection != null) { tmpConnection.close(); } diff --git a/src/test/java/org/mariadb/jdbc/ServerPrepareStatementTest.java b/src/test/java/org/mariadb/jdbc/ServerPrepareStatementTest.java index bb53f63f0..7445f72e1 100644 --- a/src/test/java/org/mariadb/jdbc/ServerPrepareStatementTest.java +++ b/src/test/java/org/mariadb/jdbc/ServerPrepareStatementTest.java @@ -121,14 +121,12 @@ public void prepStmtCacheSizeTest1() throws Throwable { ResultSet rs = statement.executeQuery("show global status like 'Prepared_stmt_count'"); rs.next(); int prepareServerStatement = rs.getInt(2); - log.trace("server side : " + prepareServerStatement); connection.prepareStatement("INSERT INTO ServerPrepareStatementCacheSize3(test) " + "VALUES (?)"); rs = statement.executeQuery("show global status like 'Prepared_stmt_count'"); rs.next(); int prepareServerStatement2 = rs.getInt(2); - log.trace("server side before closing: " + prepareServerStatement2); assertTrue(prepareServerStatement2 == prepareServerStatement + 1); } finally { @@ -145,7 +143,6 @@ public void prepStmtCacheSizeTest() throws Throwable { PreparedStatement[] sts = new PreparedStatement[20]; for (int i = 0; i < 20; i++) { String sql = "INSERT INTO ServerPrepareStatementCacheSize(id, test) VALUES (" + (i + 1) + ",?)"; - log.trace(sql); sts[i] = connection.prepareStatement(sql); } //check max cache size @@ -425,7 +422,7 @@ public void readerTest() throws Throwable { PreparedStatement ps = connection.prepareStatement( "INSERT INTO ServerPrepareStatementCacheSize3(test) VALUES (?)"); Reader reader = new BufferedReader(new InputStreamReader( - ClassLoader.getSystemResourceAsStream("logback.xml"))); + ClassLoader.getSystemResourceAsStream("style.xml"))); ps.setCharacterStream(1, reader); ps.addBatch(); diff --git a/src/test/java/org/mariadb/jdbc/SslTest.java b/src/test/java/org/mariadb/jdbc/SslTest.java index 2776a30a9..30d7301f6 100644 --- a/src/test/java/org/mariadb/jdbc/SslTest.java +++ b/src/test/java/org/mariadb/jdbc/SslTest.java @@ -43,7 +43,6 @@ public void checkSsl() throws SQLException { ResultSet rs = sharedConnection.createStatement().executeQuery("select @@ssl_cert"); rs.next(); serverCertificatePath = rs.getString(1); - log.trace("Server certificate path: {}", serverCertificatePath); rs.close(); } diff --git a/src/test/java/org/mariadb/jdbc/TimezoneDaylightSavingTimeTest.java b/src/test/java/org/mariadb/jdbc/TimezoneDaylightSavingTimeTest.java index 87d1c0407..ba6fa4a03 100644 --- a/src/test/java/org/mariadb/jdbc/TimezoneDaylightSavingTimeTest.java +++ b/src/test/java/org/mariadb/jdbc/TimezoneDaylightSavingTimeTest.java @@ -38,7 +38,6 @@ public static void initClass() throws SQLException { ResultSet rs = st.executeQuery("SELECT count(*) from mysql.time_zone_name " + "where Name in ('Europe/Paris','Canada/Atlantic')"); rs.next(); - log.trace("time zone information : " + rs.getInt(1)); if (rs.getInt(1) == 0) { ResultSet rs2 = st.executeQuery("SELECT DATABASE()"); rs2.next(); @@ -509,10 +508,7 @@ public void testDayLightnotUtC() throws SQLException { try { st.executeQuery("SET GLOBAL time_zone = 'Europe/Paris'"); rs = st.executeQuery("SHOW GLOBAL VARIABLES LIKE 'time_zone';"); - if (rs.next()) { - log.trace("new time_zone =" + rs.getString(2) + " was " + serverTimeZone); - } - + rs.next(); createTable("daylightCanada", "id int, tt TIMESTAMP(6)"); Calendar quarterBeforeChangingHour = Calendar.getInstance(TimeZone.getTimeZone("Canada/Atlantic")); diff --git a/src/test/java/org/mariadb/jdbc/failover/AuroraFailoverTest.java b/src/test/java/org/mariadb/jdbc/failover/AuroraFailoverTest.java index 76f742c0b..9fc8d4a80 100644 --- a/src/test/java/org/mariadb/jdbc/failover/AuroraFailoverTest.java +++ b/src/test/java/org/mariadb/jdbc/failover/AuroraFailoverTest.java @@ -48,7 +48,7 @@ public void testErrorWriteOnReplica() throws SQLException { Assert.assertTrue(connection.isReadOnly()); try { stmt.execute("drop table if exists auroraDelete" + jobId); - log.error("ERROR - > must not be able to write on slave. check if you database is start with --read-only"); + System.out.println("ERROR - > must not be able to write on slave. check if you database is start with --read-only"); Assert.fail(); } catch (SQLException e) { //normal exception @@ -131,8 +131,6 @@ public void pingReconnectAfterRestart() throws Throwable { boolean loop = true; while (loop) { if (!connection.isClosed()) { - log.trace("reconnection with failover loop after : " - + (System.currentTimeMillis() - stoppedTime) + "ms"); loop = false; } if (System.currentTimeMillis() - restartTime > 15 * 1000) { @@ -192,7 +190,7 @@ public void failoverMasterWithAutoConnectAndTransaction() throws Throwable { st.execute("insert into multinodeTransaction" + jobId + " (id, amount) VALUE (2 , 10)"); Assert.fail(); } catch (SQLException e) { - log.trace("normal error : " + e.getMessage()); + //normal error } restartProxy(masterServerId); try { diff --git a/src/test/java/org/mariadb/jdbc/failover/BaseMultiHostTest.java b/src/test/java/org/mariadb/jdbc/failover/BaseMultiHostTest.java index a0a512d4f..666dd2a2c 100644 --- a/src/test/java/org/mariadb/jdbc/failover/BaseMultiHostTest.java +++ b/src/test/java/org/mariadb/jdbc/failover/BaseMultiHostTest.java @@ -10,8 +10,6 @@ import org.mariadb.jdbc.internal.failover.AbstractMastersListener; import org.mariadb.jdbc.internal.protocol.Protocol; import org.mariadb.jdbc.internal.util.constant.HaMode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.io.IOException; import java.lang.reflect.Method; @@ -28,7 +26,6 @@ */ @Ignore public class BaseMultiHostTest { - protected static final Logger log = LoggerFactory.getLogger(BaseMultiHostTest.class); protected static String initialGaleraUrl; protected static String initialAuroraUrl; @@ -55,11 +52,11 @@ public class BaseMultiHostTest { @Rule public TestRule watcher = new TestWatcher() { protected void starting(Description description) { - log.debug("Starting test: " + description.getMethodName()); + System.out.println("Starting test: " + description.getMethodName()); } protected void finished(Description description) { - log.debug("finished test: " + description.getMethodName()); + System.out.println("finished test: " + description.getMethodName()); } }; @@ -137,8 +134,6 @@ private static String createProxies(String tmpUrl, HaMode proxyType) throws SQLE try { hostAddress = tmpUrlParser.getHostAddresses().get(i); tcpProxies[i] = new TcpProxy(hostAddress.host, hostAddress.port); - log.trace("creating socket " + proxyType + " : " + hostAddress.host + ":" + hostAddress.port - + " -> localhost:" + tcpProxies[i].getLocalPort()); sockethosts += ",address=(host=localhost)(port=" + tcpProxies[i].getLocalPort() + ")" + ((hostAddress.type != null) ? "(type=" + hostAddress.type + ")" : ""); } catch (IOException e) { @@ -213,7 +208,6 @@ protected Connection getNewConnection(String additionnalConnectionData, boolean * @param millissecond milliseconds */ public void stopProxy(int hostNumber, long millissecond) { - log.trace("stopping host " + hostNumber); proxySet.get(currentType)[hostNumber - 1].restart(millissecond); } @@ -222,7 +216,6 @@ public void stopProxy(int hostNumber, long millissecond) { * @param hostNumber host number (first is 1) */ public void stopProxy(int hostNumber) { - log.trace("stopping host " + hostNumber); proxySet.get(currentType)[hostNumber - 1].stop(); } @@ -231,7 +224,6 @@ public void stopProxy(int hostNumber) { * @param hostNumber host number (first is 1) */ public void restartProxy(int hostNumber) { - log.trace("restart host " + hostNumber); if (hostNumber != -1) { proxySet.get(currentType)[hostNumber - 1].restart(); } @@ -278,7 +270,7 @@ public boolean hasSuperPrivilege(Connection connection, String testName) throws rs.close(); if (superPrivilege) { - log.trace("test '" + testName + "' skipped because user '" + username + "' has SUPER privileges"); + System.out.println("test '" + testName + "' skipped because user '" + username + "' has SUPER privileges"); } return superPrivilege; diff --git a/src/test/java/org/mariadb/jdbc/failover/BaseReplication.java b/src/test/java/org/mariadb/jdbc/failover/BaseReplication.java index d3e0840cf..f11e904bb 100644 --- a/src/test/java/org/mariadb/jdbc/failover/BaseReplication.java +++ b/src/test/java/org/mariadb/jdbc/failover/BaseReplication.java @@ -3,8 +3,6 @@ import org.junit.Assert; import org.junit.Assume; import org.junit.Test; -import org.mariadb.jdbc.HostAddress; -import org.mariadb.jdbc.internal.protocol.Protocol; import java.sql.Connection; import java.sql.SQLException; @@ -46,7 +44,6 @@ public void failoverSlaveToMaster() throws Throwable { connection.createStatement().execute("SELECT 1"); int currentServerId = getServerId(connection); - log.trace("masterServerId = " + masterServerId + "/currentServerId = " + currentServerId); Assert.assertTrue(masterServerId == currentServerId); Assert.assertFalse(connection.isReadOnly()); } finally { @@ -83,10 +80,8 @@ public void failoverSlaveAndMasterWithoutAutoConnect() throws Throwable { try { connection = getNewConnection("&retriesAllDown=1", true); int masterServerId = getServerId(connection); - log.trace("master server_id = " + masterServerId); connection.setReadOnly(true); int firstSlaveId = getServerId(connection); - log.trace("slave1 server_id = " + firstSlaveId); stopProxy(masterServerId); stopProxy(firstSlaveId); @@ -111,12 +106,10 @@ public void reconnectSlaveAndMasterWithAutoConnect() throws Throwable { //search actual server_id for master and slave int masterServerId = getServerId(connection); - log.trace("master server_id = " + masterServerId); connection.setReadOnly(true); int firstSlaveId = getServerId(connection); - log.trace("slave1 server_id = " + firstSlaveId); stopProxy(masterServerId); stopProxy(firstSlaveId); @@ -124,7 +117,6 @@ public void reconnectSlaveAndMasterWithAutoConnect() throws Throwable { //must reconnect to the second slave without error connection.createStatement().execute("SELECT 1"); int currentSlaveId = getServerId(connection); - log.trace("currentSlaveId server_id = " + currentSlaveId); Assert.assertTrue(currentSlaveId != firstSlaveId); Assert.assertTrue(currentSlaveId != masterServerId); } finally { @@ -221,14 +213,12 @@ public void randomConnection() throws Throwable { try { connection = getNewConnection(false); int serverId = getServerId(connection); - log.trace("master server found " + serverId); if (i > 0) { Assert.assertTrue(masterId == serverId); } masterId = serverId; connection.setReadOnly(true); int replicaId = getServerId(connection); - log.trace("++++++++++++slave server found " + replicaId); MutableInt count = connectionMap.get(String.valueOf(replicaId)); if (count == null) { connectionMap.put(String.valueOf(replicaId), new MutableInt()); @@ -247,10 +237,8 @@ public void randomConnection() throws Throwable { Assert.assertTrue(connectionMap.size() >= 2); for (String key : connectionMap.keySet()) { Integer connectionCount = connectionMap.get(key).get(); - log.trace(" ++++ Server " + key + " : " + connectionCount + " connections "); Assert.assertTrue(connectionCount > 1); } - log.trace("randomConnection OK"); } @@ -313,7 +301,6 @@ public void run() { long start = System.currentTimeMillis(); Thread.sleep(2400); // wait that slave reconnection loop is launched connection.close(); - log.trace("close take " + (System.currentTimeMillis() - start) + "ms"); } catch (Throwable e) { e.printStackTrace(); Assert.fail(); diff --git a/src/test/java/org/mariadb/jdbc/failover/GaleraFailoverTest.java b/src/test/java/org/mariadb/jdbc/failover/GaleraFailoverTest.java index d9dc0161c..e33741d26 100644 --- a/src/test/java/org/mariadb/jdbc/failover/GaleraFailoverTest.java +++ b/src/test/java/org/mariadb/jdbc/failover/GaleraFailoverTest.java @@ -46,7 +46,6 @@ public void connectionOrder() throws Throwable { for (int i = 0; i < 20; i++) { Connection connection = getNewConnection(false); int serverId = getServerId(connection); - log.trace("master server found " + serverId); MutableInt count = connectionMap.get(String.valueOf(serverId)); if (count == null) { connectionMap.put(String.valueOf(serverId), new MutableInt()); @@ -59,10 +58,8 @@ public void connectionOrder() throws Throwable { Assert.assertTrue(connectionMap.size() >= 2); for (String key : connectionMap.keySet()) { Integer connectionCount = connectionMap.get(key).get(); - log.trace(" ++++ Server " + key + " : " + connectionCount + " connections "); Assert.assertTrue(connectionCount > 1); } - log.trace("randomConnection OK"); } } diff --git a/src/test/java/org/mariadb/jdbc/failover/LoadBalanceFailoverTest.java b/src/test/java/org/mariadb/jdbc/failover/LoadBalanceFailoverTest.java index d1d26ed63..8b72d2408 100644 --- a/src/test/java/org/mariadb/jdbc/failover/LoadBalanceFailoverTest.java +++ b/src/test/java/org/mariadb/jdbc/failover/LoadBalanceFailoverTest.java @@ -56,7 +56,6 @@ public void randomConnection() throws Throwable { for (int i = 0; i < 20; i++) { Connection connection = getNewConnection(false); int serverId = getServerId(connection); - log.trace("master server found " + serverId); MutableInt count = connectionMap.get(String.valueOf(serverId)); if (count == null) { connectionMap.put(String.valueOf(serverId), new MutableInt()); @@ -69,10 +68,8 @@ public void randomConnection() throws Throwable { Assert.assertTrue(connectionMap.size() >= 2); for (String key : connectionMap.keySet()) { Integer connectionCount = connectionMap.get(key).get(); - log.trace(" ++++ Server " + key + " : " + connectionCount + " connections "); Assert.assertTrue(connectionCount > 1); } - log.trace("randomConnection OK"); } diff --git a/src/test/java/org/mariadb/jdbc/failover/ReplicationFailoverTest.java b/src/test/java/org/mariadb/jdbc/failover/ReplicationFailoverTest.java index 5a9f77f60..2cbdd2018 100644 --- a/src/test/java/org/mariadb/jdbc/failover/ReplicationFailoverTest.java +++ b/src/test/java/org/mariadb/jdbc/failover/ReplicationFailoverTest.java @@ -48,7 +48,6 @@ public void testErrorWriteOnSlave() throws SQLException { Assume.assumeTrue(false); } stmt.execute("drop table if exists replicationDelete" + jobId); - log.error("ERROR - > must not be able to write on slave "); fail(); } catch (SQLException e) { //normal exception @@ -92,11 +91,8 @@ public void pingReconnectAfterFailover() throws Throwable { while (loop) { try { Thread.sleep(250); - log.trace("time : " + (System.currentTimeMillis() - stoppedTime) + "ms"); int currentHost = getServerId(connection); if (masterServerId == currentHost) { - log.trace("reconnection with failover loop after : " + (System.currentTimeMillis() - stoppedTime) - + "ms"); assertTrue((System.currentTimeMillis() - stoppedTime) > 5 * 1000); loop = false; } @@ -138,10 +134,8 @@ public void masterWithoutFailover() throws Throwable { try { connection = getNewConnection("&retriesAllDown=1", true); int masterServerId = getServerId(connection); - log.trace("master server_id = " + masterServerId); connection.setReadOnly(true); int firstSlaveId = getServerId(connection); - log.trace("slave1 server_id = " + firstSlaveId); connection.setReadOnly(false); stopProxy(masterServerId); @@ -183,8 +177,6 @@ public void checkBackOnMasterOnSlaveFail() throws Throwable { Thread.sleep(250); try { if (!connection.isReadOnly()) { - log.trace("reconnection to master with failover loop after : " + (System.currentTimeMillis() - - stoppedTime) + "ms"); assertTrue((System.currentTimeMillis() - stoppedTime) > 10 * 1000); loop = false; } diff --git a/src/test/java/org/mariadb/jdbc/failover/SequentialFailoverTest.java b/src/test/java/org/mariadb/jdbc/failover/SequentialFailoverTest.java index fb7a51652..93f9ef3e5 100644 --- a/src/test/java/org/mariadb/jdbc/failover/SequentialFailoverTest.java +++ b/src/test/java/org/mariadb/jdbc/failover/SequentialFailoverTest.java @@ -75,7 +75,6 @@ public void checkStaticBlacklist() throws Throwable { //check blacklist size try { Protocol protocol = getProtocolFromConnection(connection); - log.trace("backlist size : " + protocol.getProxy().getListener().getBlacklist().size()); Assert.assertTrue(protocol.getProxy().getListener().getBlacklist().size() == 1); //replace proxified HostAddress by normal one @@ -116,15 +115,12 @@ public void checkStaticBlacklist() throws Throwable { public void testMultiHostWriteOnMaster() throws Throwable { Assume.assumeTrue(initialGaleraUrl != null); Connection connection = null; - log.trace("testMultiHostWriteOnMaster begin"); try { connection = getNewConnection(); Statement stmt = connection.createStatement(); stmt.execute("drop table if exists multinode"); stmt.execute("create table multinode (id int not null primary key auto_increment, test VARCHAR(10))"); - log.trace("testMultiHostWriteOnMaster OK"); } finally { - log.trace("testMultiHostWriteOnMaster done"); if (connection != null) { connection.close(); } @@ -152,8 +148,6 @@ public void pingReconnectAfterRestart() throws Throwable { boolean loop = true; while (loop) { if (!connection.isClosed()) { - log.trace("reconnection with failover loop after : " + (System.currentTimeMillis() - stoppedTime) - + "ms"); loop = false; } if (System.currentTimeMillis() - restartTime > 15 * 1000) { @@ -182,7 +176,6 @@ public void run() { try { connection2 = getNewConnection(); int otherServerId = getServerId(connection2); - log.trace("connected to server " + otherServerId); Assert.assertTrue(otherServerId != firstServerId); Protocol protocol = getProtocolFromConnection(connection2); Assert.assertTrue(blacklist.keySet().toArray()[0].equals(protocol.getProxy().getListener() diff --git a/src/test/java/org/mariadb/jdbc/failover/TcpProxy.java b/src/test/java/org/mariadb/jdbc/failover/TcpProxy.java index c276ce371..be97c448e 100644 --- a/src/test/java/org/mariadb/jdbc/failover/TcpProxy.java +++ b/src/test/java/org/mariadb/jdbc/failover/TcpProxy.java @@ -1,15 +1,11 @@ package org.mariadb.jdbc.failover; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.IOException; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; public class TcpProxy { - protected static final Logger log = LoggerFactory.getLogger(TcpProxy.class); String host; int remoteport; diff --git a/src/test/java/org/mariadb/jdbc/failover/TcpProxySocket.java b/src/test/java/org/mariadb/jdbc/failover/TcpProxySocket.java index 6a88ee5a1..ba4859965 100644 --- a/src/test/java/org/mariadb/jdbc/failover/TcpProxySocket.java +++ b/src/test/java/org/mariadb/jdbc/failover/TcpProxySocket.java @@ -1,15 +1,11 @@ package org.mariadb.jdbc.failover; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.*; import java.net.BindException; import java.net.ServerSocket; import java.net.Socket; public class TcpProxySocket implements Runnable { - protected static final Logger log = LoggerFactory.getLogger(TcpProxySocket.class); String host; int remoteport; @@ -111,7 +107,6 @@ public void run() { try { while ((bytesRead = fromClient.read(request)) != -1) { toServer.write(request, 0, bytesRead); - log.trace(bytesRead + "toServer--->" + new String(request, "UTF-8") + "<---"); toServer.flush(); } } catch (IOException e) { @@ -129,7 +124,6 @@ public void run() { while ((bytesRead = fromServer.read(reply)) != -1) { try { Thread.sleep(1); - log.trace(bytesRead + " toClient--->" + new String(reply, "UTF-8") + "<---"); } catch (InterruptedException e) { e.printStackTrace(); } diff --git a/src/test/resources/logback.xml b/src/test/resources/logback.xml deleted file mode 100644 index e3c78ad70..000000000 --- a/src/test/resources/logback.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n - - - - - - - - - - - - - - - - \ No newline at end of file From b597835ae278fd535e9c2146c395ec07d741db4d Mon Sep 17 00:00:00 2001 From: kolzeq Date: Sat, 5 Dec 2015 17:51:56 +0100 Subject: [PATCH 2/2] [misc] test unstable correction --- .../jdbc/ServerPrepareStatementTest.java | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/src/test/java/org/mariadb/jdbc/ServerPrepareStatementTest.java b/src/test/java/org/mariadb/jdbc/ServerPrepareStatementTest.java index 7445f72e1..62bffa746 100644 --- a/src/test/java/org/mariadb/jdbc/ServerPrepareStatementTest.java +++ b/src/test/java/org/mariadb/jdbc/ServerPrepareStatementTest.java @@ -76,30 +76,6 @@ public void serverExecutionTest() throws SQLException { } } - @Test - public void withoutParameterClientExecutionTest() throws SQLException { - Connection connection = null; - try { - connection = setConnection(); - Statement statement = connection.createStatement(); - ResultSet rs = statement.executeQuery("show global status like 'Prepared_stmt_count'"); - assertTrue(rs.next()); - final int nbStatementCount = rs.getInt(2); - - PreparedStatement ps = connection.prepareStatement( - "INSERT INTO ServerPrepareStatementTest (test) VALUES (1)"); - ps.addBatch(); - ps.execute(); - - rs = statement.executeQuery("show global status like 'Prepared_stmt_count'"); - assertTrue(rs.next()); - System.out.println("client : rs.getInt(2) = " + rs.getInt(2)); - assertTrue(rs.getInt(2) == nbStatementCount); - } finally { - connection.close(); - } - } - @Test public void serverCacheStatementTest() throws Throwable { Protocol protocol = getProtocolFromConnection(sharedConnection);