Skip to content

Commit 5488c18

Browse files
BryanCutlerpradeepvaka
authored andcommitted
Adding e2e tests for the native Arrow Flight connector
This adds e2e tests using the ArrowFlightQueryRunner to run native workers and test queries against a H2 Flight Producer data source. The CI workflow has been updated to add additional steps to build a native presto server with Arrow Flight connector enabled, and run the e2e Java tests with queries taken from AbstractTestNativeGeneralQueries that are compatible with the Flight data source.
1 parent 8659966 commit 5488c18

File tree

5 files changed

+593
-17
lines changed

5 files changed

+593
-17
lines changed

.github/workflows/arrow-flight-tests.yml

Lines changed: 158 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ env:
1414
RETRY: .github/bin/retry
1515

1616
jobs:
17-
test:
17+
arrowflight-java-tests:
1818
runs-on: ubuntu-latest
1919
strategy:
2020
fail-fast: false
@@ -48,6 +48,161 @@ jobs:
4848
export MAVEN_OPTS="${MAVEN_INSTALL_OPTS}"
4949
./mvnw install ${MAVEN_FAST_INSTALL} -am -pl ${{ matrix.modules }}
5050
51-
# Run Maven tests for the target module
51+
# Run Maven tests for the target module, excluding native tests
5252
- name: Maven Tests
53-
run: ./mvnw test ${MAVEN_TEST} -pl ${{ matrix.modules }}
53+
run: ./mvnw test ${MAVEN_TEST} -pl ${{ matrix.modules }} -Dtest="*,!TestArrowFlightNativeQueries"
54+
55+
prestocpp-linux-build-for-test:
56+
runs-on: ubuntu-22.04
57+
container:
58+
image: prestodb/presto-native-dependency:0.292-20250204112033-cf8ba84
59+
env:
60+
CCACHE_DIR: "${{ github.workspace }}/ccache"
61+
DEPENDENCY_DIR: "${{ github.workspace }}/adapter-deps/download"
62+
INSTALL_PREFIX: "${{ github.workspace }}/adapter-deps/install"
63+
steps:
64+
- uses: actions/checkout@v4
65+
66+
- name: Fix git permissions
67+
# Usually actions/checkout does this but as we run in a container
68+
# it doesn't work
69+
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
70+
71+
- name: Update velox
72+
run: |
73+
cd presto-native-execution
74+
make velox-submodule
75+
76+
- name: Install Arrow Flight
77+
run: |
78+
mkdir -p ${DEPENDENCY_DIR}/adapter-deps/download
79+
mkdir -p ${INSTALL_PREFIX}/adapter-deps/install
80+
source /opt/rh/gcc-toolset-12/enable
81+
set -xu
82+
cd presto-native-execution
83+
PROMPT_ALWAYS_RESPOND=n ./scripts/setup-adapters.sh arrow_flight
84+
85+
- name: Install Github CLI for using apache/infrastructure-actions/stash
86+
run: |
87+
curl -L https://github.com/cli/cli/releases/download/v2.63.2/gh_2.63.2_linux_amd64.rpm > gh_2.63.2_linux_amd64.rpm
88+
rpm -iv gh_2.63.2_linux_amd64.rpm
89+
90+
- uses: apache/infrastructure-actions/stash/restore@4ab8682fbd4623d2b4fc1c98db38aba5091924c3
91+
with:
92+
path: '${{ env.CCACHE_DIR }}'
93+
key: ccache-prestocpp-linux-build-for-test
94+
95+
- name: Zero ccache statistics
96+
run: ccache -sz
97+
98+
- name: Build engine
99+
run: |
100+
source /opt/rh/gcc-toolset-12/enable
101+
cd presto-native-execution
102+
cmake \
103+
-B _build/release \
104+
-GNinja \
105+
-DTREAT_WARNINGS_AS_ERRORS=1 \
106+
-DENABLE_ALL_WARNINGS=1 \
107+
-DVELOX_ENABLE_ARROW=OFF \
108+
-DVELOX_ENABLE_PARQUET=OFF \
109+
-DPRESTO_ENABLE_ARROW_FLIGHT_CONNECTOR=ON \
110+
-DCMAKE_PREFIX_PATH=/usr/local \
111+
-DThrift_ROOT=/usr/local \
112+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
113+
-DMAX_LINK_JOBS=4
114+
ninja -C _build/release -j 4
115+
116+
- name: Ccache after
117+
run: ccache -s
118+
119+
- uses: apache/infrastructure-actions/stash/save@4ab8682fbd4623d2b4fc1c98db38aba5091924c3
120+
with:
121+
path: '${{ env.CCACHE_DIR }}'
122+
key: ccache-prestocpp-linux-build-for-test
123+
124+
- name: Upload artifacts
125+
uses: actions/upload-artifact@v4
126+
with:
127+
name: arrow-flight-presto-native-build
128+
path: presto-native-execution/_build/release/presto_cpp/main/presto_server
129+
130+
- name: Upload Arrow Flight install artifacts
131+
uses: actions/upload-artifact@v4
132+
with:
133+
name: arrow-flight-install
134+
path: ${{ env.INSTALL_PREFIX }}/lib64/libarrow_flight*
135+
136+
arrowflight-native-e2e-tests:
137+
needs: prestocpp-linux-build-for-test
138+
runs-on: ubuntu-22.04
139+
container:
140+
image: prestodb/presto-native-dependency:0.292-20250204112033-cf8ba84
141+
env:
142+
INSTALL_PREFIX: "${{ github.workspace }}/adapter-deps/install"
143+
strategy:
144+
fail-fast: false
145+
matrix:
146+
modules:
147+
- ":presto-base-arrow-flight" # Only run tests for the `presto-base-arrow-flight` module
148+
149+
timeout-minutes: 80
150+
concurrency:
151+
group: ${{ github.workflow }}-test-${{ matrix.modules }}-${{ github.event.pull_request.number }}
152+
cancel-in-progress: true
153+
154+
steps:
155+
- uses: actions/checkout@v4
156+
157+
- name: Fix git permissions
158+
# Usually actions/checkout does this but as we run in a container
159+
# it doesn't work
160+
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
161+
162+
- name: Download artifacts
163+
uses: actions/download-artifact@v4
164+
with:
165+
name: arrow-flight-presto-native-build
166+
path: presto-native-execution/_build/release/presto_cpp/main
167+
168+
- name: Download Arrow Flight install artifacts
169+
uses: actions/download-artifact@v4
170+
with:
171+
name: arrow-flight-install
172+
path: ${{ env.INSTALL_PREFIX }}/lib64
173+
174+
# Permissions are lost when uploading. Details here: https://github.com/actions/upload-artifact/issues/38
175+
- name: Restore execute permissions and library path
176+
run: |
177+
chmod +x ${GITHUB_WORKSPACE}/presto-native-execution/_build/release/presto_cpp/main/presto_server
178+
# Ensure transitive dependency libboost-iostreams is found.
179+
ldconfig /usr/local/lib
180+
181+
- name: Install OpenJDK8
182+
uses: actions/setup-java@v4
183+
with:
184+
distribution: 'temurin'
185+
java-version: 8
186+
cache: 'maven'
187+
- name: Download nodejs to maven cache
188+
run: .github/bin/download_nodejs
189+
190+
- name: Maven install
191+
env:
192+
# Use different Maven options to install.
193+
MAVEN_OPTS: "-Xmx2G -XX:+ExitOnOutOfMemoryError"
194+
run: |
195+
export MAVEN_OPTS="${MAVEN_INSTALL_OPTS}"
196+
./mvnw install ${MAVEN_FAST_INSTALL} -am -pl ${{ matrix.modules }}
197+
198+
- name: Run arrowflight native e2e tests
199+
run: |
200+
export PRESTO_SERVER_PATH="${GITHUB_WORKSPACE}/presto-native-execution/_build/release/presto_cpp/main/presto_server"
201+
mvn test \
202+
${MAVEN_TEST} \
203+
-pl ${{ matrix.modules }} \
204+
-Dtest="TestArrowFlightNativeQueries" \
205+
-DPRESTO_SERVER=${PRESTO_SERVER_PATH} \
206+
-DDATA_DIR=${RUNNER_TEMP} \
207+
-Duser.timezone=America/Bahia_Banderas \
208+
-T1C

presto-base-arrow-flight/src/test/java/com/facebook/plugin/arrow/ArrowFlightQueryRunner.java

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@
2626
import org.apache.arrow.memory.RootAllocator;
2727

2828
import java.io.File;
29+
import java.net.URI;
2930
import java.util.Map;
3031
import java.util.Optional;
32+
import java.util.function.BiFunction;
3133

34+
import static com.facebook.plugin.arrow.testingConnector.TestingArrowFlightPlugin.ARROW_FLIGHT_CATALOG;
35+
import static com.facebook.plugin.arrow.testingConnector.TestingArrowFlightPlugin.ARROW_FLIGHT_CONNECTOR;
3236
import static com.facebook.presto.testing.TestingSession.testSessionBuilder;
3337

3438
public class ArrowFlightQueryRunner
@@ -40,49 +44,60 @@ private ArrowFlightQueryRunner()
4044

4145
public static DistributedQueryRunner createQueryRunner(int flightServerPort) throws Exception
4246
{
43-
return createQueryRunner(ImmutableMap.of("arrow-flight.server.port", String.valueOf(flightServerPort)));
47+
return createQueryRunner(flightServerPort, ImmutableMap.of(), ImmutableMap.of(), Optional.empty());
4448
}
4549

46-
private static DistributedQueryRunner createQueryRunner(Map<String, String> catalogProperties) throws Exception
50+
public static DistributedQueryRunner createQueryRunner(
51+
int flightServerPort,
52+
Map<String, String> extraProperties,
53+
Map<String, String> coordinatorProperties,
54+
Optional<BiFunction<Integer, URI, Process>> externalWorkerLauncher)
55+
throws Exception
4756
{
48-
return createQueryRunner(ImmutableMap.of(), catalogProperties);
57+
return createQueryRunner(extraProperties, ImmutableMap.of("arrow-flight.server.port", String.valueOf(flightServerPort)), coordinatorProperties, externalWorkerLauncher);
4958
}
5059

5160
private static DistributedQueryRunner createQueryRunner(
5261
Map<String, String> extraProperties,
53-
Map<String, String> catalogProperties)
62+
Map<String, String> catalogProperties,
63+
Map<String, String> coordinatorProperties,
64+
Optional<BiFunction<Integer, URI, Process>> externalWorkerLauncher)
5465
throws Exception
5566
{
5667
Session session = testSessionBuilder()
57-
.setCatalog("arrowflight")
68+
.setCatalog(ARROW_FLIGHT_CATALOG)
5869
.setSchema("tpch")
5970
.build();
6071

6172
DistributedQueryRunner.Builder queryRunnerBuilder = DistributedQueryRunner.builder(session);
6273
Optional<Integer> workerCount = getProperty("WORKER_COUNT").map(Integer::parseInt);
6374
workerCount.ifPresent(queryRunnerBuilder::setNodeCount);
6475

65-
DistributedQueryRunner queryRunner = queryRunnerBuilder.setExtraProperties(extraProperties).build();
76+
DistributedQueryRunner queryRunner = queryRunnerBuilder
77+
.setExtraProperties(extraProperties)
78+
.setCoordinatorProperties(coordinatorProperties)
79+
.setExternalWorkerLauncher(externalWorkerLauncher).build();
6680

6781
try {
68-
queryRunner.installPlugin(new TestingArrowFlightPlugin());
82+
boolean nativeExecution = externalWorkerLauncher.isPresent();
83+
queryRunner.installPlugin(new TestingArrowFlightPlugin(nativeExecution));
6984

7085
ImmutableMap.Builder<String, String> properties = ImmutableMap.<String, String>builder()
7186
.putAll(catalogProperties)
7287
.put("arrow-flight.server", "localhost")
7388
.put("arrow-flight.server-ssl-enabled", "true")
7489
.put("arrow-flight.server-ssl-certificate", "src/test/resources/server.crt");
7590

76-
queryRunner.createCatalog("arrowflight", "arrow-flight", properties.build());
91+
queryRunner.createCatalog(ARROW_FLIGHT_CATALOG, ARROW_FLIGHT_CONNECTOR, properties.build());
7792

7893
return queryRunner;
7994
}
8095
catch (Exception e) {
81-
throw new RuntimeException("Failed to create ArrowQueryRunner", e);
96+
throw new RuntimeException("Failed to create ArrowFlightQueryRunner", e);
8297
}
8398
}
8499

85-
private static Optional<String> getProperty(String name)
100+
public static Optional<String> getProperty(String name)
86101
{
87102
String systemPropertyValue = System.getProperty(name);
88103
if (systemPropertyValue != null) {
@@ -116,7 +131,9 @@ public static void main(String[] args)
116131

117132
DistributedQueryRunner queryRunner = createQueryRunner(
118133
ImmutableMap.of("http-server.http.port", "8080"),
119-
ImmutableMap.of("arrow-flight.server.port", String.valueOf(9443)));
134+
ImmutableMap.of("arrow-flight.server.port", String.valueOf(9443)),
135+
ImmutableMap.of(),
136+
Optional.empty());
120137
Thread.sleep(10);
121138
log.info("======== SERVER STARTED ========");
122139
log.info("\n====\n%s\n====", queryRunner.getCoordinator().getBaseUrl());

0 commit comments

Comments
 (0)