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
71 changes: 71 additions & 0 deletions .github/workflows/prestocpp-linux-build-and-unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,77 @@ jobs:
-Duser.timezone=America/Bahia_Banderas \
-T1C

prestocpp-linux-presto-native-tests:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too much code copying is happening with these test jobs (E22, sidecar plugin and now this one). We will refactor the test jobs after the merge and not make the refactor part of the PR.

needs: prestocpp-linux-build-for-test
runs-on: ubuntu-22.04
container:
image: prestodb/presto-native-dependency:0.292-20250204112033-cf8ba84
env:
MAVEN_OPTS: "-Xmx4G -XX:+ExitOnOutOfMemoryError"
MAVEN_FAST_INSTALL: "-B -V --quiet -T 1C -DskipTests -Dair.check.skip-all -Dmaven.javadoc.skip=true"
MAVEN_TEST: "-B -Dair.check.skip-all -Dmaven.javadoc.skip=true -DLogTestDurationListener.enabled=true --fail-at-end"
steps:
- uses: actions/checkout@v4

- name: Fix git permissions
# Usually actions/checkout does this but as we run in a container
# it doesn't work
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}

- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: presto-native-build
path: presto-native-execution/_build/release

# Permissions are lost when uploading. Details here: https://github.com/actions/upload-artifact/issues/38
- name: Restore execute permissions and library path
run: |
chmod +x ${GITHUB_WORKSPACE}/presto-native-execution/_build/release/presto_cpp/main/presto_server
chmod +x ${GITHUB_WORKSPACE}/presto-native-execution/_build/release/velox/velox/functions/remote/server/velox_functions_remote_server_main
# Ensure transitive dependency libboost-iostreams is found.
ldconfig /usr/local/lib

- name: Install OpenJDK8
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
cache: 'maven'
- name: Download nodejs to maven cache
run: .github/bin/download_nodejs

- name: Maven install
env:
# Use different Maven options to install.
MAVEN_OPTS: "-Xmx2G -XX:+ExitOnOutOfMemoryError"
run: |
for i in $(seq 1 3); do ./mvnw clean install $MAVEN_FAST_INSTALL -pl 'presto-native-tests' -am && s=0 && break || s=$? && sleep 10; done; (exit $s)

- name: Run presto-native tests
run: |
export PRESTO_SERVER_PATH="${GITHUB_WORKSPACE}/presto-native-execution/_build/release/presto_cpp/main/presto_server"
export TESTFILES=`find ./presto-native-tests/src/test -type f -name 'Test*.java'`
# Convert file paths to comma separated class names
export TESTCLASSES=
for test_file in $TESTFILES
do
tmp=${test_file##*/}
test_class=${tmp%%\.*}
export TESTCLASSES="${TESTCLASSES},$test_class"
done
export TESTCLASSES=${TESTCLASSES#,}
echo "TESTCLASSES = $TESTCLASSES"

mvn test \
${MAVEN_TEST} \
-pl 'presto-native-tests' \
-Dtest="${TESTCLASSES}" \
-DPRESTO_SERVER=${PRESTO_SERVER_PATH} \
-DDATA_DIR=${RUNNER_TEMP} \
-Duser.timezone=America/Bahia_Banderas \
-T1C

prestocpp-linux-presto-sidecar-tests:
needs: prestocpp-linux-build-for-test
runs-on: ubuntu-22.04
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-other-modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ jobs:
run: |
./mvnw test -T 1 ${MAVEN_TEST} -pl '
!presto-tests,
!presto-native-tests,
!presto-accumulo,
!presto-cassandra,
!presto-hive,
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
<module>presto-test-coverage</module>
<module>presto-hudi</module>
<module>presto-native-execution</module>
<module>presto-native-tests</module>
<module>presto-router</module>
<module>presto-open-telemetry</module>
<module>redis-hbo-provider</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.UUID;
Expand Down Expand Up @@ -128,7 +130,7 @@ public static QueryRunner createQueryRunner(
defaultQueryRunner.close();

return createNativeQueryRunner(dataDirectory.get().toString(), prestoServerPath.get(), workerCount, cacheMaxSize, true, Optional.empty(),
storageFormat, addStorageFormatToPath, false, isCoordinatorSidecarEnabled, false, enableRuntimeMetricsCollection, enableSsdCache);
storageFormat, addStorageFormatToPath, false, isCoordinatorSidecarEnabled, false, enableRuntimeMetricsCollection, enableSsdCache, Collections.emptyMap());
}

public static QueryRunner createJavaQueryRunner()
Expand Down Expand Up @@ -335,7 +337,8 @@ public static QueryRunner createNativeQueryRunner(
boolean isCoordinatorSidecarEnabled,
boolean singleNodeExecutionEnabled,
boolean enableRuntimeMetricsCollection,
boolean enableSsdCache)
boolean enableSsdCache,
Map<String, String> extraProperties)
throws Exception
{
// The property "hive.allow-drop-table" needs to be set to true because security is always "legacy" in NativeQueryRunner.
Expand All @@ -359,6 +362,7 @@ public static QueryRunner createNativeQueryRunner(
.put("experimental.internal-communication.thrift-transport-enabled", String.valueOf(useThrift))
.putAll(getNativeWorkerSystemProperties())
.putAll(isCoordinatorSidecarEnabled ? getNativeSidecarProperties() : ImmutableMap.of())
.putAll(extraProperties)
.build(),
coordinatorProperties.build(),
"legacy",
Expand Down Expand Up @@ -420,6 +424,28 @@ public static QueryRunner createNativeQueryRunner(String remoteFunctionServerUds
return createNativeQueryRunner(false, DEFAULT_STORAGE_FORMAT, Optional.ofNullable(remoteFunctionServerUds), false, false, false, false, false);
}

public static QueryRunner createNativeQueryRunner(Map<String, String> extraProperties, String storageFormat)
throws Exception
{
int cacheMaxSize = 0;
NativeQueryRunnerParameters nativeQueryRunnerParameters = getNativeQueryRunnerParameters();
return createNativeQueryRunner(
nativeQueryRunnerParameters.dataDirectory.toString(),
nativeQueryRunnerParameters.serverBinary.toString(),
nativeQueryRunnerParameters.workerCount,
cacheMaxSize,
true,
Optional.empty(),
storageFormat,
true,
false,
false,
false,
false,
false,
extraProperties);
}

public static QueryRunner createNativeQueryRunner(boolean useThrift)
throws Exception
{
Expand Down Expand Up @@ -464,7 +490,8 @@ public static QueryRunner createNativeQueryRunner(
isCoordinatorSidecarEnabled,
singleNodeExecutionEnabled,
enableRuntimeMetricsCollection,
enableSSDCache);
enableSSDCache,
Collections.emptyMap());
}

// Start the remote function server. Return the UDS path used to communicate with it.
Expand Down
31 changes: 31 additions & 0 deletions presto-native-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Presto Native Tests

This module contains end-to-end tests that run queries from test classes in
the `presto-tests` module with Presto C++ workers. Please build the module
`presto-native-execution` first.

The following command can be used to run all tests in this module:
```
mvn test
-pl 'presto-native-tests'
-Dtest="com.facebook.presto.nativetests.Test*"
-Duser.timezone=America/Bahia_Banderas
-DPRESTO_SERVER=${PRESTO_HOME}/presto-native-execution/cmake-build-debug/presto_cpp/main/presto_server
-DWORKER_COUNT=${WORKER_COUNT} -T1C
```
Please update JVM argument `PRESTO_SERVER` to point to the Presto C++ worker
binary `presto_server`.

## Adding new tests

Presto C++ currently does not have the same behavior as Presto for certain
queries. This could be because of missing types, missing function signatures,
among other reasons. Tests with these unsupported queries are therefore
expected to fail and the test asserts the error message is as expected.

Issues should also be created for the failing queries, so they are documented
and fixed. Please add the tag `presto-native-tests` for these issues.
Once all the failures in a testcase are fixed, the overriden test in this
module should be removed and the testcase in the corresponding base class in
`presto-tests` would be the single source of truth for Presto SQL coverage
tests.
109 changes: 109 additions & 0 deletions presto-native-tests/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-root</artifactId>
<version>0.292-SNAPSHOT</version>
</parent>

<artifactId>presto-native-tests</artifactId>
<name>presto-native-tests</name>
<description>Presto Native Tests</description>

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

<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</dependency>

<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-main</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-native-execution</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-tests</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-tpcds</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<!-- Disable git-commit-id-plugin plugin to allow for running tests without
a git checkout -->
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.basepom.maven</groupId>
<artifactId>duplicate-finder-maven-plugin</artifactId>
<configuration>
<ignoredResourcePatterns>
<ignoredResourcePattern>parquet.thrift</ignoredResourcePattern>
<ignoredResourcePattern>about.html</ignoredResourcePattern>
<ignoredResourcePattern>mozilla/public-suffix-list.txt</ignoredResourcePattern>
<ignoredResourcePattern>iceberg-build.properties</ignoredResourcePattern>
<ignoredResourcePattern>org.apache.avro.data/Json.avsc</ignoredResourcePattern>
</ignoredResourcePatterns>
<ignoredClassPatterns>
<ignoredClassPattern>com.esotericsoftware.kryo.*</ignoredClassPattern>
<ignoredClassPattern>com.esotericsoftware.minlog.Log</ignoredClassPattern>
<ignoredClassPattern>com.esotericsoftware.reflectasm.*</ignoredClassPattern>
<ignoredClassPattern>module-info</ignoredClassPattern>
<ignoredClassPattern>META-INF.versions.9.module-info</ignoredClassPattern>
<ignoredClassPattern>org.apache.avro.*</ignoredClassPattern>
<ignoredClassPattern>com.github.benmanes.caffeine.*</ignoredClassPattern>
<ignoredClassPattern>org.roaringbitmap.*</ignoredClassPattern>
</ignoredClassPatterns>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Xms4g -Xmx4g</argLine>
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
<excludedGroups>remote-function,textfile_reader</excludedGroups>
<systemPropertyVariables>
<PRESTO_SERVER>/root/project/build/debug/presto_cpp/main/presto_server</PRESTO_SERVER>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</project>
Loading
Loading