Skip to content

Commit 844df48

Browse files
author
diego Dupin
committed
[misc] test stability correction
1 parent baae3db commit 844df48

File tree

4 files changed

+14
-22
lines changed

4 files changed

+14
-22
lines changed

src/main/java/org/mariadb/jdbc/client/impl/ConnectionHelper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ public static long initializeClientCapabilities(
157157
}
158158

159159
// remains for compatibility
160-
if (Boolean.parseBoolean(configuration.nonMappedOptions().getProperty("interactiveClient", "false"))) {
160+
if (Boolean.parseBoolean(
161+
configuration.nonMappedOptions().getProperty("interactiveClient", "false"))) {
161162
capabilities |= Capabilities.CLIENT_INTERACTIVE;
162163
}
163164

src/main/java/org/mariadb/jdbc/client/impl/StandardClient.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,7 @@ private void postConnectionQueries() throws SQLException {
295295
commands.add("show status like 'wsrep_local_state'");
296296
}
297297

298-
if (!hostAddress.primary
299-
&& context.getVersion().versionGreaterOrEqual(5, 6, 5)) {
298+
if (!hostAddress.primary && context.getVersion().versionGreaterOrEqual(5, 6, 5)) {
300299
commands.add("SET SESSION TRANSACTION READ ONLY");
301300
}
302301

src/test/java/org/mariadb/jdbc/integration/LoggingTest.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,20 +81,6 @@ void basicLogging() throws Exception {
8181
ds.close();
8282
try {
8383
String contents = new String(Files.readAllBytes(Paths.get(tempFile.getPath())));
84-
String defaultRequest =
85-
"+--------------------------------------------------+\n"
86-
+ "| 0 1 2 3 4 5 6 7 8 9 a b c d e f |\n"
87-
+ "+--------------------------------------------------+------------------+\n"
88-
+ "| 23 00 00 00 03 53 45 54 20 53 45 53 53 49 4F 4E | #....SET SESSION |\n"
89-
+ "| 20 54 52 41 4E 53 41 43 54 49 4F 4E 20 52 45 41 | TRANSACTION REA |\n"
90-
+ "| 44 20 57 52 49 54 45 | D WRITE |\n"
91-
+ "+--------------------------------------------------+------------------+";
92-
if (!"maxscale".equals(System.getenv("srv")) && !"skysql-ha".equals(System.getenv("srv"))) {
93-
Assertions.assertTrue(
94-
contents.contains(defaultRequest)
95-
|| contents.contains(defaultRequest.replace("\r\n", "\n")),
96-
contents);
97-
}
9884
String selectOne =
9985
"+--------------------------------------------------+\n"
10086
+ "| 0 1 2 3 4 5 6 7 8 9 a b c d e f |\n"

src/test/java/org/mariadb/jdbc/integration/MultiHostTest.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,25 +241,31 @@ public void masterFailover() throws Exception {
241241
url
242242
+ "waitReconnectTimeout=300&deniedListTimeout=300&retriesAllDown=4&connectTimeout=500&deniedListTimeout=20")) {
243243
Statement stmt = con.createStatement();
244+
con.setAutoCommit(false);
244245
stmt.execute("START TRANSACTION");
245246
stmt.execute("SET @con=1");
246247

247248
proxy.restart(50);
248-
ResultSet rs = stmt.executeQuery("SELECT @con");
249-
rs.next();
250-
assertEquals(1, rs.getInt(1));
249+
try {
250+
ResultSet rs = stmt.executeQuery("SELECT @con");
251+
rs.next();
252+
assertEquals(1, rs.getInt(1));
253+
} catch (SQLException e) {
254+
assertTrue(e.getMessage().contains("In progress transaction was lost"));
255+
}
251256
}
252-
257+
Thread.sleep(50);
253258
// with transaction replay
254259
try (Connection con =
255260
(Connection)
256261
DriverManager.getConnection(
257262
url
258-
+ "transactionReplay=true&waitReconnectTimeout=300&deniedListTimeout=300&retriesAllDown=4&connectTimeout=500")) {
263+
+ "transactionReplay=true&waitReconnectTimeout=300&deniedListTimeout=300&retriesAllDown=4&connectTimeout=20")) {
259264
Statement stmt = con.createStatement();
260265
stmt.execute("DROP TABLE IF EXISTS testReplay");
261266
stmt.execute("CREATE TABLE testReplay(id INT)");
262267
stmt.execute("INSERT INTO testReplay VALUE (1)");
268+
con.setAutoCommit(false);
263269
stmt.execute("START TRANSACTION");
264270
stmt.execute("INSERT INTO testReplay VALUE (2)");
265271
try (PreparedStatement prep = con.prepareStatement("INSERT INTO testReplay VALUE (?)")) {

0 commit comments

Comments
 (0)