Skip to content

Commit 06c23cc

Browse files
authored
Speed up DB2 client tests (#1655)
This commit modernizes the DB2 client test infrastructure by: - upgrading to the community image icr.io/db2_community/db2:12.1.4.0 - eliminating the JDBC driver dependency - removing z/OS *testing* support (not possible in containerized environments) Also, a lot of NPE were logged because the DB2SocketConnection#closeHandler was always invoked even if not set. With all these changes, on my box, the DB2 client build passes in 3-4 minutes instead of 7-8 minutes. Some portions of this content were created with the assistance of IBM Bob. Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
1 parent ab7d4f9 commit 06c23cc

File tree

16 files changed

+132
-356
lines changed

16 files changed

+132
-356
lines changed

.github/workflows/ci-4.x.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ jobs:
4646
module: 'vertx-mssql-client'
4747
- os: ubuntu-latest
4848
jdk: 8
49-
profile: 'DB2-11.5'
5049
module: 'vertx-db2-client'
5150
- os: ubuntu-latest
5251
jdk: 8

.github/workflows/ci-matrix-5.x.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ jobs:
5353
module: 'vertx-mssql-client'
5454
- os: ubuntu-latest
5555
jdk: 11
56-
profile: 'DB2-11.5'
5756
module: 'vertx-db2-client'
5857
- os: ubuntu-latest
5958
jdk: 11

vertx-db2-client/pom.xml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,10 @@
4949
<!-- Testing purposes -->
5050
<dependency>
5151
<groupId>org.testcontainers</groupId>
52-
<artifactId>testcontainers-db2</artifactId>
52+
<artifactId>testcontainers</artifactId>
5353
<version>${testcontainers.version}</version>
5454
<scope>test</scope>
5555
</dependency>
56-
<dependency>
57-
<groupId>com.ibm.db2</groupId>
58-
<artifactId>jcc</artifactId>
59-
<version>11.1.4.4</version>
60-
<scope>test</scope>
61-
</dependency>
6256
<!-- SLF4J API for test code and Testcontainers -->
6357
<dependency>
6458
<groupId>org.slf4j</groupId>

vertx-db2-client/src/main/java/io/vertx/db2client/impl/DB2SocketConnection.java

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
/*
2-
* Copyright (C) 2019,2020 IBM Corporation
2+
* Copyright (c) 2011-2026 Contributors to the Eclipse Foundation
33
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License 2.0 which is available at
6+
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
7+
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
78
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
9+
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
1510
*/
1611
package io.vertx.db2client.impl;
1712

@@ -24,23 +19,18 @@
2419
import io.vertx.core.spi.metrics.ClientMetrics;
2520
import io.vertx.db2client.DB2ConnectOptions;
2621
import io.vertx.db2client.DB2Exception;
27-
import io.vertx.db2client.impl.codec.ConnectionState;
28-
import io.vertx.db2client.impl.codec.DB2CommandMessage;
29-
import io.vertx.db2client.impl.codec.DB2Codec;
30-
import io.vertx.db2client.impl.codec.DB2PreparedStatement;
31-
import io.vertx.db2client.impl.codec.ExtendedBatchQueryDB2CommandMessage;
32-
import io.vertx.db2client.impl.codec.ExtendedQueryDB2CommandMessage;
22+
import io.vertx.db2client.impl.codec.*;
3323
import io.vertx.db2client.impl.command.InitialHandshakeCommand;
3424
import io.vertx.db2client.impl.drda.ConnectionMetaData;
3525
import io.vertx.db2client.impl.drda.SQLState;
3626
import io.vertx.db2client.impl.drda.SqlCode;
3727
import io.vertx.sqlclient.SqlConnectOptions;
3828
import io.vertx.sqlclient.codec.CommandMessage;
39-
import io.vertx.sqlclient.spi.connection.Connection;
29+
import io.vertx.sqlclient.codec.SocketConnectionBase;
4030
import io.vertx.sqlclient.internal.PreparedStatement;
4131
import io.vertx.sqlclient.internal.QueryResultHandler;
42-
import io.vertx.sqlclient.codec.SocketConnectionBase;
4332
import io.vertx.sqlclient.spi.DatabaseMetadata;
33+
import io.vertx.sqlclient.spi.connection.Connection;
4434
import io.vertx.sqlclient.spi.protocol.CommandBase;
4535
import io.vertx.sqlclient.spi.protocol.ExtendedQueryCommand;
4636
import io.vertx.sqlclient.spi.protocol.SimpleQueryCommand;
@@ -141,7 +131,9 @@ protected <R> void doSchedule(CommandBase<R> cmd, Completable<R> handler) {
141131
@Override
142132
public void handleClose(Throwable t) {
143133
super.handleClose(t);
144-
context().runOnContext(closeHandler);
134+
if (closeHandler != null) {
135+
context().runOnContext(closeHandler);
136+
}
145137
}
146138

147139
@Override

vertx-db2-client/src/test/java/io/vertx/tests/db2client/DB2DataTypeTest.java

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
/*
2-
* Copyright (C) 2020 IBM Corporation
2+
* Copyright (c) 2011-2026 Contributors to the Eclipse Foundation
33
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License 2.0 which is available at
6+
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
7+
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
78
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
9+
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
1510
*/
1611
package io.vertx.tests.db2client;
1712

@@ -32,8 +27,6 @@
3227
import java.util.List;
3328
import java.util.UUID;
3429

35-
import static org.junit.Assume.assumeTrue;
36-
3730
@RunWith(VertxUnitRunner.class)
3831
public class DB2DataTypeTest extends DB2TestBase {
3932

@@ -214,35 +207,6 @@ public void testUUID(TestContext ctx) {
214207
}));
215208
}
216209

217-
@Test
218-
public void testRowId(TestContext ctx) {
219-
assumeTrue("Only DB2/Z supports the ROWID column type", rule.isZOS());
220-
221-
final String msg = "insert data for testRowId";
222-
connect(ctx.asyncAssertSuccess(conn -> {
223-
// Insert some data
224-
conn
225-
.preparedQuery("INSERT INTO ROWTEST (message) VALUES ('" + msg + "')")
226-
.execute()
227-
.onComplete(ctx.asyncAssertSuccess(insertResult -> {
228-
// Find it by msg
229-
conn
230-
.preparedQuery("SELECT * FROM ROWTEST WHERE message = '" + msg + "'")
231-
.execute()
232-
.onComplete(ctx.asyncAssertSuccess(rows -> {
233-
RowId rowId = verifyRowId(ctx, rows, msg);
234-
// Now find it by rowid
235-
conn
236-
.preparedQuery("SELECT * FROM ROWTEST WHERE id = ?")
237-
.execute(Tuple.of(rowId))
238-
.onComplete(ctx.asyncAssertSuccess(rows2 -> {
239-
verifyRowId(ctx, rows2, msg);
240-
}));
241-
}));
242-
}));
243-
}));
244-
}
245-
246210
/**
247211
* Test to support using enum string values in the Row and Tuple methods.
248212
*/

vertx-db2-client/src/test/java/io/vertx/tests/db2client/QueryVariationsTest.java

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
1-
package io.vertx.tests.db2client;
2-
3-
import static org.junit.Assume.assumeFalse;
4-
5-
import java.util.Arrays;
6-
import java.util.function.Consumer;
1+
/*
2+
* Copyright (c) 2011-2026 Contributors to the Eclipse Foundation
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License 2.0 which is available at
6+
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
7+
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
8+
*
9+
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
10+
*/
711

8-
import org.junit.Test;
9-
import org.junit.runner.RunWith;
12+
package io.vertx.tests.db2client;
1013

1114
import io.vertx.ext.unit.TestContext;
1215
import io.vertx.ext.unit.junit.VertxUnitRunner;
1316
import io.vertx.sqlclient.Row;
1417
import io.vertx.sqlclient.RowIterator;
1518
import io.vertx.sqlclient.RowSet;
1619
import io.vertx.sqlclient.Tuple;
20+
import org.junit.Test;
21+
import org.junit.runner.RunWith;
22+
23+
import java.util.Arrays;
24+
import java.util.function.Consumer;
1725

1826
/**
1927
* Tests for subqueries which are documented here:
@@ -180,8 +188,6 @@ public void testSectionReuse(TestContext ctx) {
180188
*/
181189
@Test
182190
public void testSequenceQuery(TestContext ctx) {
183-
assumeFalse("TODO: Sequences behave differently on DB2/z and need to be implemented properly", rule.isZOS());
184-
185191
connect(ctx.asyncAssertSuccess(con -> {
186192
con
187193
.query("values nextval for my_seq")
@@ -214,8 +220,6 @@ public void testSequenceQuery(TestContext ctx) {
214220
*/
215221
@Test
216222
public void testSequenceQueryPrepared(TestContext ctx) {
217-
assumeFalse("TODO: Sequences behave differently on DB2/z and need to be implemented properly", rule.isZOS());
218-
219223
connect(ctx.asyncAssertSuccess(con -> {
220224
con
221225
.preparedQuery("VALUES nextval for my_seq")

vertx-db2-client/src/test/java/io/vertx/tests/db2client/TableJoinTest.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
1-
package io.vertx.tests.db2client;
2-
3-
import static org.junit.Assume.assumeFalse;
4-
5-
import java.util.Arrays;
1+
/*
2+
* Copyright (c) 2011-2026 Contributors to the Eclipse Foundation
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License 2.0 which is available at
6+
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
7+
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
8+
*
9+
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
10+
*/
611

7-
import org.junit.Test;
8-
import org.junit.runner.RunWith;
12+
package io.vertx.tests.db2client;
913

1014
import io.vertx.ext.unit.TestContext;
1115
import io.vertx.ext.unit.junit.VertxUnitRunner;
1216
import io.vertx.sqlclient.Row;
17+
import org.junit.Test;
18+
import org.junit.runner.RunWith;
19+
20+
import java.util.Arrays;
1321

1422
/**
1523
* Tests for table joins which are documented here:
@@ -84,7 +92,6 @@ public void testRightOuterJoin(TestContext ctx) {
8492

8593
@Test
8694
public void testFullOuterJoin(TestContext ctx) {
87-
assumeFalse("DB2 on Z does not support operations within ON clause for FULL OUTER JOIN", rule.isZOS());
8895
testJoin(ctx, "FULL OUTER JOIN");
8996
}
9097

0 commit comments

Comments
 (0)