Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add e2e testcases for REST based remote functions #23777

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,4 @@ presto-native-execution/deps-install
# Compiled executables used for docker build
/docker/presto-cli-*-executable.jar
/docker/presto-server-*.tar.gz
/docker/presto-remote-function-server-executable.jar
4 changes: 4 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ FROM quay.io/centos/centos:stream9
ARG PRESTO_VERSION
ARG PRESTO_PKG=presto-server-$PRESTO_VERSION.tar.gz
ARG PRESTO_CLI_JAR=presto-cli-$PRESTO_VERSION-executable.jar
ARG PRESTO_REMOTE_SERVER_JAR=presto-remote-function-server-executable.jar
ARG JMX_PROMETHEUS_JAVAAGENT_VERSION=0.20.0

ENV PRESTO_HOME="/opt/presto-server"

COPY $PRESTO_PKG .
COPY $PRESTO_CLI_JAR /opt/presto-cli
COPY $PRESTO_REMOTE_SERVER_JAR /opt/presto-remote-server

Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove unwanted line


RUN dnf install -y java-11-openjdk less procps python3 \
&& ln -s $(which python3) /usr/bin/python \
Expand All @@ -19,6 +22,7 @@ RUN dnf install -y java-11-openjdk less procps python3 \
&& rm -rf ./presto-server-$PRESTO_VERSION \
&& chmod +x /opt/presto-cli \
&& ln -s /opt/presto-cli /usr/local/bin/ \
&& chmod +x /opt/presto-remote-server \
# clean cache jobs
&& mv /etc/yum/protected.d/systemd.conf /etc/yum/protected.d/systemd.conf.bak \
&& dnf clean all \
Expand Down
2 changes: 2 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

set -e

java -Dconfig=/opt/function-server/etc/config.properties -jar /opt/presto-remote-server >> log1.txt 2>&1
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove temporary log.


$PRESTO_HOME/bin/launcher run
20 changes: 20 additions & 0 deletions presto-main/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,26 @@
</ignorePackages>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>presto-remote-function-server-executable</finalName>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.facebook.presto.server.FunctionServer</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
Expand Down
8 changes: 7 additions & 1 deletion presto-native-execution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,12 @@
<include>presto-cli-*-executable.jar</include>
</includes>
</resource>
<resource>
<directory>${project.parent.basedir}/presto-main/target</directory>
<includes>
<include>presto-remote-function-server-executable.jar</include>
</includes>
</resource>
<resource>
<directory>${project.parent.basedir}/presto-server/target</directory>
<includes>
Expand Down Expand Up @@ -433,7 +439,7 @@
<args>
<BUILD_TYPE>Release</BUILD_TYPE>
<DEPENDENCY_IMAGE>presto-native-dependency:latest</DEPENDENCY_IMAGE>
<EXTRA_CMAKE_FLAGS>-DPRESTO_ENABLE_TESTING=OFF</EXTRA_CMAKE_FLAGS>
<EXTRA_CMAKE_FLAGS>-DPRESTO_ENABLE_REMOTE_FUNCTIONS=ON</EXTRA_CMAKE_FLAGS>
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you keep existing CMAKE flags

<NUM_THREADS>2</NUM_THREADS>
<BASE_IMAGE>ubuntu:22.04</BASE_IMAGE>
<OSNAME>ubuntu</OSNAME>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,5 +314,5 @@ JavaClasses:
- presto-main/src/main/java/com/facebook/presto/connector/system/SystemTableLayoutHandle.java
- presto-main/src/main/java/com/facebook/presto/connector/system/SystemTransactionHandle.java
- presto-spi/src/main/java/com/facebook/presto/spi/function/AggregationFunctionMetadata.java
- presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/json/JsonBasedUdfFunctionMetadata.java
- presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/JsonBasedUdfFunctionMetadata.java
- presto-spi/src/main/java/com/facebook/presto/spi/plan/ExchangeEncoding.java
Original file line number Diff line number Diff line change
Expand Up @@ -364,4 +364,4 @@ JavaClasses:
- presto-main/src/main/java/com/facebook/presto/connector/system/SystemTableLayoutHandle.java
- presto-main/src/main/java/com/facebook/presto/connector/system/SystemTransactionHandle.java
- presto-spi/src/main/java/com/facebook/presto/spi/function/AggregationFunctionMetadata.java
- presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/json/JsonBasedUdfFunctionMetadata.java
- presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/JsonBasedUdfFunctionMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@ public static void createNativeWorkerConfigProperties(int coordinatorPort, Strin
createPropertiesFile("testcontainers/" + nodeId + "/etc/config.properties", properties);
}

public static void createNativeWorkerConfigPropertiesWithFunctionServer(int coordinatorPort, int functionServerPort, String nodeId)
throws IOException
{
Properties properties = new Properties();
properties.setProperty("presto.version", "testversion");
properties.setProperty("http-server.http.port", "7777");
properties.setProperty("discovery.uri", "http://presto-coordinator:" + coordinatorPort);
properties.setProperty("system-memory-gb", "2");
properties.setProperty("native.sidecar", "false");
properties.setProperty("remote-function-server.rest.url", "http://presto-coordinator:" + functionServerPort);
createPropertiesFile("testcontainers/" + nodeId + "/etc/config.properties", properties);
}

public static void createCoordinatorConfigProperties(int port)
throws IOException
{
Expand All @@ -93,6 +106,8 @@ public static void createCoordinatorConfigProperties(int port)
properties.setProperty("http-server.http.port", Integer.toString(port));
properties.setProperty("discovery-server.enabled", "true");
properties.setProperty("discovery.uri", "http://presto-coordinator:" + port);
properties.setProperty("list-built-in-functions-only", "false");
properties.setProperty("native-execution-enabled", "false");

// Get native worker system properties and add them to the coordinator properties
Map<String, String> nativeWorkerProperties = NativeQueryRunnerUtils.getNativeWorkerSystemProperties();
Expand All @@ -103,6 +118,52 @@ public static void createCoordinatorConfigProperties(int port)
createPropertiesFile("testcontainers/coordinator/etc/config.properties", properties);
}

public static void createFunctionNamespaceRemoteProperties()
throws IOException
{
Properties properties = new Properties();
properties.setProperty("function-namespace-manager.name", "rest");
properties.setProperty("supported-function-languages", "Java");
properties.setProperty("function-implementation-type", "REST");

String directoryPath = "testcontainers/function-namespace";
File directory = new File(directoryPath);
if (!directory.exists()) {
directory.mkdirs();
}

createPropertiesFile("testcontainers/coordinator/etc/function-namespace/remote.properties", properties);
}

public static void createFunctionNamespaceRemotePropertiesWithFunctionServer(int functionServerPort)
throws IOException
{
Properties properties = new Properties();
properties.setProperty("function-namespace-manager.name", "rest");
properties.setProperty("supported-function-languages", "Java");
properties.setProperty("function-implementation-type", "REST");
properties.setProperty("rest-based-function-manager.rest.url", "http://localhost:" + functionServerPort);

String directoryPath = "testcontainers/function-namespace";
File directory = new File(directoryPath);
if (!directory.exists()) {
directory.mkdirs();
}

createPropertiesFile("testcontainers/coordinator/etc/function-namespace/remote.properties", properties);
}

public static void createFunctionServerConfigProperties(int functionServerPort)
throws IOException
{
Properties properties = new Properties();
properties.setProperty("http-server.http.port", String.valueOf(functionServerPort));
properties.setProperty("regex-library", "RE2J");
properties.setProperty("parse-decimal-literals-as-double", "true");

createPropertiesFile("testcontainers/coordinator/etc/function-server/config.properties", properties);
}

public static void createCoordinatorJvmConfig()
throws IOException

Expand Down Expand Up @@ -161,6 +222,11 @@ public static void createCoordinatorEntryPointScript()
{
String scriptContent = "#!/bin/sh\n" +
"set -e\n" +
"java " +
// "-Dplugin.dir=/opt/presto-remote-server/function-server-plugin " +
// "-Dconfig=/opt/presto-remote-server/function-server-etc/config.properties " +
// "-jar /opt/presto-remote-server >> log1.txt 2>&1 & \n" +
"-Dconfig=/opt/function-server/etc/config.properties -jar /opt/presto-remote-server >> log1.txt 2>&1 & \n" +
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

"$PRESTO_HOME/bin/launcher run\n";
createScriptFile("testcontainers/coordinator/entrypoint.sh", scriptContent);
}
Expand Down Expand Up @@ -204,10 +270,6 @@ public static void createPropertiesFile(String filePath, Properties properties)
parentDir.mkdirs();
}

if (file.exists()) {
throw new IOException("File exists: " + filePath);
}

try (OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8)) {
for (String key : properties.stringPropertyNames()) {
writer.write(key + "=" + properties.getProperty(key) + "\n");
Expand All @@ -224,10 +286,6 @@ public static void createScriptFile(String filePath, String scriptContent)
parentDir.mkdirs();
}

if (file.exists()) {
throw new IOException("File exists: " + filePath);
}

try (OutputStream output = new FileOutputStream(file);
OutputStreamWriter writer = new OutputStreamWriter(output, StandardCharsets.UTF_8)) {
writer.write(scriptContent);
Expand Down
Loading
Loading