From ff7abeb0f16126c64c308fa26e0efa68689a16c0 Mon Sep 17 00:00:00 2001 From: Zoltan Haindrich Date: Tue, 28 May 2024 15:54:29 +0000 Subject: [PATCH] small cleanup --- .../org/apache/druid/quidem/Launcher.java | 23 ++++++++++--------- .../druid/quidem/LauncherSmokeTest.java | 5 +--- .../druid/quidem/DruidAvaticaTestDriver.java | 11 ++++----- .../sql/calcite/SqlTestFrameworkConfig.java | 15 ++++++++---- 4 files changed, 28 insertions(+), 26 deletions(-) diff --git a/integration-tests/src/main/java/org/apache/druid/quidem/Launcher.java b/integration-tests/src/main/java/org/apache/druid/quidem/Launcher.java index 2d7ec784a4e..f797d92789f 100644 --- a/integration-tests/src/main/java/org/apache/druid/quidem/Launcher.java +++ b/integration-tests/src/main/java/org/apache/druid/quidem/Launcher.java @@ -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(); } } diff --git a/integration-tests/src/test/java/org/apache/druid/quidem/LauncherSmokeTest.java b/integration-tests/src/test/java/org/apache/druid/quidem/LauncherSmokeTest.java index 62a01d2c15e..25f031cfc6c 100644 --- a/integration-tests/src/test/java/org/apache/druid/quidem/LauncherSmokeTest.java +++ b/integration-tests/src/test/java/org/apache/druid/quidem/LauncherSmokeTest.java @@ -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(); } diff --git a/sql/src/test/java/org/apache/druid/quidem/DruidAvaticaTestDriver.java b/sql/src/test/java/org/apache/druid/quidem/DruidAvaticaTestDriver.java index a10c9015ec0..ff1db3b6cfd 100644 --- a/sql/src/test/java/org/apache/druid/quidem/DruidAvaticaTestDriver.java +++ b/sql/src/test/java/org/apache/druid/quidem/DruidAvaticaTestDriver.java @@ -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); } diff --git a/sql/src/test/java/org/apache/druid/sql/calcite/SqlTestFrameworkConfig.java b/sql/src/test/java/org/apache/druid/sql/calcite/SqlTestFrameworkConfig.java index 4b8137349ca..29e0a878ccb 100644 --- a/sql/src/test/java/org/apache/druid/sql/calcite/SqlTestFrameworkConfig.java +++ b/sql/src/test/java/org/apache/druid/sql/calcite/SqlTestFrameworkConfig.java @@ -230,11 +230,18 @@ public class SqlTestFrameworkConfig public static class SqlTestFrameworkConfigStore implements Closeable { + private final Function queryComponentSupplierWrapper; + + public SqlTestFrameworkConfigStore( + Function queryComponentSupplierWrapper) + { + this.queryComponentSupplierWrapper = queryComponentSupplierWrapper; + } + Map configMap = new HashMap<>(); public ConfigurationInstance getConfigurationInstance( - SqlTestFrameworkConfig config, - Function 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 getAnnotation(Class annotationType)