add some validation/etc

This commit is contained in:
Zoltan Haindrich 2024-06-17 15:42:48 +00:00
parent e06e54631e
commit 7eccf5b518
5 changed files with 51 additions and 43 deletions

View File

@ -18,7 +18,9 @@
~ under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>druid-quidem-it</artifactId>
@ -420,24 +422,24 @@
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<scope>compile</scope>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<scope>compile</scope>
</dependency>
<!-- Tests -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
@ -472,16 +474,16 @@
<artifactId>datasketches-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
@ -500,23 +502,13 @@
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>-Dquidem.uriXXX=Xa</argument>
<!-- <argument>-Xdebug</argument> -->
<!-- <argument>-Xdebug</argument> -->
<!-- <argument>-Xrunjdwp:server=y,transport=dt_socket,address=4000,suspend=y</argument> -->
<argument>org.apache.druid.quidem.Launcher</argument>
<argument>-classpath</argument>
<classpath />
<argument>-Dquidem.uri=${quidem.uri}</argument>
<argument>org.apache.druid.quidem.Launcher</argument>
</arguments>
<systemProperties>
<projectProperties />
<systemProperty>
<key>quidem.uri1</key>
<value>myvalue</value>
</systemProperty>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>
</project>
</project>

View File

@ -43,7 +43,9 @@ public class Launcher
public Launcher(String uri) throws Exception
{
SqlTestFrameworkConfig config = SqlTestFrameworkConfig.fromURL(uri);
System.out.println("Config: " + config);
configurationInstance = CONFIG_STORE.getConfigurationInstance(config);
System.out.println("Configuration instance: " + configurationInstance);
framework = configurationInstance.framework;
}
@ -62,11 +64,13 @@ public class Launcher
String quidemUri = System.getProperty(QUIDEM_URI, "druidtest:///");
Properties p = System.getProperties();
for (Object string : p.keySet()) {
log.info("[%s] -> %s", string, p.get(string));
if (string.toString().startsWith("quidem")) {
log.info("[%s] -> %s", string, p.get(string));
}
}
log.info("Starting Quidem with URI[%s]", quidemUri);
Launcher launcher = new Launcher(quidemUri);
System.exit(1);
launcher.start();
launcher.lifecycle.join();
}

View File

@ -64,7 +64,7 @@ public class QuidemCaptureResource
stopIfRunning();
recorder = new QuidemRecorder(
quidemURI,
new FileOutputStream("/tmp/new.iq")
new FileOutputStream("new1.iq")
);
return recorder.toString();
}

View File

@ -90,7 +90,8 @@ public class DruidAvaticaTestDriver implements Driver
new DruidAvaticaTestDriver().register();
}
public static final String URI_PREFIX = "druidtest://";
public static final String SCHEME = "druidtest";
public static final String URI_PREFIX = SCHEME + "://";
public static final String DEFAULT_URI = URI_PREFIX + "/";
static final SqlTestFrameworkConfigStore CONFIG_STORE = new SqlTestFrameworkConfigStore(

View File

@ -31,6 +31,7 @@ import com.google.inject.Module;
import org.apache.druid.java.util.common.IAE;
import org.apache.druid.java.util.common.StringUtils;
import org.apache.druid.query.topn.TopNQueryConfig;
import org.apache.druid.quidem.DruidAvaticaTestDriver;
import org.apache.druid.sql.calcite.util.CacheTestHelperModule.ResultCacheMode;
import org.apache.druid.sql.calcite.util.SqlTestFramework;
import org.apache.druid.sql.calcite.util.SqlTestFramework.QueryComponentSupplier;
@ -419,10 +420,20 @@ public class SqlTestFrameworkConfig
public static SqlTestFrameworkConfig fromURL(String url) throws SQLException
{
Map<String, String> queryParams;
queryParams = new HashMap<>();
try {
List<NameValuePair> params = URLEncodedUtils.parse(new URI(url), StandardCharsets.UTF_8);
URI uri = new URI(url);
if (!DruidAvaticaTestDriver.SCHEME.equals(uri.getScheme())) {
throw new SQLException(
StringUtils.format("URI [%s] is invalid ; only scheme [%s] is supported.", url, DruidAvaticaTestDriver.SCHEME)
);
}
if (uri.getHost() != null || uri.getPort() != -1) {
throw new SQLException(StringUtils.format("URI [%s] is invalid ; only query parameters are supported.", url));
}
List<NameValuePair> params = URLEncodedUtils.parse(uri, StandardCharsets.UTF_8);
for (NameValuePair pair : params) {
queryParams.put(pair.getName(), pair.getValue());
}