Skip to content

Commit

Permalink
merge FD96 turn of SSL for mysql access by regression tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardttom2 committed Dec 23, 2021
1 parent 0940615 commit 628a8c6
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -50,7 +51,7 @@ public void testDML() throws InterruptedException, SQLException, NamingException
"</esperio-db-configuration>";

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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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);
}
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 628a8c6

Please sign in to comment.