From ee010ad157bf94c1a0eae1906af6a4bafe93cf23 Mon Sep 17 00:00:00 2001 From: Filipe Silva Date: Thu, 9 Jun 2022 19:17:33 +0100 Subject: [PATCH] Fix for tests failing on Windows and other sporadic failures. Change-Id: Ide11dea40c83cbafabbe276b1f102bcb624327d9 --- .../regression/MetaDataRegressionTest.java | 3 +++ .../regression/StatementRegressionTest.java | 13 +++++-------- .../testsuite/regression/StringRegressionTest.java | 9 ++++++--- src/test/java/testsuite/x/devapi/SessionTest.java | 9 +++++---- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/test/java/testsuite/regression/MetaDataRegressionTest.java b/src/test/java/testsuite/regression/MetaDataRegressionTest.java index 2c60ebcd1..a6c7d8ab6 100644 --- a/src/test/java/testsuite/regression/MetaDataRegressionTest.java +++ b/src/test/java/testsuite/regression/MetaDataRegressionTest.java @@ -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," diff --git a/src/test/java/testsuite/regression/StatementRegressionTest.java b/src/test/java/testsuite/regression/StatementRegressionTest.java index 9a8707c39..7e5a5f889 100644 --- a/src/test/java/testsuite/regression/StatementRegressionTest.java +++ b/src/test/java/testsuite/regression/StatementRegressionTest.java @@ -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); @@ -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"); @@ -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 { diff --git a/src/test/java/testsuite/regression/StringRegressionTest.java b/src/test/java/testsuite/regression/StringRegressionTest.java index 87226c039..e0b6c291d 100644 --- a/src/test/java/testsuite/regression/StringRegressionTest.java +++ b/src/test/java/testsuite/regression/StringRegressionTest.java @@ -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 @@ -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; @@ -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()); @@ -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()); diff --git a/src/test/java/testsuite/x/devapi/SessionTest.java b/src/test/java/testsuite/x/devapi/SessionTest.java index 760199837..030bf5171 100644 --- a/src/test/java/testsuite/x/devapi/SessionTest.java +++ b/src/test/java/testsuite/x/devapi/SessionTest.java @@ -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 @@ -1068,13 +1068,14 @@ private 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");