Skip to content

Commit 6547ca7

Browse files
committed
Fix a couple of intermittent test failures for the MySQL client (#1658)
* Fix intermittent MySQLConnectionTest#testInflightCommandsFailWhenConnectionClosed failure The process info should match the sleep query that was executed. Signed-off-by: Thomas Segismont <tsegismont@gmail.com> * Fix intermittent MySQLUnixDomainSocketTest.connectWithVertxInstance failure Manage the dedicated Vert.x and Pool instance separately from the object instances. Otherwise, the dedicated Vert.x instance is closed asynchronously and then the client stored in the fields cannot be properly closed in the tear down method. Signed-off-by: Thomas Segismont <tsegismont@gmail.com> --------- Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
1 parent 6fd8a9f commit 6547ca7

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

vertx-mysql-client/src/test/java/io/vertx/mysqlclient/MySQLConnectionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public void testInflightCommandsFailWhenConnectionClosed(TestContext ctx) {
8484
Long id = row.getLong("Id");
8585
String state = row.getString("State");
8686
String info = row.getString("Info");
87-
if ("User sleep".equals(state) || "DO SLEEP(10)".equals(info)) {
87+
if ("User sleep".equals(state) || "DO SLEEP(20)".equals(info)) {
8888
// kill the connection
8989
conn2.query("KILL CONNECTION " + id).execute(ctx.asyncAssertSuccess(v -> conn2.close()));
9090
break;

vertx-mysql-client/src/test/java/io/vertx/mysqlclient/MySQLUnixDomainSocketTest.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
*/
1111
package io.vertx.mysqlclient;
1212

13+
import io.vertx.core.Future;
1314
import io.vertx.core.Vertx;
1415
import io.vertx.core.VertxOptions;
1516
import io.vertx.ext.unit.Async;
1617
import io.vertx.ext.unit.TestContext;
1718
import io.vertx.ext.unit.junit.VertxUnitRunner;
19+
import io.vertx.sqlclient.Pool;
1820
import io.vertx.sqlclient.PoolOptions;
1921
import org.junit.After;
2022
import org.junit.Before;
@@ -81,16 +83,22 @@ public void simpleConnect(TestContext context) {
8183
@Test
8284
public void connectWithVertxInstance(TestContext context) {
8385
Vertx vertx = Vertx.vertx(new VertxOptions().setPreferNativeTransport(true));
86+
Pool pool = null;
8487
try {
85-
client = MySQLPool.pool(vertx, new MySQLConnectOptions(options), new PoolOptions());
88+
pool = MySQLBuilder.pool(builder -> builder.connectingTo(new MySQLConnectOptions(options)).using(vertx));
8689
Async async = context.async();
87-
client.getConnection(context.asyncAssertSuccess(conn -> {
90+
pool
91+
.getConnection()
92+
.onComplete(context.asyncAssertSuccess(conn -> {
8893
async.complete();
8994
conn.close();
9095
}));
9196
async.await();
9297
} finally {
93-
vertx.close();
98+
if (pool != null) {
99+
Future.await(pool.close());
100+
}
101+
Future.await(vertx.close());
94102
}
95103
}
96104

0 commit comments

Comments
 (0)