This commit is contained in:
Zoltan Haindrich 2024-06-17 16:05:29 +00:00
parent 7eccf5b518
commit f5720ce97d
6 changed files with 76 additions and 13 deletions

2
quidem-it/new1.iq Normal file
View File

@ -0,0 +1,2 @@
#started
!connect druidtest:///

View File

@ -330,6 +330,11 @@
<groupId>com.github.docker-java</groupId>
<artifactId>docker-java-core</artifactId>
</dependency>
<dependency>
<groupId>com.github.javafaker</groupId>
<artifactId>javafaker</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-kqueue</artifactId>
@ -484,7 +489,6 @@
<artifactId>hamcrest-core</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

View File

@ -19,7 +19,10 @@
package org.apache.druid.quidem;
import com.github.javafaker.Faker;
import com.github.javafaker.Pokemon;
import com.google.inject.Inject;
import org.apache.hadoop.util.StringUtils;
import javax.inject.Named;
import javax.ws.rs.GET;
@ -27,6 +30,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URI;
@ -53,7 +57,7 @@ public class QuidemCaptureResource
private boolean withAutoStart()
{
return Boolean.valueOf(System.getProperty("quidem.autostart", "false"));
return Boolean.valueOf(System.getProperty("quidem.record.autostart", "false"));
}
@GET
@ -64,11 +68,25 @@ public class QuidemCaptureResource
stopIfRunning();
recorder = new QuidemRecorder(
quidemURI,
new FileOutputStream("new1.iq")
new FileOutputStream(extracted())
);
return recorder.toString();
}
private File extracted()
{
File dir = QTest.testRoot();
Pokemon pokemon = Faker.instance().pokemon();
String fileName = StringUtils.format("quidem-%s.txt", pokemon.name());
return new File(dir, fileName);
}
public static void main(String[] args)
{
Pokemon pokemon = Faker.instance().pokemon();
System.out.println(Faker.instance().aviation().aircraft());
}
private synchronized void stopIfRunning()
{
if (recorder != null) {

View File

@ -0,0 +1,41 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.druid.quidem;
import java.io.File;
public class QTest extends DruidQuidemTestBase
{
public QTest()
{
super();
}
@Override
protected File getTestRoot()
{
return testRoot();
}
public static File testRoot()
{
return ProjectPathUtils.getPathFromProjectRoot("quidem-it/src/test/quidem/" + QTest.class.getName());
}
}

View File

@ -29,12 +29,14 @@ import org.apache.calcite.util.Closer;
import org.apache.calcite.util.Util;
import org.apache.commons.io.filefilter.TrueFileFilter;
import org.apache.commons.io.filefilter.WildcardFileFilter;
import org.apache.druid.common.config.NullHandling;
import org.apache.druid.java.util.common.FileUtils;
import org.apache.druid.java.util.common.IAE;
import org.apache.druid.java.util.common.RE;
import org.apache.druid.java.util.common.StringUtils;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.condition.EnabledIf;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
@ -76,8 +78,14 @@ import static org.junit.jupiter.api.Assertions.fail;
*
*/
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@EnabledIf(value = "enabled", disabledReason = "These tests are only run in SqlCompatible mode!")
public abstract class DruidQuidemTestBase
{
public static boolean enabled()
{
NullHandling.initializeForTests();
return NullHandling.sqlCompatible();
}
public static final String IQ_SUFFIX = ".iq";
/**

View File

@ -19,20 +19,10 @@
package org.apache.druid.quidem;
import org.apache.druid.common.config.NullHandling;
import org.junit.jupiter.api.condition.EnabledIf;
import java.io.File;
@EnabledIf(value = "enabled", disabledReason = "These tests are only run in SqlCompatible mode!")
public class SqlQuidemTest extends DruidQuidemTestBase
{
public static boolean enabled()
{
NullHandling.initializeForTests();
return NullHandling.sqlCompatible();
}
public SqlQuidemTest()
{
super();