small cleanup

This commit is contained in:
Zoltan Haindrich 2024-05-28 15:54:29 +00:00
parent 295c09a03c
commit ff7abeb0f1
4 changed files with 28 additions and 26 deletions

View File

@ -26,19 +26,22 @@ import org.apache.druid.sql.calcite.SqlTestFrameworkConfig;
import org.apache.druid.sql.calcite.SqlTestFrameworkConfig.ConfigurationInstance;
import org.apache.druid.sql.calcite.SqlTestFrameworkConfig.SqlTestFrameworkConfigStore;
import org.apache.druid.sql.calcite.util.SqlTestFramework;
import java.sql.SQLException;
public class Launcher
{
static final SqlTestFrameworkConfigStore CONFIG_STORE = new SqlTestFrameworkConfigStore();
static final SqlTestFrameworkConfigStore CONFIG_STORE = new SqlTestFrameworkConfigStore(
x -> new ExposedAsBrokerQueryComponentSupplierWrapper(x)
);
private static final String QUIDEM_URI = "quidem.uri";
private static Logger log = new Logger(Launcher.class);
private final SqlTestFramework framework;
private final ConfigurationInstance configurationInstance;
private Lifecycle lifecycle;
public Launcher() throws Exception
public Launcher(String uri) throws Exception
{
configurationInstance = getConfigurationInstance();
SqlTestFrameworkConfig config = SqlTestFrameworkConfig.fromURL(uri);
configurationInstance = CONFIG_STORE.getConfigurationInstance(config);
framework = configurationInstance.framework;
}
@ -52,14 +55,12 @@ public class Launcher
lifecycle.stop();
}
private static ConfigurationInstance getConfigurationInstance() throws SQLException, Exception
public static void main(String[] args) throws Exception
{
SqlTestFrameworkConfig config = SqlTestFrameworkConfig.fromURL("druidtest:///");
String quidemUri = System.getProperty(QUIDEM_URI, "druidtest:///");
ConfigurationInstance ci = CONFIG_STORE.getConfigurationInstance(
config,
x -> new ExposedAsBrokerQueryComponentSupplierWrapper(x)
);
return ci;
Launcher launcher = new Launcher(quidemUri );
launcher.start();
launcher.lifecycle.join();
}
}

View File

@ -18,7 +18,6 @@
*/
package org.apache.druid.quidem;
import org.apache.druid.sql.calcite.SqlTestFrameworkConfig.SqlTestFrameworkConfigStore;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@ -33,14 +32,12 @@ import static org.testng.Assert.assertEquals;
public class LauncherSmokeTest
{
static final SqlTestFrameworkConfigStore CONFIG_STORE = new SqlTestFrameworkConfigStore();
private static Launcher launcher;
@BeforeClass
public static void setUp() throws Exception
{
launcher = new Launcher();
launcher = new Launcher("druidtest:///");
launcher.start();
}

View File

@ -93,7 +93,9 @@ public class DruidAvaticaTestDriver implements Driver
public static final String URI_PREFIX = "druidtest://";
public static final String DEFAULT_URI = URI_PREFIX + "/";
static final SqlTestFrameworkConfigStore CONFIG_STORE = new SqlTestFrameworkConfigStore();
static final SqlTestFrameworkConfigStore CONFIG_STORE = new SqlTestFrameworkConfigStore(
x -> new AvaticaBasedTestConnectionSupplier(x)
);
public DruidAvaticaTestDriver()
{
@ -107,12 +109,7 @@ public class DruidAvaticaTestDriver implements Driver
}
try {
SqlTestFrameworkConfig config = SqlTestFrameworkConfig.fromURL(url);
ConfigurationInstance ci = CONFIG_STORE.getConfigurationInstance(
config,
x -> new AvaticaBasedTestConnectionSupplier(x)
);
ConfigurationInstance ci = CONFIG_STORE.getConfigurationInstance(config);
AvaticaJettyServer server = ci.framework.injector().getInstance(AvaticaJettyServer.class);
return server.getConnection(info);
}

View File

@ -230,11 +230,18 @@ public class SqlTestFrameworkConfig
public static class SqlTestFrameworkConfigStore implements Closeable
{
private final Function<QueryComponentSupplier, QueryComponentSupplier> queryComponentSupplierWrapper;
public SqlTestFrameworkConfigStore(
Function<QueryComponentSupplier, QueryComponentSupplier> queryComponentSupplierWrapper)
{
this.queryComponentSupplierWrapper = queryComponentSupplierWrapper;
}
Map<SqlTestFrameworkConfig, ConfigurationInstance> configMap = new HashMap<>();
public ConfigurationInstance getConfigurationInstance(
SqlTestFrameworkConfig config,
Function<QueryComponentSupplier, QueryComponentSupplier> queryComponentSupplierWrapper) throws Exception
SqlTestFrameworkConfig config) throws Exception
{
ConfigurationInstance ret = configMap.get(config);
if (!configMap.containsKey(config)) {
@ -273,7 +280,7 @@ public class SqlTestFrameworkConfig
*/
public static class Rule implements AfterAllCallback, BeforeEachCallback
{
SqlTestFrameworkConfigStore configStore = new SqlTestFrameworkConfigStore();
SqlTestFrameworkConfigStore configStore = new SqlTestFrameworkConfigStore(Function.identity());
private SqlTestFrameworkConfig config;
private Method method;
private String testName;
@ -324,7 +331,7 @@ public class SqlTestFrameworkConfig
public SqlTestFramework get() throws Exception
{
return configStore.getConfigurationInstance(config, Function.identity()).framework;
return configStore.getConfigurationInstance(config).framework;
}
public <T extends Annotation> T getAnnotation(Class<T> annotationType)