Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 31 additions & 36 deletions core/trino-main/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@

<properties>
<air.main.basedir>${project.parent.basedir}</air.main.basedir>

<!--
Project's default for air.test.parallel is 'methods'. By design, 'instances' runs all the methods in the same instance in the same thread,
but two methods on two different instances will be running in different threads.
As a side effect, it prevents TestNG from initializing multiple test instances upfront, which happens with 'methods'.
A potential downside can be long tail single-threaded execution of a single long test class.
TODO (https://github.com/trinodb/trino/issues/11294) remove when we upgrade to surefire with https://issues.apache.org/jira/browse/SUREFIRE-1967
-->
<air.test.parallel>instances</air.test.parallel>
</properties>

<dependencies>
Expand Down Expand Up @@ -390,12 +381,6 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
Expand Down Expand Up @@ -533,25 +518,35 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<dependencies>
<!-- allow both JUnit and TestNG -->
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit-platform</artifactId>
<version>${dep.plugin.surefire.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>${dep.plugin.surefire.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>benchmarks</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<executable>${java.home}/bin/java</executable>
<arguments>
<argument>-DoutputDirectory=benchmark_outputs</argument>
<argument>-classpath</argument>
<classpath />
<argument>io.trino.benchmark.BenchmarkSuite</argument>
</arguments>
<classpathScope>test</classpathScope>
</configuration>
<executions>
<execution>
<id>benchmarks</id>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@

import io.trino.array.LongBigArray;
import it.unimi.dsi.fastutil.longs.LongArrayList;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import static com.google.common.collect.Lists.cartesianProduct;
import static java.lang.Math.min;
import static org.assertj.core.api.Assertions.assertThat;

Expand All @@ -43,27 +41,20 @@ public long hashCode(long rowId)
}
};

@DataProvider
public static Object[][] parameters()
{
List<Integer> topNs = Arrays.asList(1, 2, 3);
List<Integer> valueCounts = Arrays.asList(0, 1, 2, 4, 8);
List<Integer> groupCounts = Arrays.asList(1, 2, 3);
List<Boolean> drainWithRankings = Arrays.asList(true, false);
return to2DArray(cartesianProduct(topNs, valueCounts, groupCounts, drainWithRankings));
}

private static Object[][] to2DArray(List<List<Object>> nestedList)
@Test
public void testSinglePeerGroupInsert()
{
Object[][] array = new Object[nestedList.size()][];
for (int i = 0; i < nestedList.size(); i++) {
array[i] = nestedList.get(i).toArray();
for (int topN : Arrays.asList(1, 2, 3)) {
for (int valueCount : Arrays.asList(0, 1, 2, 4, 8)) {
for (int groupCount : Arrays.asList(1, 2, 3)) {
testSinglePeerGroupInsert(topN, valueCount, groupCount, true);
testSinglePeerGroupInsert(topN, valueCount, groupCount, false);
}
}
}
return array;
}

@Test(dataProvider = "parameters")
public void testSinglePeerGroupInsert(int topN, long valueCount, long groupCount, boolean drainWithRanking)
private void testSinglePeerGroupInsert(int topN, long valueCount, long groupCount, boolean drainWithRanking)
{
List<Long> evicted = new LongArrayList();
GroupedTopNRankAccumulator accumulator = new GroupedTopNRankAccumulator(STRATEGY, topN, evicted::add);
Expand Down Expand Up @@ -103,8 +94,20 @@ public void testSinglePeerGroupInsert(int topN, long valueCount, long groupCount
}
}

@Test(dataProvider = "parameters")
public void testIncreasingAllUniqueValues(int topN, long valueCount, long groupCount, boolean drainWithRanking)
@Test
public void testIncreasingAllUniqueValues()
{
for (int topN : Arrays.asList(1, 2, 3)) {
for (int valueCount : Arrays.asList(0, 1, 2, 4, 8)) {
for (int groupCount : Arrays.asList(1, 2, 3)) {
testIncreasingAllUniqueValues(topN, valueCount, groupCount, true);
testIncreasingAllUniqueValues(topN, valueCount, groupCount, false);
}
}
}
}

private void testIncreasingAllUniqueValues(int topN, long valueCount, long groupCount, boolean drainWithRanking)
{
List<Long> evicted = new LongArrayList();
GroupedTopNRankAccumulator accumulator = new GroupedTopNRankAccumulator(STRATEGY, topN, evicted::add);
Expand Down Expand Up @@ -144,8 +147,20 @@ public void testIncreasingAllUniqueValues(int topN, long valueCount, long groupC
}
}

@Test(dataProvider = "parameters")
public void testDecreasingAllUniqueValues(int topN, long valueCount, long groupCount, boolean drainWithRanking)
@Test
public void testDecreasingAllUniqueValues()
{
for (int topN : Arrays.asList(1, 2, 3)) {
for (int valueCount : Arrays.asList(0, 1, 2, 4, 8)) {
for (int groupCount : Arrays.asList(1, 2, 3)) {
testDecreasingAllUniqueValues(topN, valueCount, groupCount, true);
testDecreasingAllUniqueValues(topN, valueCount, groupCount, false);
}
}
}
}

private void testDecreasingAllUniqueValues(int topN, long valueCount, long groupCount, boolean drainWithRanking)
{
List<Long> evicted = new LongArrayList();
GroupedTopNRankAccumulator accumulator = new GroupedTopNRankAccumulator(STRATEGY, topN, evicted::add);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
import io.trino.spi.type.TypeOperators;
import io.trino.sql.gen.JoinCompiler;
import io.trino.type.BlockTypeOperators;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.junit.jupiter.api.Test;

import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
Expand All @@ -39,12 +38,6 @@

public class TestGroupedTopNRankBuilder
{
@DataProvider
public static Object[][] produceRanking()
{
return new Object[][] {{true}, {false}};
}

@Test
public void testEmptyInput()
{
Expand Down Expand Up @@ -74,8 +67,14 @@ public long hashCode(Page page, int position)
assertThat(groupedTopNBuilder.buildResult().hasNext()).isFalse();
}

@Test(dataProvider = "produceRanking")
public void testSingleGroupTopN(boolean produceRanking)
@Test
public void testSingleGroupTopN()
{
testSingleGroupTopN(true);
testSingleGroupTopN(false);
}

private void testSingleGroupTopN(boolean produceRanking)
{
TypeOperators typeOperators = new TypeOperators();
BlockTypeOperators blockTypeOperators = new BlockTypeOperators(typeOperators);
Expand Down Expand Up @@ -133,8 +132,14 @@ public void testSingleGroupTopN(boolean produceRanking)
assertPageEquals(outputTypes, getOnlyElement(output), expected);
}

@Test(dataProvider = "produceRanking")
public void testMultiGroupTopN(boolean produceRanking)
@Test
public void testMultiGroupTopN()
{
testMultiGroupTopN(true);
testMultiGroupTopN(false);
}

private void testMultiGroupTopN(boolean produceRanking)
{
TypeOperators typeOperators = new TypeOperators();
BlockTypeOperators blockTypeOperators = new BlockTypeOperators(typeOperators);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
import io.trino.spi.type.Type;
import io.trino.spi.type.TypeOperators;
import io.trino.sql.gen.JoinCompiler;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.junit.jupiter.api.Test;

import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
Expand All @@ -36,19 +35,6 @@ public class TestGroupedTopNRowNumberBuilder
{
private static final TypeOperators TYPE_OPERATORS_CACHE = new TypeOperators();

@DataProvider
public static Object[][] produceRowNumbers()
{
return new Object[][] {{true}, {false}};
}

@DataProvider
public static Object[][] pageRowCounts()
{
// make either page or row count > 1024 to expand the big arrays
return new Object[][] {{10000, 20}, {20, 10000}};
}

@Test
public void testEmptyInput()
{
Expand All @@ -64,8 +50,14 @@ public void testEmptyInput()
assertThat(groupedTopNBuilder.buildResult().hasNext()).isFalse();
}

@Test(dataProvider = "produceRowNumbers")
public void testMultiGroupTopN(boolean produceRowNumbers)
@Test
public void testMultiGroupTopN()
{
testMultiGroupTopN(true);
testMultiGroupTopN(false);
}

private void testMultiGroupTopN(boolean produceRowNumbers)
{
List<Type> types = ImmutableList.of(BIGINT, DOUBLE);
List<Page> input = rowPagesBuilder(types)
Expand Down Expand Up @@ -131,8 +123,14 @@ public void testMultiGroupTopN(boolean produceRowNumbers)
}
}

@Test(dataProvider = "produceRowNumbers")
public void testSingleGroupTopN(boolean produceRowNumbers)
@Test
public void testSingleGroupTopN()
{
testSingleGroupTopN(true);
testSingleGroupTopN(false);
}

private void testSingleGroupTopN(boolean produceRowNumbers)
{
List<Type> types = ImmutableList.of(BIGINT, DOUBLE);
List<Page> input = rowPagesBuilder(types)
Expand Down
Loading