yashmayya commented on code in PR #13817:
URL: https://github.com/apache/pinot/pull/13817#discussion_r1716695667
##########
pinot-core/src/test/java/org/apache/pinot/queries/FluentQueryTest.java:
##########
@@ -101,11 +182,22 @@ public static class DeclaringTable {
_extraQueryOptions = extraQueryOptions;
}
+ /**
+ * Creates one segment on the first instance with the given content.
+ *
+ * @param content the content of the segment.
+ * @see OnFirstInstance#andSegment(String...) to learn more about the
content syntax
+ */
Review Comment:
What are the first and second "instances" referring to exactly? It's a
little unclear to me.
##########
pinot-core/src/test/java/org/apache/pinot/queries/FluentQueryTest.java:
##########
@@ -55,36 +57,115 @@
import org.testng.Assert;
+/**
+ * A fluent API for testing queries.
+ *
+ * Use {@link #withBaseDir(File)} to start a new test.
+ *
+ * @see
org.apache.pinot.core.query.aggregation.function.CountAggregationFunctionTest
+ */
public class FluentQueryTest {
private final FluentBaseQueriesTest _baseQueriesTest;
- private final File _baseDir;
+ final File _baseDir;
private final Map<String, String> _extraQueryOptions = new HashMap<>();
- private FluentQueryTest(FluentBaseQueriesTest baseQueriesTest, File baseDir)
{
+ FluentQueryTest(FluentBaseQueriesTest baseQueriesTest, File baseDir) {
_baseQueriesTest = baseQueriesTest;
_baseDir = baseDir;
}
+ /**
+ * Start a new test with the given base directory.
+ *
+ * Usually the base directory will be created before every test and
destroyed after that using lifecycle testing
+ * hooks like {@link org.testng.annotations.BeforeClass} and {@link
org.testng.annotations.AfterClass}.
+ *
+ * Each test will create its own subdirectory in the base directory, so
multiple tests may use the same base
+ * directory.
+ *
+ * @param baseDir the base directory for the test. It must exist, be a
directory and be writable.
+ * @return The fluent API for testing queries, where eventually {@link
#givenTable(Schema, TableConfig)} will be
+ * called.
+ */
public static FluentQueryTest withBaseDir(File baseDir) {
+ Preconditions.checkArgument(baseDir.exists(), "Base directory must exist");
+ Preconditions.checkArgument(baseDir.isDirectory(), "Base directory must be
a directory");
+ Preconditions.checkArgument(baseDir.canWrite(), "Base directory must be
writable");
return new FluentQueryTest(new FluentBaseQueriesTest(), baseDir);
}
+ /**
+ * Creates a new test with a temporary directory.
+ *
+ * @param consumer the test to run. The received FluentQueryTest will use a
temporary directory that will be removed
+ * after the consumer is executed, even if a throwable is
thrown.
+ */
+ public static void test(Consumer<FluentQueryTest> consumer) {
+ StackWalker walker =
StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE);
+ try (Closeable test = new Closeable(walker.getCallerClass().getName())) {
+ consumer.accept(test);
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ }
+
+ /**
+ * Creates a new test with a temporary directory.
+ *
+ * The returned object is intended to be used in a try-with-resources manner.
+ * Its close method will remove the temporary directory.
+ */
+ public static FluentQueryTest.Closeable open() {
Review Comment:
Are there different targeted use cases for both these methods?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]