From 628a8c6a29621080fc323a22271056854d19ba0c Mon Sep 17 00:00:00 2001 From: Thomas Bernhardt Date: Thu, 23 Dec 2021 18:01:16 -0500 Subject: [PATCH] merge FD96 turn of SSL for mysql access by regression tests --- .../database/connection/SupportDatabaseURL.java | 12 ++++++++++-- .../connection/TestDatabaseDMConnFactory.java | 4 ++-- .../connection/TestDatabaseDSConnFactory.java | 4 ++-- .../esperio/db/SupportDatabaseService.java | 7 ++++--- .../espertech/esperio/db/TestDBAdapterDML.java | 3 ++- .../multithread/MultithreadContextDBAccess.java | 8 ++++---- .../support/util/SupportDatabaseService.java | 2 +- .../suite/context/TestSuiteContext.java | 3 ++- .../suite/epl/TestSuiteEPLDatabase.java | 15 ++++++++------- .../suite/epl/TestSuiteEPLDatabaseWConfig.java | 3 ++- .../suite/multithread/TestSuiteMultithread.java | 3 ++- 11 files changed, 39 insertions(+), 25 deletions(-) diff --git a/common/src/main/java/com/espertech/esper/common/internal/epl/historical/database/connection/SupportDatabaseURL.java b/common/src/main/java/com/espertech/esper/common/internal/epl/historical/database/connection/SupportDatabaseURL.java index 76ca29f9c..8a43adb01 100644 --- a/common/src/main/java/com/espertech/esper/common/internal/epl/historical/database/connection/SupportDatabaseURL.java +++ b/common/src/main/java/com/espertech/esper/common/internal/epl/historical/database/connection/SupportDatabaseURL.java @@ -10,10 +10,18 @@ */ package com.espertech.esper.common.internal.epl.historical.database.connection; +import java.util.Properties; + public class SupportDatabaseURL { public final static String DBUSER = "root"; public final static String DBPWD = "password"; public final static String DRIVER = "com.mysql.cj.jdbc.Driver"; - public final static String FULLURL = "jdbc:mysql://localhost/test?user=root&password=password"; - public final static String PARTURL = "jdbc:mysql://localhost/test"; + public final static String FULLURL = "jdbc:mysql://localhost/test?user=root&password=password&useSSL=false"; + public final static String PARTURL = "jdbc:mysql://localhost/test?useSSL=false"; + + public static Properties newProperties() { + Properties properties = new Properties(); + properties.put("useSSL", "false"); + return properties; + } } diff --git a/common/src/test/java/com/espertech/esper/common/internal/epl/historical/database/connection/TestDatabaseDMConnFactory.java b/common/src/test/java/com/espertech/esper/common/internal/epl/historical/database/connection/TestDatabaseDMConnFactory.java index 279e02a60..52a7a4d8b 100644 --- a/common/src/test/java/com/espertech/esper/common/internal/epl/historical/database/connection/TestDatabaseDMConnFactory.java +++ b/common/src/test/java/com/espertech/esper/common/internal/epl/historical/database/connection/TestDatabaseDMConnFactory.java @@ -32,7 +32,7 @@ public void setUp() throws Exception { // driver-manager config 1 ConfigurationCommonDBRef config = new ConfigurationCommonDBRef(); - config.setDriverManagerConnection(SupportDatabaseURL.DRIVER, SupportDatabaseURL.FULLURL, new Properties()); + config.setDriverManagerConnection(SupportDatabaseURL.DRIVER, SupportDatabaseURL.FULLURL, SupportDatabaseURL.newProperties()); config.setConnectionAutoCommit(true); config.setConnectionCatalog("test"); config.setConnectionTransactionIsolation(1); @@ -46,7 +46,7 @@ public void setUp() throws Exception { // driver-manager config 3 config = new ConfigurationCommonDBRef(); - Properties properties = new Properties(); + Properties properties = SupportDatabaseURL.newProperties(); properties.setProperty("user", SupportDatabaseURL.DBUSER); properties.setProperty("password", SupportDatabaseURL.DBPWD); config.setDriverManagerConnection(SupportDatabaseURL.DRIVER, SupportDatabaseURL.PARTURL, properties); diff --git a/common/src/test/java/com/espertech/esper/common/internal/epl/historical/database/connection/TestDatabaseDSConnFactory.java b/common/src/test/java/com/espertech/esper/common/internal/epl/historical/database/connection/TestDatabaseDSConnFactory.java index 79b65f80d..ab0009e21 100644 --- a/common/src/test/java/com/espertech/esper/common/internal/epl/historical/database/connection/TestDatabaseDSConnFactory.java +++ b/common/src/test/java/com/espertech/esper/common/internal/epl/historical/database/connection/TestDatabaseDSConnFactory.java @@ -29,13 +29,13 @@ public void setUp() { MysqlDataSource mySQLDataSource = new MysqlDataSource(); mySQLDataSource.setUser(SupportDatabaseURL.DBUSER); mySQLDataSource.setPassword(SupportDatabaseURL.DBPWD); - mySQLDataSource.setURL("jdbc:mysql://localhost/test"); + mySQLDataSource.setURL("jdbc:mysql://localhost/test?useSSL=false"); String envName = "java:comp/env/jdbc/MySQLDB"; SupportInitialContextFactory.addContextEntry(envName, mySQLDataSource); ConfigurationCommonDBRef config = new ConfigurationCommonDBRef(); - Properties properties = new Properties(); + Properties properties = SupportDatabaseURL.newProperties(); properties.put("java.naming.factory.initial", SupportInitialContextFactory.class.getName()); config.setDataSourceConnection(envName, properties); diff --git a/esperio/esperio-db/src/test/java/com/espertech/esperio/db/SupportDatabaseService.java b/esperio/esperio-db/src/test/java/com/espertech/esperio/db/SupportDatabaseService.java index caf1da81a..ce429b9e6 100644 --- a/esperio/esperio-db/src/test/java/com/espertech/esperio/db/SupportDatabaseService.java +++ b/esperio/esperio-db/src/test/java/com/espertech/esperio/db/SupportDatabaseService.java @@ -11,6 +11,7 @@ package com.espertech.esperio.db; import com.espertech.esper.common.client.configuration.common.ConfigurationCommonDBRef; +import com.espertech.esper.common.internal.epl.historical.database.connection.SupportDatabaseURL; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -28,12 +29,12 @@ public class SupportDatabaseService { public final static String DBUSER = "root"; public final static String DBPWD = "password"; public final static String DRIVER = "com.mysql.cj.jdbc.Driver"; - public final static String FULLURL = "jdbc:mysql://localhost/test?user=root&password=password"; - public final static String PARTURL = "jdbc:mysql://localhost/test"; + public final static String FULLURL = "jdbc:mysql://localhost/test?user=root&password=password&useSSL=false"; + public final static String PARTURL = "jdbc:mysql://localhost/test?useSSL=false"; public static ConfigurationCommonDBRef makeDBConfig() { ConfigurationCommonDBRef configDB = new ConfigurationCommonDBRef(); - configDB.setDriverManagerConnection(SupportDatabaseService.DRIVER, SupportDatabaseService.FULLURL, new Properties()); + configDB.setDriverManagerConnection(SupportDatabaseService.DRIVER, SupportDatabaseService.FULLURL, SupportDatabaseURL.newProperties()); return configDB; } diff --git a/esperio/esperio-db/src/test/java/com/espertech/esperio/db/TestDBAdapterDML.java b/esperio/esperio-db/src/test/java/com/espertech/esperio/db/TestDBAdapterDML.java index b34ee2912..5ecf404a8 100644 --- a/esperio/esperio-db/src/test/java/com/espertech/esperio/db/TestDBAdapterDML.java +++ b/esperio/esperio-db/src/test/java/com/espertech/esperio/db/TestDBAdapterDML.java @@ -12,6 +12,7 @@ import com.espertech.esper.common.client.configuration.Configuration; import com.espertech.esper.common.client.scopetest.EPAssertionUtil; +import com.espertech.esper.common.internal.epl.historical.database.connection.SupportDatabaseURL; import com.espertech.esper.runtime.client.EPRuntime; import com.espertech.esper.runtime.client.EPRuntimeProvider; import com.espertech.esperio.db.core.ExecutorServices; @@ -50,7 +51,7 @@ public void testDML() throws InterruptedException, SQLException, NamingException ""; Configuration config = new Configuration(); - config.getRuntime().addPluginLoader("EsperIODBAdapter", EsperIODBAdapterPlugin.class.getName(), new Properties(), esperIODBConfig); + config.getRuntime().addPluginLoader("EsperIODBAdapter", EsperIODBAdapterPlugin.class.getName(), SupportDatabaseURL.newProperties(), esperIODBConfig); config.getCommon().addEventType("SupportDBBean", SupportDBBean.class); config.getCommon().addEventType("SupportBean", SupportBean.class); diff --git a/regression-lib/src/main/java/com/espertech/esper/regressionlib/suite/multithread/MultithreadContextDBAccess.java b/regression-lib/src/main/java/com/espertech/esper/regressionlib/suite/multithread/MultithreadContextDBAccess.java index d113bc200..70ebfc369 100644 --- a/regression-lib/src/main/java/com/espertech/esper/regressionlib/suite/multithread/MultithreadContextDBAccess.java +++ b/regression-lib/src/main/java/com/espertech/esper/regressionlib/suite/multithread/MultithreadContextDBAccess.java @@ -13,6 +13,7 @@ import com.espertech.esper.common.client.EventBean; import com.espertech.esper.common.client.configuration.Configuration; import com.espertech.esper.common.client.configuration.common.ConfigurationCommonDBRef; +import com.espertech.esper.common.internal.epl.historical.database.connection.SupportDatabaseURL; import com.espertech.esper.common.internal.support.SupportBean; import com.espertech.esper.regressionlib.framework.RegressionEnvironment; import com.espertech.esper.regressionlib.framework.RegressionExecutionWithConfigure; @@ -29,7 +30,6 @@ import java.util.ArrayList; import java.util.EnumSet; import java.util.List; -import java.util.Properties; import java.util.concurrent.*; import static org.junit.Assert.assertEquals; @@ -44,7 +44,7 @@ public void configure(Configuration configuration) { configuration.getRuntime().getThreading().setListenerDispatchPreserveOrder(false); ConfigurationCommonDBRef configDB = new ConfigurationCommonDBRef(); - configDB.setDriverManagerConnection(SupportDatabaseService.DRIVER, SupportDatabaseService.FULLURL, new Properties()); + configDB.setDriverManagerConnection(SupportDatabaseService.DRIVER, SupportDatabaseService.FULLURL, SupportDatabaseURL.newProperties()); configDB.setConnectionLifecycleEnum(ConfigurationCommonDBRef.ConnectionLifecycleEnum.RETAIN); configuration.getCommon().addDatabaseReference("MyDB", configDB); } @@ -62,8 +62,8 @@ public void run(RegressionEnvironment env) { RegressionPath path = new RegressionPath(); env.compileDeploy("@public create context CtxEachString partition by theString from SupportBean", path); env.compileDeploy("@Name('select') context CtxEachString " + - "select * from SupportBean, " + - " sql:MyDB ['select mycol3 from mytesttable_large where ${theString} = mycol1']", path); + "select * from SupportBean, " + + " sql:MyDB ['select mycol3 from mytesttable_large where ${theString} = mycol1']", path); // up to 10 threads, up to 1000 combinations (1 to 1000) tryThreadSafetyHistoricalJoin(env, 8, 20); diff --git a/regression-lib/src/main/java/com/espertech/esper/regressionlib/support/util/SupportDatabaseService.java b/regression-lib/src/main/java/com/espertech/esper/regressionlib/support/util/SupportDatabaseService.java index d57542a5d..34216d432 100644 --- a/regression-lib/src/main/java/com/espertech/esper/regressionlib/support/util/SupportDatabaseService.java +++ b/regression-lib/src/main/java/com/espertech/esper/regressionlib/support/util/SupportDatabaseService.java @@ -14,5 +14,5 @@ public class SupportDatabaseService { public final static String DBUSER = "root"; public final static String DBPWD = "password"; public final static String DRIVER = "com.mysql.cj.jdbc.Driver"; - public final static String FULLURL = "jdbc:mysql://localhost/test?user=root&password=password"; + public final static String FULLURL = "jdbc:mysql://localhost/test?user=root&password=password&useSSL=false"; } diff --git a/regression-run/src/test/java/com/espertech/esper/regressionrun/suite/context/TestSuiteContext.java b/regression-run/src/test/java/com/espertech/esper/regressionrun/suite/context/TestSuiteContext.java index 4cd67fa5d..b738a1266 100644 --- a/regression-run/src/test/java/com/espertech/esper/regressionrun/suite/context/TestSuiteContext.java +++ b/regression-run/src/test/java/com/espertech/esper/regressionrun/suite/context/TestSuiteContext.java @@ -13,6 +13,7 @@ import com.espertech.esper.common.client.configuration.Configuration; import com.espertech.esper.common.client.configuration.common.ConfigurationCommonDBRef; import com.espertech.esper.common.client.configuration.compiler.ConfigurationCompilerPlugInSingleRowFunction; +import com.espertech.esper.common.internal.epl.historical.database.connection.SupportDatabaseURL; import com.espertech.esper.common.internal.support.SupportBean; import com.espertech.esper.common.internal.support.SupportBean_S0; import com.espertech.esper.common.internal.support.SupportBean_S1; @@ -153,7 +154,7 @@ private static void configure(Configuration configuration) { configuration.getCommon().addImport(ContextHashSegmented.class.getName()); ConfigurationCommonDBRef configDB = new ConfigurationCommonDBRef(); - configDB.setDriverManagerConnection(SupportDatabaseService.DRIVER, SupportDatabaseService.FULLURL, new Properties()); + configDB.setDriverManagerConnection(SupportDatabaseService.DRIVER, SupportDatabaseService.FULLURL, SupportDatabaseURL.newProperties()); configuration.getCommon().addDatabaseReference("MyDB", configDB); configuration.getCompiler().getByteCode().setAllowSubscriber(true); diff --git a/regression-run/src/test/java/com/espertech/esper/regressionrun/suite/epl/TestSuiteEPLDatabase.java b/regression-run/src/test/java/com/espertech/esper/regressionrun/suite/epl/TestSuiteEPLDatabase.java index 474a9372c..50499eece 100644 --- a/regression-run/src/test/java/com/espertech/esper/regressionrun/suite/epl/TestSuiteEPLDatabase.java +++ b/regression-run/src/test/java/com/espertech/esper/regressionrun/suite/epl/TestSuiteEPLDatabase.java @@ -13,6 +13,7 @@ import com.espertech.esper.common.client.configuration.Configuration; import com.espertech.esper.common.client.configuration.common.ConfigurationCommon; import com.espertech.esper.common.client.configuration.common.ConfigurationCommonDBRef; +import com.espertech.esper.common.internal.epl.historical.database.connection.SupportDatabaseURL; import com.espertech.esper.common.internal.support.SupportBean; import com.espertech.esper.common.internal.support.SupportBean_S0; import com.espertech.esper.regressionlib.suite.epl.database.*; @@ -115,11 +116,11 @@ private static void configure(Configuration configuration) { common.getLogging().setEnableJDBC(true); ConfigurationCommonDBRef configDBWithRetain = new ConfigurationCommonDBRef(); - configDBWithRetain.setDriverManagerConnection(SupportDatabaseService.DRIVER, SupportDatabaseService.FULLURL, new Properties()); + configDBWithRetain.setDriverManagerConnection(SupportDatabaseService.DRIVER, SupportDatabaseService.FULLURL, SupportDatabaseURL.newProperties()); configDBWithRetain.setConnectionLifecycleEnum(ConfigurationCommonDBRef.ConnectionLifecycleEnum.RETAIN); configuration.getCommon().addDatabaseReference("MyDBWithRetain", configDBWithRetain); - Properties props = new Properties(); + Properties props = SupportDatabaseURL.newProperties(); props.put("driverClassName", SupportDatabaseService.DRIVER); props.put("url", SupportDatabaseService.FULLURL); props.put("username", SupportDatabaseService.DBUSER); @@ -131,7 +132,7 @@ private static void configure(Configuration configuration) { configuration.getCommon().addDatabaseReference("MyDBWithPooledWithLRU100", configDBWithPooledWithLRU100); ConfigurationCommonDBRef configDBWithTxnIso1WithReadOnly = new ConfigurationCommonDBRef(); - configDBWithTxnIso1WithReadOnly.setDriverManagerConnection(SupportDatabaseService.DRIVER, SupportDatabaseService.FULLURL, new Properties()); + configDBWithTxnIso1WithReadOnly.setDriverManagerConnection(SupportDatabaseService.DRIVER, SupportDatabaseService.FULLURL, SupportDatabaseURL.newProperties()); configDBWithTxnIso1WithReadOnly.setConnectionLifecycleEnum(ConfigurationCommonDBRef.ConnectionLifecycleEnum.RETAIN); configDBWithTxnIso1WithReadOnly.setConnectionCatalog("test"); configDBWithTxnIso1WithReadOnly.setConnectionReadOnly(true); @@ -152,18 +153,18 @@ private static void configure(Configuration configuration) { configuration.getCommon().addDatabaseReference("MyDBPlain", dbconfigPlain); ConfigurationCommonDBRef configDBPooled = new ConfigurationCommonDBRef(); - configDBPooled.setDriverManagerConnection(SupportDatabaseService.DRIVER, SupportDatabaseService.FULLURL, new Properties()); + configDBPooled.setDriverManagerConnection(SupportDatabaseService.DRIVER, SupportDatabaseService.FULLURL, SupportDatabaseURL.newProperties()); configDBPooled.setConnectionLifecycleEnum(ConfigurationCommonDBRef.ConnectionLifecycleEnum.POOLED); configuration.getCommon().addDatabaseReference("MyDBPooled", configDBPooled); ConfigurationCommonDBRef configDBWithLRU100000 = new ConfigurationCommonDBRef(); - configDBWithLRU100000.setDriverManagerConnection(SupportDatabaseService.DRIVER, SupportDatabaseService.FULLURL, new Properties()); + configDBWithLRU100000.setDriverManagerConnection(SupportDatabaseService.DRIVER, SupportDatabaseService.FULLURL, SupportDatabaseURL.newProperties()); configDBWithLRU100000.setConnectionLifecycleEnum(ConfigurationCommonDBRef.ConnectionLifecycleEnum.RETAIN); configDBWithLRU100000.setLRUCache(100000); configuration.getCommon().addDatabaseReference("MyDBWithLRU100000", configDBWithLRU100000); ConfigurationCommonDBRef configDBWithExpiryTime = new ConfigurationCommonDBRef(); - configDBWithExpiryTime.setDriverManagerConnection(SupportDatabaseService.DRIVER, SupportDatabaseService.FULLURL, new Properties()); + configDBWithExpiryTime.setDriverManagerConnection(SupportDatabaseService.DRIVER, SupportDatabaseService.FULLURL, SupportDatabaseURL.newProperties()); configDBWithExpiryTime.setConnectionCatalog("test"); configDBWithExpiryTime.setExpiryTimeCache(60, 120); configuration.getCommon().addDatabaseReference("MyDBWithExpiryTime", configDBWithExpiryTime); @@ -174,7 +175,7 @@ private static void configure(Configuration configuration) { protected static ConfigurationCommonDBRef getDBConfig() { ConfigurationCommonDBRef configDB = new ConfigurationCommonDBRef(); - configDB.setDriverManagerConnection(SupportDatabaseService.DRIVER, SupportDatabaseService.FULLURL, new Properties()); + configDB.setDriverManagerConnection(SupportDatabaseService.DRIVER, SupportDatabaseService.FULLURL, SupportDatabaseURL.newProperties()); configDB.setConnectionLifecycleEnum(ConfigurationCommonDBRef.ConnectionLifecycleEnum.RETAIN); configDB.setConnectionCatalog("test"); configDB.setConnectionReadOnly(true); diff --git a/regression-run/src/test/java/com/espertech/esper/regressionrun/suite/epl/TestSuiteEPLDatabaseWConfig.java b/regression-run/src/test/java/com/espertech/esper/regressionrun/suite/epl/TestSuiteEPLDatabaseWConfig.java index 1d6282e5b..2511ede92 100644 --- a/regression-run/src/test/java/com/espertech/esper/regressionrun/suite/epl/TestSuiteEPLDatabaseWConfig.java +++ b/regression-run/src/test/java/com/espertech/esper/regressionrun/suite/epl/TestSuiteEPLDatabaseWConfig.java @@ -11,6 +11,7 @@ package com.espertech.esper.regressionrun.suite.epl; import com.espertech.esper.common.client.configuration.common.ConfigurationCommonDBRef; +import com.espertech.esper.common.internal.epl.historical.database.connection.SupportDatabaseURL; import com.espertech.esper.regressionlib.suite.epl.database.EPLDatabaseQueryResultCache; import com.espertech.esper.common.internal.support.SupportBean_S0; import com.espertech.esper.regressionlib.support.util.SupportDatabaseService; @@ -48,7 +49,7 @@ private void run(EPLDatabaseQueryResultCache exec) { private ConfigurationCommonDBRef getDefaultConfig() { ConfigurationCommonDBRef configDB = new ConfigurationCommonDBRef(); - configDB.setDriverManagerConnection(SupportDatabaseService.DRIVER, SupportDatabaseService.FULLURL, new Properties()); + configDB.setDriverManagerConnection(SupportDatabaseService.DRIVER, SupportDatabaseService.FULLURL, SupportDatabaseURL.newProperties()); configDB.setConnectionLifecycleEnum(ConfigurationCommonDBRef.ConnectionLifecycleEnum.RETAIN); return configDB; } diff --git a/regression-run/src/test/java/com/espertech/esper/regressionrun/suite/multithread/TestSuiteMultithread.java b/regression-run/src/test/java/com/espertech/esper/regressionrun/suite/multithread/TestSuiteMultithread.java index a192857b2..c0dbfdad0 100644 --- a/regression-run/src/test/java/com/espertech/esper/regressionrun/suite/multithread/TestSuiteMultithread.java +++ b/regression-run/src/test/java/com/espertech/esper/regressionrun/suite/multithread/TestSuiteMultithread.java @@ -13,6 +13,7 @@ import com.espertech.esper.common.client.configuration.Configuration; import com.espertech.esper.common.client.configuration.common.ConfigurationCommon; import com.espertech.esper.common.client.configuration.common.ConfigurationCommonDBRef; +import com.espertech.esper.common.internal.epl.historical.database.connection.SupportDatabaseURL; import com.espertech.esper.common.internal.support.SupportBean; import com.espertech.esper.common.internal.support.SupportBean_S0; import com.espertech.esper.common.internal.support.SupportBean_S1; @@ -212,7 +213,7 @@ private static void configure(Configuration configuration) { } ConfigurationCommonDBRef configDB = new ConfigurationCommonDBRef(); - configDB.setDriverManagerConnection(SupportDatabaseService.DRIVER, SupportDatabaseService.FULLURL, new Properties()); + configDB.setDriverManagerConnection(SupportDatabaseService.DRIVER, SupportDatabaseService.FULLURL, SupportDatabaseURL.newProperties()); configDB.setConnectionLifecycleEnum(ConfigurationCommonDBRef.ConnectionLifecycleEnum.RETAIN); configDB.setConnectionCatalog("test"); configDB.setConnectionReadOnly(true);