Skip to content

Commit 3015aaa

Browse files
authored
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 06c23cc commit 3015aaa

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void testInflightCommandsFailWhenConnectionClosed(TestContext ctx) {
9292
Long id = row.getLong("Id");
9393
String state = row.getString("State");
9494
String info = row.getString("Info");
95-
if ("User sleep".equals(state) || "DO SLEEP(10)".equals(info)) {
95+
if ("User sleep".equals(state) || "DO SLEEP(20)".equals(info)) {
9696
// kill the connection
9797
conn2
9898
.query("KILL CONNECTION " + id)

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,22 @@ public void connectWithVertxInstance(TestContext context) {
101101
boolean useNativeTransport = Runtime.version().feature() < 16;
102102
Vertx vertx = Vertx.vertx(new VertxOptions().setPreferNativeTransport(useNativeTransport));
103103
assertEquals(useNativeTransport, vertx.isNativeTransportEnabled());
104+
Pool pool = null;
104105
try {
105-
client = MySQLBuilder.pool(builder -> builder.connectingTo(new MySQLConnectOptions(options)).using(vertx));
106+
pool = MySQLBuilder.pool(builder -> builder.connectingTo(new MySQLConnectOptions(options)).using(vertx));
106107
Async async = context.async();
107-
client
108+
pool
108109
.getConnection()
109110
.onComplete(context.asyncAssertSuccess(conn -> {
110111
async.complete();
111112
conn.close();
112113
}));
113114
async.await();
114115
} finally {
115-
vertx.close();
116+
if (pool != null) {
117+
pool.close().await();
118+
}
119+
vertx.close().await();
116120
}
117121
}
118122

0 commit comments

Comments
 (0)