Skip to content

Commit 1b8509a

Browse files
committed
WL#14660, Testsuite with support for single MySQL server instance.
1 parent 408a1b6 commit 1b8509a

File tree

77 files changed

+6977
-6412
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+6977
-6412
lines changed

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
Version 8.0.27
55

6+
- WL#14660, Testsuite with support for single MySQL server instance.
7+
68
- Fix for Bug#103878 (32954449), CONNECTOR/J 8 : QUERY WITH 'SHOW XXX' WILL GET EXCEPTION WHEN USE CURSOR.
79

810
- Fix for Bug#103796 (32922715), CONNECTOR/J 8 STMT SETQUERYTIMEOUT CAN NOT WORK.

build.xml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,10 @@ com.mysql.cj.testsuite.build.dir - root directory for building testsuite, defaul
182182
com.mysql.cj.testsuite.junit.results - where to put junit reports, default '${com.mysql.cj.testsuite.junit.results}'
183183
com.mysql.cj.testsuite.jvm - run testsuite under this one JVM, default '${com.mysql.cj.testsuite.jvm}'
184184
com.mysql.cj.testsuite.url - connection string to the main test server, default _unset_
185-
com.mysql.cj.testsuite.url.openssl - connection string to the test server compiled with OpenSSL, used in sha256 tests, default _unset_
186185
com.mysql.cj.testsuite.mysqlx.url - connection string to the test server with xplugin, default _unset_
187-
com.mysql.cj.testsuite.mysqlx.url.openssl - connection string to the test server compiled with OpenSSL and enabled xplugin, default _unset_
188186
com.mysql.cj.testsuite.test.class - testcase class name to run, default _unset_
189187
com.mysql.cj.testsuite.test.methods - a comma separated list of test names existing in class defined by 'com.mysql.cj.testsuite.test.class', default _unset_
190188
com.mysql.cj.testsuite.unavailable.host - a host:port pair used for tests checking socket connection timeout
191-
com.mysql.cj.testsuite.no.server.testsuite - Option to indicate that the server was installed without the test package, default _unset_
192189

193190
See also com.mysql.cj.conf.PropertyDefinitions.SYSP_* variables for other test options.
194191

@@ -1239,11 +1236,30 @@ See also com.mysql.cj.conf.PropertyDefinitions.SYSP_* variables for other test o
12391236
<!-- ***** TESTING ***** -->
12401237
<!-- ******************* -->
12411238

1239+
<condition property="junit.styledir" value="${com.mysql.cj.build.dir.driver}" else="${ant.home}/etc">
1240+
<available file="${com.mysql.cj.extra.libs}/ant/junit-frames.xsl" type="file"/>
1241+
</condition>
1242+
1243+
<target name="-check-custom-xslt" unless="file.exists">
1244+
<available property="custom.xslt.exists" file="${com.mysql.cj.extra.libs}/ant/junit-frames.xsl" type="file"/>
1245+
</target>
1246+
1247+
<target name="-init-custom-xslt" depends="-check-custom-xslt" if="${custom.xslt.exists}">
1248+
<copy file="${com.mysql.cj.extra.libs}/ant/junit-frames.xsl"
1249+
tofile="${com.mysql.cj.build.dir.driver}/junit-frames.xsl"
1250+
overwrite="true" />
1251+
1252+
<replaceregexp match="extralibs"
1253+
replace="file:${ant.home}/etc/junit-frames.xsl"
1254+
flags="s">
1255+
<fileset file="${com.mysql.cj.build.dir.driver}/junit-frames.xsl"/>
1256+
</replaceregexp>
1257+
</target>
12421258

12431259
<!-- Run the full test suite, single test set or named tests against one JVM and one server config. -->
12441260
<target name="test"
12451261
description="Runs the full test suite, single test set (variable 'com.mysql.cj.testsuite.test.class') or named tests (variables 'com.mysql.cj.testsuite.test.class' and 'com.mysql.cj.testsuite.test.methods') against one JVM and one server config."
1246-
depends="-testsuite-jvm-check, compile-testsuite">
1262+
depends="-testsuite-jvm-check, compile-testsuite, -init-custom-xslt">
12471263

12481264
<mkdir dir="${com.mysql.cj.testsuite.junit.results}/report" />
12491265

@@ -1337,7 +1353,7 @@ See also com.mysql.cj.conf.PropertyDefinitions.SYSP_* variables for other test o
13371353
<fileset dir="${com.mysql.cj.testsuite.junit.results}">
13381354
<include name="**/TEST-*.xml" />
13391355
</fileset>
1340-
<report format="frames" todir="${com.mysql.cj.testsuite.junit.results}/report" />
1356+
<report styledir="${junit.styledir}" format="frames" todir="${com.mysql.cj.testsuite.junit.results}/report" />
13411357
</junitreport>
13421358

13431359
<!-- Don't fail the build if we're doing coverage test. -->

src/main/core-api/java/com/mysql/cj/conf/PropertyDefinitions.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,13 @@ public class PropertyDefinitions {
6161
* Testsuite system properties.
6262
*/
6363
public static final String SYSP_testsuite_url /* */ = "com.mysql.cj.testsuite.url";
64-
public final static String SYSP_testsuite_url_admin /* */ = "com.mysql.cj.testsuite.url.admin";
6564
public static final String SYSP_testsuite_url_cluster /* */ = "com.mysql.cj.testsuite.url.cluster";
66-
/** Connection string to server compiled with OpenSSL */
67-
public static final String SYSP_testsuite_url_openssl /* */ = "com.mysql.cj.testsuite.url.openssl";
6865

6966
public static final String SYSP_testsuite_url_mysqlx /* */ = "com.mysql.cj.testsuite.mysqlx.url";
70-
public static final String SYSP_testsuite_url_mysqlx_openssl /* */ = "com.mysql.cj.testsuite.mysqlx.url.openssl";
7167

7268
public static final String SYSP_testsuite_cantGrant /* */ = "com.mysql.cj.testsuite.cantGrant";
73-
public static final String SYSP_testsuite_disable_multihost_tests /* */ = "com.mysql.cj.testsuite.disable.multihost.tests"; // TODO should be more specific for different types of multi-host configs
74-
7569
public static final String SYSP_testsuite_unavailable_host /* */ = "com.mysql.cj.testsuite.unavailable.host";
7670

77-
/** Option to indicate that the server was installed without the test package */
78-
public static final String SYSP_testsuite_no_server_testsuite /* */ = "com.mysql.cj.testsuite.no.server.testsuite";
79-
8071
/** For testsuite.regression.DataSourceRegressionTest */
8172
public static final String SYSP_testsuite_ds_host /* */ = "com.mysql.cj.testsuite.ds.host";
8273
/** For testsuite.regression.DataSourceRegressionTest */
@@ -328,7 +319,7 @@ public enum DatabaseTerm {
328319
new StringPropertyDefinition(PropertyKey.serverRSAPublicKeyFile, DEFAULT_VALUE_NULL_STRING, RUNTIME_NOT_MODIFIABLE,
329320
Messages.getString("ConnectionProperties.serverRSAPublicKeyFile"), "5.1.31", CATEGORY_SECURITY, 2),
330321

331-
new BooleanPropertyDefinition(PropertyKey.allowPublicKeyRetrieval, DEFAULT_VALUE_FALSE, RUNTIME_NOT_MODIFIABLE,
322+
new BooleanPropertyDefinition(PropertyKey.allowPublicKeyRetrieval, DEFAULT_VALUE_FALSE, RUNTIME_MODIFIABLE,
332323
Messages.getString("ConnectionProperties.allowPublicKeyRetrieval"), "5.1.31", CATEGORY_SECURITY, 3),
333324

334325
new EnumPropertyDefinition<>(PropertyKey.sslMode, SslMode.PREFERRED, RUNTIME_MODIFIABLE, Messages.getString("ConnectionProperties.sslMode"),

src/main/protocol-impl/java/com/mysql/cj/protocol/x/XProtocol.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -145,22 +145,6 @@ public class XProtocol extends AbstractProtocol<XMessage> implements Protocol<XM
145145

146146
private Map<Class<? extends GeneratedMessageV3>, ProtocolEntityFactory<? extends ProtocolEntity, XMessage>> messageToProtocolEntityFactory = new HashMap<>();
147147

148-
public XProtocol(String host, int port, String defaultSchema, PropertySet propertySet) {
149-
150-
this.defaultSchemaName = defaultSchema;
151-
152-
// Override common connectTimeout with xdevapi.connect-timeout to provide unified logic in StandardSocketFactory
153-
RuntimeProperty<Integer> connectTimeout = propertySet.getIntegerProperty(PropertyKey.connectTimeout);
154-
RuntimeProperty<Integer> xdevapiConnectTimeout = propertySet.getIntegerProperty(PropertyKey.xdevapiConnectTimeout);
155-
if (xdevapiConnectTimeout.isExplicitlySet() || !connectTimeout.isExplicitlySet()) {
156-
connectTimeout.setValue(xdevapiConnectTimeout.getValue());
157-
}
158-
159-
SocketConnection socketConn = new NativeSocketConnection();
160-
socketConn.connect(host, port, propertySet, null, null, 0);
161-
init(null, socketConn, propertySet, null);
162-
}
163-
164148
public XProtocol(HostInfo hostInfo, PropertySet propertySet) {
165149
String host = hostInfo.getHost();
166150
if (host == null || StringUtils.isEmptyOrWhitespaceOnly(host)) {

src/main/user-impl/java/com/mysql/cj/jdbc/DatabaseMetaDataUsingInfoSchema.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ public java.sql.ResultSet getCrossReference(String primaryCatalog, String primar
326326
sqlBuf.append(" AND A.TABLE_SCHEMA = ?");
327327
}
328328
sqlBuf.append(" AND A.TABLE_NAME=?");
329-
sqlBuf.append(" ORDER BY A.TABLE_SCHEMA, A.TABLE_NAME, A.ORDINAL_POSITION");
329+
sqlBuf.append(" ORDER BY FKTABLE_NAME, FKTABLE_NAME, KEY_SEQ");
330330

331331
java.sql.PreparedStatement pStmt = null;
332332

@@ -387,7 +387,7 @@ public java.sql.ResultSet getExportedKeys(String catalog, String schema, String
387387
sqlBuf.append(" AND A.REFERENCED_TABLE_SCHEMA = ?");
388388
}
389389
sqlBuf.append(" AND A.REFERENCED_TABLE_NAME=?");
390-
sqlBuf.append(" ORDER BY A.TABLE_SCHEMA, A.TABLE_NAME, A.ORDINAL_POSITION");
390+
sqlBuf.append(" ORDER BY FKTABLE_NAME, FKTABLE_NAME, KEY_SEQ");
391391

392392
java.sql.PreparedStatement pStmt = null;
393393

src/test/java/com/mysql/cj/ConnectionUrlTest.java

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2020, Oracle and/or its affiliates.
2+
* Copyright (c) 2016, 2021, Oracle and/or its affiliates.
33
*
44
* This program is free software; you can redistribute it and/or modify it under
55
* the terms of the GNU General Public License, version 2.0, as published by the
@@ -96,14 +96,10 @@ protected static <EX extends Throwable> EX assertThrows(String message, Class<EX
9696
try {
9797
testRoutine.call();
9898
} catch (Throwable t) {
99-
if (!throwable.isAssignableFrom(t.getClass())) {
100-
fail(message + "expected exception of type '" + throwable.getName() + "' but instead a exception of type '" + t.getClass().getName()
101-
+ "' was thrown.");
102-
}
103-
104-
if (msgMatchesRegex != null && !t.getMessage().matches(msgMatchesRegex)) {
105-
fail(message + "the error message «" + t.getMessage() + "» was expected to match «" + msgMatchesRegex + "».");
106-
}
99+
assertTrue(throwable.isAssignableFrom(t.getClass()), message + "expected exception of type '" + throwable.getName()
100+
+ "' but instead a exception of type '" + t.getClass().getName() + "' was thrown.");
101+
assertFalse(msgMatchesRegex != null && !t.getMessage().matches(msgMatchesRegex),
102+
message + "the error message «" + t.getMessage() + "» was expected to match «" + msgMatchesRegex + "».");
107103

108104
return throwable.cast(t);
109105
}
@@ -662,9 +658,7 @@ public void testConnectionUrl() {
662658
ok = true;
663659
}
664660
}
665-
if (!ok) {
666-
fail(cs + ": unexpected " + e.getClass().getName() + " thrown with message: " + e.getMessage());
667-
}
661+
assertTrue(ok, cs + ": unexpected " + e.getClass().getName() + " thrown with message: " + e.getMessage());
668662
}
669663
}
670664
}
@@ -861,12 +855,10 @@ public void testConnectionUrlWithWrongConnectionString() {
861855
connStr.add("jdbc:mysql://johndoe:secret@myhost:1234/db?=value");
862856

863857
for (String cs : connStr) {
864-
try {
858+
assertThrows(WrongArgumentException.class, () -> {
865859
System.out.println(ConnectionUrl.getConnectionUrlInstance(cs, null));
866-
fail(cs + ": expected to throw a " + WrongArgumentException.class.getName());
867-
} catch (Exception e) {
868-
assertTrue(WrongArgumentException.class.isAssignableFrom(e.getClass()), cs + ": expected to throw a " + WrongArgumentException.class.getName());
869-
}
860+
return null;
861+
});
870862
}
871863
}
872864

src/test/java/com/mysql/cj/protocol/a/MysqlTextValueDecoderTest.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2020, Oracle and/or its affiliates.
2+
* Copyright (c) 2015, 2021, Oracle and/or its affiliates.
33
*
44
* This program is free software; you can redistribute it and/or modify it under
55
* the terms of the GNU General Public License, version 2.0, as published by the
@@ -31,8 +31,8 @@
3131

3232
import static org.junit.jupiter.api.Assertions.assertEquals;
3333
import static org.junit.jupiter.api.Assertions.assertFalse;
34+
import static org.junit.jupiter.api.Assertions.assertThrows;
3435
import static org.junit.jupiter.api.Assertions.assertTrue;
35-
import static org.junit.jupiter.api.Assertions.fail;
3636

3737
import org.junit.jupiter.api.Test;
3838

@@ -96,12 +96,10 @@ public void testIntValues() {
9696
assertEquals(String.valueOf(Integer.MAX_VALUE), this.valueDecoder.decodeUInt4(String.valueOf(Integer.MAX_VALUE).getBytes(), 0, 10, vf));
9797
assertEquals("2147483648",
9898
this.valueDecoder.decodeUInt4(Constants.BIG_INTEGER_MAX_INTEGER_VALUE.add(Constants.BIG_INTEGER_ONE).toString().getBytes(), 0, 10, vf));
99-
try {
99+
100+
assertThrows(NumberOutOfRange.class, () -> {
100101
this.valueDecoder.decodeInt4(Constants.BIG_INTEGER_MAX_INTEGER_VALUE.add(Constants.BIG_INTEGER_ONE).toString().getBytes(), 0, 10, vf);
101-
fail("Exception should be thrown for decodeInt4(Integer.MAX_VALUE + 1)");
102-
} catch (NumberOutOfRange ex) {
103-
// expected
104-
}
102+
}, "Exception should be thrown for decodeInt4(Integer.MAX_VALUE + 1)");
105103

106104
byte[] uint8LessThanMaxLong = "8223372036854775807".getBytes();
107105
ValueFactory<String> fromLongOnly = new DefaultValueFactory<String>(new DefaultPropertySet()) {

src/test/java/com/mysql/cj/protocol/x/SyncMessageWriterTest.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2020, Oracle and/or its affiliates.
2+
* Copyright (c) 2015, 2021, Oracle and/or its affiliates.
33
*
44
* This program is free software; you can redistribute it and/or modify it under
55
* the terms of the GNU General Public License, version 2.0, as published by the
@@ -30,8 +30,8 @@
3030
package com.mysql.cj.protocol.x;
3131

3232
import static org.junit.jupiter.api.Assertions.assertEquals;
33+
import static org.junit.jupiter.api.Assertions.assertThrows;
3334
import static org.junit.jupiter.api.Assertions.assertTrue;
34-
import static org.junit.jupiter.api.Assertions.fail;
3535

3636
import java.io.BufferedOutputStream;
3737
import java.io.ByteArrayOutputStream;
@@ -87,13 +87,10 @@ public void testCompleteWriteMessage() throws IOException {
8787

8888
@Test
8989
public void testBadMessageClass() {
90-
try {
90+
assertThrows(WrongArgumentException.class, () -> {
9191
// try sending "Ok" which is a server-sent message. should fail with exception
9292
this.writer.send(new XMessage(Ok.getDefaultInstance()));
93-
fail("Writing OK message should fail");
94-
} catch (WrongArgumentException ex) {
95-
// expected
96-
}
93+
}, "Writing OK message should fail");
9794
}
9895

9996
@Test

src/test/java/com/mysql/cj/result/CommonAsserts.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2020, Oracle and/or its affiliates.
2+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates.
33
*
44
* This program is free software; you can redistribute it and/or modify it under
55
* the terms of the GNU General Public License, version 2.0, as published by the
@@ -29,6 +29,7 @@
2929

3030
package com.mysql.cj.result;
3131

32+
import static org.junit.jupiter.api.Assertions.assertTrue;
3233
import static org.junit.jupiter.api.Assertions.fail;
3334

3435
import java.util.concurrent.Callable;
@@ -38,14 +39,9 @@ protected static <EX extends Throwable> EX assertThrows(Class<EX> throwable, Str
3839
try {
3940
testRoutine.call();
4041
} catch (Throwable t) {
41-
if (!throwable.isAssignableFrom(t.getClass())) {
42-
fail("Expected exception of type '" + throwable.getName() + "' but instead a exception of type '" + t.getClass().getName() + "' was thrown.");
43-
}
44-
45-
if (!t.getMessage().matches(msgMatchesRegex)) {
46-
fail("The error message [" + t.getMessage() + "] was expected to match [" + msgMatchesRegex + "].");
47-
}
48-
42+
assertTrue(throwable.isAssignableFrom(t.getClass()),
43+
"Expected exception of type '" + throwable.getName() + "' but instead a exception of type '" + t.getClass().getName() + "' was thrown.");
44+
assertTrue(t.getMessage().matches(msgMatchesRegex), "The error message [" + t.getMessage() + "] was expected to match [" + msgMatchesRegex + "].");
4945
return throwable.cast(t);
5046
}
5147
fail("Expected exception of type '" + throwable.getName() + "'.");

src/test/java/com/mysql/cj/xdevapi/ExprParserTest.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2020, Oracle and/or its affiliates.
2+
* Copyright (c) 2015, 2021, Oracle and/or its affiliates.
33
*
44
* This program is free software; you can redistribute it and/or modify it under
55
* the terms of the GNU General Public License, version 2.0, as published by the
@@ -31,8 +31,8 @@
3131

3232
import static org.junit.jupiter.api.Assertions.assertEquals;
3333
import static org.junit.jupiter.api.Assertions.assertFalse;
34+
import static org.junit.jupiter.api.Assertions.assertThrows;
3435
import static org.junit.jupiter.api.Assertions.assertTrue;
35-
import static org.junit.jupiter.api.Assertions.fail;
3636

3737
import java.util.Arrays;
3838
import java.util.Iterator;
@@ -62,13 +62,10 @@ public class ExprParserTest {
6262
* @param s
6363
*/
6464
private void checkBadParse(String s) {
65-
try {
65+
assertThrows(WrongArgumentException.class, () -> {
6666
Expr e = new ExprParser(s).parse();
6767
System.err.println("Parsed as: " + e);
68-
fail("Expected exception while parsing: '" + s + "'");
69-
} catch (WrongArgumentException ex) {
70-
// expected
71-
}
68+
}, "Expected exception while parsing: '" + s + "'");
7269
}
7370

7471
@Test

0 commit comments

Comments
 (0)