Skip to content

Commit

Permalink
Fix for tests failing on Windows and other sporadic failures.
Browse files Browse the repository at this point in the history
Change-Id: Ide11dea40c83cbafabbe276b1f102bcb624327d9
  • Loading branch information
fjssilva committed Jun 9, 2022
1 parent 32892f1 commit ee010ad
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5325,6 +5325,9 @@ public void testBug95280() throws Exception {
@Test
public void testBug104641() throws Exception {
String databaseName1 = "dbBug104641";
if (isServerRunningOnWindows()) {
databaseName1 = databaseName1.toLowerCase();
}
createDatabase(databaseName1);
createTable(databaseName1 + ".table1",
"(`CREATED` datetime DEFAULT NULL,`ID` bigint NOT NULL AUTO_INCREMENT,`LRN_ID` bigint DEFAULT '0',`USERNAME` varchar(50) NOT NULL,"
Expand Down
13 changes: 5 additions & 8 deletions src/test/java/testsuite/regression/StatementRegressionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11448,7 +11448,7 @@ public void testBug20391550() throws Exception {
st.setQueryTimeout(2);

PreparedStatement ps = con.prepareStatement("update testBug20391550 set c2=? where c1=?");
assertThrows(SQLException.class, "Statement cancelled due to timeout or client request", () -> st.executeQuery("select sleep(3)"));
assertThrows(SQLException.class, "Statement cancelled due to timeout or client request", () -> st.executeQuery("select sleep(8)"));

assertThrows(SQLException.class, "No operations allowed after statement closed.", () -> {
ps.setInt(2, 100);
Expand Down Expand Up @@ -11576,16 +11576,14 @@ public void testBug103878() throws Exception {
PreparedStatement ps = con.prepareStatement("SHOW CREATE TABLE testBug103878");
this.rs = ps.executeQuery();
assertTrue(this.rs.next());
assertTrue(this.rs.getString(2).startsWith("CREATE TABLE"));
System.out.println(this.rs.getString(2));
assertTrue(StringUtils.startsWithIgnoreCase(this.rs.getString(2), "CREATE TABLE"));
ps.close();

ps = con.prepareStatement("SHOW CREATE VIEW testBug103878_view");
this.rs = ps.executeQuery();
assertTrue(this.rs.next());
assertTrue(this.rs.getString(2).startsWith("CREATE"));
assertTrue(this.rs.getString(2).contains("testBug103878_view"));
System.out.println(this.rs.getString(2));
assertTrue(StringUtils.startsWithIgnoreCase(this.rs.getString(2), "CREATE"));
assertTrue(StringUtils.indexOfIgnoreCase(this.rs.getString(2), "testBug103878_view") >= 0);
ps.close();

ps = con.prepareStatement("SHOW PROCESSLIST");
Expand All @@ -11599,8 +11597,7 @@ public void testBug103878() throws Exception {
ps = con.prepareStatement("SHOW CREATE USER testBug103878User");
this.rs = ps.executeQuery();
assertTrue(this.rs.next());
assertTrue(this.rs.getString(1).startsWith("CREATE USER"));
System.out.println(this.rs.getString(1));
assertTrue(StringUtils.startsWithIgnoreCase(this.rs.getString(1), "CREATE USER"));
ps.close();
}
} finally {
Expand Down
9 changes: 6 additions & 3 deletions src/test/java/testsuite/regression/StringRegressionTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2021, Oracle and/or its affiliates.
* Copyright (c) 2002, 2022, Oracle and/or its affiliates.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 2.0, as published by the
Expand Down Expand Up @@ -35,6 +35,7 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.charset.Charset;
import java.sql.Clob;
import java.sql.Connection;
import java.util.Properties;
Expand Down Expand Up @@ -194,8 +195,10 @@ public void printCallStackTrace() {
*/
@Test
public void testBug11614() throws Exception {
System.out.println(Charset.defaultCharset());

createTable("testBug11614",
"(`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, `text` TEXT NOT NULL," + "PRIMARY KEY(`id`)) CHARACTER SET utf8 COLLATE utf8_general_ci");
"(`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, `text` TEXT NOT NULL, PRIMARY KEY(`id`)) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci");

Properties props = new Properties();
props.setProperty(PropertyKey.sslMode.getKeyName(), SslMode.DISABLED.name());
Expand All @@ -207,7 +210,7 @@ public void testBug11614() throws Exception {
try {
utf8Conn = getConnectionWithProps(props);

utf8Conn.createStatement().executeUpdate("INSERT INTO testBug11614 (`id`,`text`) values (1,'')");
utf8Conn.createStatement().executeUpdate("INSERT INTO testBug11614 (`id`,`text`) values (1,'')");
this.rs = utf8Conn.createStatement().executeQuery("SELECT `text` FROM testBug11614 WHERE id=1");
assertTrue(this.rs.next());

Expand Down
9 changes: 5 additions & 4 deletions src/test/java/testsuite/x/devapi/SessionTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2021, Oracle and/or its affiliates.
* Copyright (c) 2015, 2022, Oracle and/or its affiliates.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 2.0, as published by the
Expand Down Expand Up @@ -1068,13 +1068,14 @@ private <EX extends Throwable> void testPooledSessions_assertFailureTimeout(Clie

@Test
public void testBug28616573() throws Exception {
RowResult res = this.session.sql(
"select @@global.mysqlx_max_connections, VARIABLE_VALUE FROM performance_schema.global_status WHERE VARIABLE_NAME='Mysqlx_worker_threads_active'")
.execute();
this.session.sql("FLUSH STATUS").execute();
RowResult res = this.session.sql("SELECT @@global.mysqlx_max_connections, VARIABLE_VALUE FROM performance_schema.global_status "
+ "WHERE VARIABLE_NAME='Mysqlx_worker_threads_active'").execute();
Row r = res.next();
int mysqlxMaxConnections = r.getInt(0);
int mysqlWorkerThreadsActive = Integer.parseInt(r.getString(1));
this.session.sql("SET @@global.mysqlx_max_connections=" + (mysqlWorkerThreadsActive + 2)).execute(); // allow only 2 additional connections
this.session.sql("FLUSH STATUS").execute();

Properties props = new Properties();
props.setProperty(ClientProperty.POOLING_ENABLED.getKeyName(), "true");
Expand Down

0 comments on commit ee010ad

Please sign in to comment.