Skip to content

Commit de2aad7

Browse files
committed
[misc] mysql 8 testing correction
1 parent fe4b771 commit de2aad7

File tree

4 files changed

+46
-29
lines changed

4 files changed

+46
-29
lines changed

.travis.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ install:
2929
connector-test-machine/launch.bat -t "$srv" -v "$v" -d testj
3030
;;
3131
linux)
32-
source connector-test-machine/launch.sh -t "$srv" -v "$v" -d testj -n 0 -l "$LOCAL"
32+
source connector-test-machine/launch.sh -t "$srv" -v "$v" -d testj -n 0 -l "$local"
3333
;;
3434
esac
3535
jobs:
@@ -42,11 +42,11 @@ jobs:
4242
- env: srv=mariadb v=10.5
4343
os: windows
4444
language: shell
45-
- env: srv=mariadb v=10.2 LOCAL=1
46-
- env: srv=mariadb v=10.3 LOCAL=1
47-
- env: srv=mariadb v=10.4 LOCAL=1
48-
- env: srv=mariadb v=10.5 LOCAL=1
49-
- env: srv=mariadb v=10.5 LOCAL=1 BENCH=1
45+
- env: srv=mariadb v=10.2 local=1
46+
- env: srv=mariadb v=10.3 local=1
47+
- env: srv=mariadb v=10.4 local=1
48+
- env: srv=mariadb v=10.5
49+
- env: srv=mariadb v=10.5 local=1 BENCH=1
5050
- env: srv=maxscale
5151
- env: srv=skysql
5252
- env: srv=skysql-ha

src/test/java/org/mariadb/jdbc/Common.java

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@
3030
import java.sql.SQLException;
3131
import java.time.Duration;
3232
import java.time.Instant;
33+
import java.util.Optional;
3334
import java.util.Properties;
3435
import org.junit.jupiter.api.*;
35-
import org.junit.jupiter.api.extension.AfterEachCallback;
36-
import org.junit.jupiter.api.extension.BeforeEachCallback;
37-
import org.junit.jupiter.api.extension.ExtensionContext;
36+
import org.junit.jupiter.api.extension.*;
3837
import org.junit.jupiter.api.function.Executable;
3938
import org.mariadb.jdbc.integration.tools.TcpProxy;
4039
import org.mariadb.jdbc.util.constants.HaMode;
@@ -141,8 +140,6 @@ public void cancelForVersion(int major, int minor) {
141140
Assumptions.assumeFalse(dbVersion.startsWith(major + "." + minor));
142141
}
143142

144-
// @RegisterExtension public Extension watcher = new Follow();
145-
146143
public static Connection createCon(String option) throws SQLException {
147144
return (Connection) DriverManager.getConnection(mDefUrl + "&" + option);
148145
}
@@ -176,16 +173,38 @@ public void assertThrowsContains(
176173
Assertions.assertTrue(e.getMessage().contains(expected), "real message:" + e.getMessage());
177174
}
178175

179-
private class Follow implements BeforeEachCallback, AfterEachCallback {
176+
@RegisterExtension public Extension watcher = new Follow();
177+
178+
private class Follow implements TestWatcher, BeforeEachCallback {
180179
@Override
181-
public void afterEach(ExtensionContext extensionContext) throws Exception {
182-
System.out.println(Duration.between(initialTest, Instant.now()).toString());
180+
public void testDisabled(ExtensionContext context, Optional<String> reason) {
181+
System.out.println(
182+
String.format(
183+
" - Disabled %s: with reason :- %s",
184+
context.getDisplayName(), reason.orElse("No reason")));
185+
}
186+
187+
@Override
188+
public void testAborted(ExtensionContext context, Throwable cause) {
189+
System.out.println(String.format(" - Aborted %s: ", context.getDisplayName()));
190+
}
191+
192+
@Override
193+
public void testFailed(ExtensionContext context, Throwable cause) {
194+
System.out.println(String.format(" \u2717 Failed %s: ", context.getDisplayName()));
195+
}
196+
197+
@Override
198+
public void testSuccessful(ExtensionContext context) {
199+
System.out.println(
200+
String.format(
201+
" ✓ %s: %sms",
202+
context.getDisplayName(), Duration.between(initialTest, Instant.now()).toMillis()));
183203
}
184204

185205
@Override
186206
public void beforeEach(ExtensionContext extensionContext) throws Exception {
187207
initialTest = Instant.now();
188-
System.out.print(" test : " + extensionContext.getTestMethod().get() + " ");
189208
}
190209
}
191210
}

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -874,18 +874,16 @@ public void windowsNamedPipe() throws SQLException {
874874

875875
@Test
876876
public void localSocket() throws Exception {
877-
Assumptions.assumeTrue(System.getenv("LOCAL") != null);
877+
System.out.println("local:" + System.getenv("local"));
878+
Assumptions.assumeTrue(System.getenv("local") != null
879+
&& "1".equals(System.getenv("local"))
880+
&& !System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("win"));
878881
Statement stmt = sharedConn.createStatement();
879882
ResultSet rs = stmt.executeQuery("select @@version_compile_os,@@socket");
880883
if (!rs.next()) {
881884
return;
882885
}
883886
System.out.println("os:" + rs.getString(1) + " path:" + rs.getString(2));
884-
String os = rs.getString(1);
885-
if (os.toLowerCase().startsWith("win")) {
886-
return;
887-
}
888-
889887
String path = rs.getString(2);
890888
stmt.execute("DROP USER IF EXISTS testSocket@'localhost'");
891889
stmt.execute("CREATE USER testSocket@'localhost' IDENTIFIED BY 'MySup5%rPassw@ord'");

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,15 @@ public static void init() throws Exception {
3131
if (rsaPublicKey == null
3232
&& rs.getString(1) != null
3333
&& System.getenv("TEST_DB_RSA_PUBLIC_KEY") != null) {
34-
rsaPublicKey =
35-
checkFileExists(System.getenv("TEST_DB_RSA_PUBLIC_KEY") + "/" + rs.getString(1));
34+
rsaPublicKey = checkFileExists(System.getenv("TEST_DB_RSA_PUBLIC_KEY"));
3635
}
3736
}
3837
if (rsaPublicKey == null) {
3938
rsaPublicKey = checkFileExists("../../ssl/public.key");
4039
}
4140

4241
stmt.execute(
43-
"CREATE USER 'cachingSha256User'@'%' IDENTIFIED WITH caching_sha2_password BY 'password'");
42+
"CREATE USER 'cachingSha256User'@'%' IDENTIFIED WITH caching_sha2_password BY 'MySup8%rPassw@ord'");
4443
stmt.execute("GRANT ALL PRIVILEGES ON *.* TO 'cachingSha256User'@'%'");
4544
stmt.execute(
4645
"CREATE USER 'cachingSha256User2'@'%' IDENTIFIED WITH caching_sha2_password BY ''");
@@ -80,7 +79,7 @@ public void cachingSha256Empty() throws Exception {
8079
Assumptions.assumeTrue(
8180
!isWindows && !isMariaDBServer() && rsaPublicKey != null && minVersion(8, 0, 0));
8281
sharedConn.createStatement().execute("FLUSH PRIVILEGES"); // reset cache
83-
try (Connection con = createCon("user=cachingSha256User2")) {
82+
try (Connection con = createCon("user=cachingSha256User2&allowPublicKeyRetrieval")) {
8483
con.isValid(1);
8584
}
8685
}
@@ -92,7 +91,8 @@ public void cachingSha256PluginTestWithServerRsaKey() throws Exception {
9291
sharedConn.createStatement().execute("FLUSH PRIVILEGES"); // reset cache
9392
try (Connection con =
9493
createCon(
95-
"user=cachingSha256User&password=password&serverRsaPublicKeyFile=" + rsaPublicKey)) {
94+
"user=cachingSha256User&password=MySup8%rPassw@ord&serverRsaPublicKeyFile="
95+
+ rsaPublicKey)) {
9696
con.isValid(1);
9797
}
9898
}
@@ -102,7 +102,7 @@ public void cachingSha256PluginTestWithoutServerRsaKey() throws Exception {
102102
Assumptions.assumeTrue(!isWindows && minVersion(8, 0, 0));
103103
sharedConn.createStatement().execute("FLUSH PRIVILEGES"); // reset cache
104104
try (Connection con =
105-
createCon("user=cachingSha256User&password=password&allowPublicKeyRetrieval")) {
105+
createCon("user=cachingSha256User&password=MySup8%rPassw@ord&allowPublicKeyRetrieval")) {
106106
con.isValid(1);
107107
}
108108
}
@@ -114,7 +114,7 @@ public void cachingSha256PluginTestException() throws Exception {
114114

115115
assertThrowsContains(
116116
SQLException.class,
117-
() -> createCon("user=cachingSha256User&password=password"),
117+
() -> createCon("user=cachingSha256User&password=MySup8%rPassw@ord"),
118118
"RSA public key is not available client side");
119119
}
120120

@@ -124,7 +124,7 @@ public void cachingSha256PluginTestSsl() throws Exception {
124124
sharedConn.createStatement().execute("FLUSH PRIVILEGES"); // reset cache
125125

126126
Assumptions.assumeTrue(haveSsl());
127-
try (Connection con = createCon("user=cachingSha256User&password=password&sslMode=trust")) {
127+
try (Connection con = createCon("user=cachingSha256User&password=MySup8%rPassw@ord&sslMode=trust")) {
128128
con.isValid(1);
129129
}
130130
}

0 commit comments

Comments
 (0)