diff --git a/lib/mo-tester-1.0-SNAPSHOT.jar b/lib/mo-tester-1.0-SNAPSHOT.jar index 03ec74e4e..d6127a1d8 100644 Binary files a/lib/mo-tester-1.0-SNAPSHOT.jar and b/lib/mo-tester-1.0-SNAPSHOT.jar differ diff --git a/mo.yml b/mo.yml index b441d91e5..3adc48911 100755 --- a/mo.yml +++ b/mo.yml @@ -15,8 +15,12 @@ jdbc: useLocalSessionState: "true" zeroDateTimeBehavior: "CONVERT_TO_NULL" failoverReadOnly: "false" + initialTimeout: 60 + autoReconnect: "true" + maxReconnects: 4 serverTimezone: "Asia/Shanghai" socketTimeout: 120000 + #users user: name: "dump" diff --git a/src/main/java/io/mo/Tester.java b/src/main/java/io/mo/Tester.java index cd9de4e00..91445953c 100755 --- a/src/main/java/io/mo/Tester.java +++ b/src/main/java/io/mo/Tester.java @@ -320,6 +320,10 @@ public static boolean isInclude(String name){ public static void cleanDatabases(){ Connection connection = ConnectionManager.getConnection(); + if(connection == null){ + LOG.error("Failed to clean databases,please check the error,the program will exit."); + System.exit(1); + } String dropDB = "DROP DATABASE IF EXISTS `%s`"; String[] dbs = RunConfUtil.getBuiltinDb(); try { diff --git a/src/main/java/io/mo/db/ConnectionManager.java b/src/main/java/io/mo/db/ConnectionManager.java index 6c7ad52cb..1d61680cf 100755 --- a/src/main/java/io/mo/db/ConnectionManager.java +++ b/src/main/java/io/mo/db/ConnectionManager.java @@ -34,7 +34,7 @@ public static Connection getConnection(int index){ if(!server_up) return null; //get db connection,if failed,retry 3 times 10 s interval - for(int i = 0; i < 3; i++) { + //for(int i = 0; i < 3; i++) { try { Class.forName(driver); if (connections[index] == null || connections[index].isClosed()) { @@ -43,7 +43,8 @@ public static Connection getConnection(int index){ } return connections[index]; } catch (SQLException e) { - LOG.error("The mo-tester can not get valid conneciton from mo with[user="+userName+", pwd="+pwd+"], and will wait 10 seconds and retry..."); + //LOG.error("The mo-tester can not get valid conneciton from mo with[user="+userName+", pwd="+pwd+"], and will wait 10 seconds and retry..."); + LOG.error(e.getMessage()); try { Thread.sleep(10000); } catch (InterruptedException ex) { @@ -52,9 +53,9 @@ public static Connection getConnection(int index){ } catch (ClassNotFoundException e) { e.printStackTrace(); } - } - - LOG.error("The mo-tester still can not get valid conneciton from mo, the following cases wil not be executed!"); + //} + + LOG.error("The mo-tester can not get valid conneciton from mo with[user="+userName+", pwd="+pwd+"], the following cases wil not be executed!"); server_up = false; return null; } @@ -64,7 +65,7 @@ public static Connection getConnection(int index, String userName, String pwd){ if(!server_up) return null; //get db connection,if failed,retry 3 times 10 s interval - for(int i = 0; i < 3; i++) { + //for(int i = 0; i < 3; i++) { try { Class.forName(driver); if (connections[index] == null || connections[index].isClosed()) { @@ -74,7 +75,8 @@ public static Connection getConnection(int index, String userName, String pwd){ } return connections[index]; } catch (SQLException e) { - LOG.error("The mo-tester can not get valid conneciton from mo with[user="+userName+", pwd="+pwd+"], and will wait 10 seconds and retry..."); + //LOG.error("The mo-tester can not get valid conneciton from mo with[user="+userName+", pwd="+pwd+"], and will wait 10 seconds and retry..."); + LOG.error(e.getMessage()); try { Thread.sleep(10000); } catch (InterruptedException ex) { @@ -83,9 +85,9 @@ public static Connection getConnection(int index, String userName, String pwd){ } catch (ClassNotFoundException e) { e.printStackTrace(); } - } + //} - LOG.error("The mo-tester still can not get valid conneciton from mo, the following cases wil not be executed!"); + LOG.error("The mo-tester can not get valid conneciton from mo with[user="+userName+", pwd="+pwd+"], the following cases wil not be executed!"); server_up = false; return null; } @@ -95,7 +97,7 @@ public static Connection getConnectionForSys(){ if(!server_up) return null; //get db connection,if failed,retry 3 times 10 s interval - for(int i = 0; i < 3; i++) { + //for(int i = 0; i < 3; i++) { try { Class.forName(driver); if (sysconn == null || sysconn.isClosed()) { @@ -103,7 +105,7 @@ public static Connection getConnectionForSys(){ } return sysconn; } catch (SQLException e) { - LOG.error("The mo-tester can not get valid conneciton from mo with[user="+userName+", pwd="+pwd+"] for sys user, and will wait 10 seconds and retry..."); + //LOG.error("The mo-tester can not get valid conneciton from mo with[user="+userName+", pwd="+pwd+"] for sys user, and will wait 10 seconds and retry..."); try { Thread.sleep(10000); } catch (InterruptedException ex) { @@ -112,9 +114,9 @@ public static Connection getConnectionForSys(){ } catch (ClassNotFoundException e) { e.printStackTrace(); } - } + //} - LOG.error("The mo-tester still can not get valid conneciton from mo for sys user, the following cases wil not be executed!"); + LOG.error("The mo-tester can not get valid conneciton from mo with[user="+userName+", pwd="+pwd+"], the following cases wil not be executed!"); server_up = false; return null; }