Skip to content

Apache DataFusion SQL Query Engine

ARROW-3367: [INTEGRATION] Port Spark integration test to the docker-compose setup

Krisztián Szűcs02aa920f732a
diff --git a/ci/docker_build_cpp.sh b/ci/docker_build_cpp.sh
index 2662704fb2..450dc87024 100755
--- a/ci/docker_build_cpp.sh
+++ b/ci/docker_build_cpp.sh
@@ -17,7 +17,6 @@
# under the License.
set -e
-set -o xtrace
source_dir=${1:-/arrow/cpp}
build_dir=${2:-/build/cpp}
diff --git a/ci/docker_build_java.sh b/ci/docker_build_java.sh
new file mode 100755
index 0000000000..0cbd00f816
--- /dev/null
+++ b/ci/docker_build_java.sh
@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+set -e
+
+# /arrow/java is read-only
+mkdir -p /build/java
+
+arrow_src=/build/java/arrow
+
+pushd /arrow
+ rsync -a header java format integration $arrow_src
+popd
+
+pushd $arrow_src/java
+ mvn -DskipTests -Drat.skip=true install
+popd
diff --git a/ci/docker_build_python.sh b/ci/docker_build_python.sh
index 801c50c19a..36b31b9973 100755
--- a/ci/docker_build_python.sh
+++ b/ci/docker_build_python.sh
@@ -26,15 +26,26 @@ export PYARROW_CMAKE_GENERATOR=Ninja
export PYARROW_BUILD_TYPE=${PYARROW_BUILD_TYPE:-debug}
# Feature flags
+export SETUPTOOLS_SCM_VERSION_WRITE_TO_PREFIX=$build_dir
export PYARROW_WITH_ORC=${PYARROW_WITH_ORC:-1}
export PYARROW_WITH_PARQUET=${PYARROW_WITH_PARQUET:-1}
export PYARROW_WITH_PLASMA=${PYARROW_WITH_PLASMA:-1}
# Build pyarrow
pushd ${source_dir}
+ # hacky again, setuptools_scm writes _generated_version.py before pyarrow
+ # directory is created by setuptools
+ mkdir -p $build_dir/pyarrow
-python setup.py build --build-temp=${build_dir} \
- install --single-version-externally-managed \
- --record=/build/python/record.txt
+ relative_build_dir=$(realpath --relative-to=. $build_dir)
+ # this is a nightmare, but prevents mutating the source directory
+ # which is bind mounted as readonly
+ python setup.py build_ext --build-temp $relative_build_dir \
+ --build-lib $relative_build_dir \
+ build_py --build-lib $relative_build_dir \
+ egg_info --egg-base $relative_build_dir \
+ install_lib --build-dir $relative_build_dir \
+ install --single-version-externally-managed \
+ --record $relative_build_dir/record.txt
popd
diff --git a/dev/docker-compose.yml b/dev/docker-compose.yml
index a11b4015c5..19fda7823a 100644
--- a/dev/docker-compose.yml
+++ b/dev/docker-compose.yml
@@ -31,18 +31,6 @@ services:
volumes:
- ../..:/apache-arrow
- spark_integration:
- build:
- context: spark_integration
- volumes:
- - ../..:/apache-arrow
-
- dask_integration:
- build:
- context: dask_integration
- volumes:
- - ../..:/apache-arrow
-
gen_apidocs:
build:
context: ..
@@ -50,12 +38,6 @@ services:
volumes:
- ..:/arrow
- iwyu:
- build:
- context: iwyu
- volumes:
- - ../..:/apache-arrow
-
run_site:
build:
context: run_site
diff --git a/dev/spark_integration/Dockerfile b/dev/spark_integration/Dockerfile
deleted file mode 100644
index 84e353a9b5..0000000000
--- a/dev/spark_integration/Dockerfile
+++ /dev/null
@@ -1,67 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-FROM maven:3.5.2-jdk-8-slim
-
-# Basic OS utilities
-RUN apt-get update \
- && apt-get install -y \
- wget \
- git \
- pkg-config \
- build-essential \
- software-properties-common \
- && apt-get clean
-
-# install conda in /home/ubuntu/miniconda
-RUN wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O conda.sh \
- && /bin/bash conda.sh -b -p /opt/conda \
- && rm conda.sh
-
-ENV PATH="/opt/conda/bin:${PATH}"
-
-RUN conda create -y -q -c conda-forge -n pyarrow-dev \
- python=2.7 \
- ipython \
- nomkl \
- numpy \
- six \
- setuptools \
- cython \
- pandas \
- pytest \
- cmake \
- flatbuffers \
- rapidjson \
- boost-cpp \
- thrift-cpp \
- snappy \
- zlib \
- gflags \
- brotli \
- lz4-c \
- zstd \
- setuptools \
- setuptools_scm \
- && conda clean --all
-
-ADD . /apache-arrow
-WORKDIR /apache-arrow
-
-CMD arrow/dev/spark_integration/spark_integration.sh
-
-# BUILD: $ docker build -f arrow/dev/spark_integration/Dockerfile -t spark-arrow .
-# RUN: $ docker run -v $HOME/.m2:/root/.m2 spark-arrow
diff --git a/dev/spark_integration/spark_integration.sh b/dev/spark_integration/spark_integration.sh
deleted file mode 100755
index 1f6a273338..0000000000
--- a/dev/spark_integration/spark_integration.sh
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/usr/bin/env bash
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# Exit on any error
-set -e
-
-# Set up environment and working directory
-cd /apache-arrow
-
-# Activate our pyarrow-dev conda env
-conda activate pyarrow-dev
-
-export ARROW_HOME=$(pwd)/arrow
-export ARROW_BUILD_TYPE=release
-export ARROW_BUILD_TOOLCHAIN=$CONDA_PREFIX
-export LD_LIBRARY_PATH=${ARROW_HOME}/lib:${LD_LIBRARY_PATH}
-export MAVEN_OPTS="-Xmx2g -XX:ReservedCodeCacheSize=512m"
-
-# Build Arrow C++
-pushd arrow/cpp
-rm -rf build/*
-mkdir -p build
-cd build/
-cmake -DCMAKE_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=0" -DARROW_PYTHON=on -DARROW_HDFS=on -DCMAKE_BUILD_TYPE=$ARROW_BUILD_TYPE -DCMAKE_INSTALL_PREFIX=$ARROW_HOME ..
-make -j4
-make install
-popd
-
-# Build pyarrow and install inplace
-export PYARROW_CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"
-pushd arrow/python
-python setup.py clean
-python setup.py build_ext --build-type=$ARROW_BUILD_TYPE install
-popd
-
-# Install Arrow to local maven repo and get the version
-pushd arrow/java
-echo "Building and installing Arrow Java"
-mvn -DskipTests -Drat.skip=true clean install
-ARROW_VERSION=`mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | sed -n -e '/^\[.*\]/ !{ /^[0-9]/ { p; q } }'`
-echo "Using Arrow version $ARROW_VERSION"
-popd
-
-# Build Spark with Arrow
-SPARK_REPO=git://git.apache.org/spark.git
-SPARK_BRANCH=master
-
-# Get the Spark repo if not in image already
-if [ ! -d "$(pwd)/spark" ]; then
- export GIT_COMMITTER_NAME="Nobody"
- export GIT_COMMITTER_EMAIL="[email protected]"
- git clone "$SPARK_REPO"
-fi
-
-pushd spark
-
-# Make sure branch has no modifications
-git checkout "$SPARK_BRANCH"
-git reset --hard HEAD
-
-# Update Spark pom with the Arrow version just installed and build Spark, need package phase for pyspark
-sed -i -e "s/\(.*<arrow.version>\).*\(<\/arrow.version>\)/\1$ARROW_VERSION\2/g" ./pom.xml
-echo "Building Spark with Arrow $ARROW_VERSION"
-build/mvn -DskipTests clean package
-
-# Run Arrow related Scala tests only, NOTE: -Dtest=_NonExist_ is to enable surefire test discovery without running any tests so that Scalatest can run
-SPARK_SCALA_TESTS="org.apache.spark.sql.execution.arrow,org.apache.spark.sql.execution.vectorized.ColumnarBatchSuite,org.apache.spark.sql.execution.vectorized.ArrowColumnVectorSuite"
-echo "Testing Spark: $SPARK_SCALA_TESTS"
-# TODO: should be able to only build spark-sql tests with adding "-pl sql/core" but not currently working
-build/mvn -Dtest=none -DwildcardSuites="$SPARK_SCALA_TESTS" test
-
-# Run pyarrow related Python tests only
-SPARK_PYTHON_TESTS="ArrowTests PandasUDFTests ScalarPandasUDFTests GroupedMapPandasUDFTests GroupedAggPandasUDFTests WindowPandasUDFTests"
-echo "Testing PySpark: $SPARK_PYTHON_TESTS"
-SPARK_TESTING=1 bin/pyspark pyspark.sql.tests $SPARK_PYTHON_TESTS
-popd
diff --git a/dev/tasks/tests.yml b/dev/tasks/tests.yml
index efb24ca01a..32131abd9f 100644
--- a/dev/tasks/tests.yml
+++ b/dev/tasks/tests.yml
@@ -38,13 +38,15 @@ groups:
- docker-iwyu
- docker-clang-format
- docker-pandas-master
- - docker-hdfs-integration
- docker-dask-integration
+ - docker-hdfs-integration
+ - docker-spark-integration
integration:
- docker-pandas-master
- docker-dask-integration
- docker-hdfs-integration
+ - docker-spark-integration
cpp-python:
- docker-cpp
@@ -275,6 +277,18 @@ tasks:
- docker-compose build hdfs-integration
- docker-compose run hdfs-integration
+ docker-spark-integration:
+ platform: linux
+ template: docker-tests/travis.linux.yml
+ params:
+ environment:
+ PYTHON_VERSION: 3.6
+ commands:
+ - docker-compose build cpp
+ - docker-compose build python
+ - docker-compose build spark-integration
+ - docker-compose run spark-integration
+
docker-pandas-master:
platform: linux
template: docker-tests/travis.linux.yml
diff --git a/docker-compose.yml b/docker-compose.yml
index b61511ee56..82a0f718d1 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -21,13 +21,19 @@ version: '3.5'
x-ubuntu-volumes:
&ubuntu-volumes
- - .:/arrow:delegated
- - ${ARROW_DOCKER_CACHE_DIR:-./docker_cache}/ubuntu:/build:delegated
+ - .:/arrow:ro # ensures that docker won't contaminate the host directory
+ - ubuntu-cache:/build:delegated
x-alpine-volumes:
&alpine-volumes
- - .:/arrow:delegated
- - ${ARROW_DOCKER_CACHE_DIR:-./docker_cache}/alpine:/build:delegated
+ - .:/arrow:ro # ensures that docker won't contaminate the host directory
+ - alpine-cache:/build:delegated
+
+volumes:
+ ubuntu-cache:
+ alpine-cache:
+ maven-cache:
+ spark-cache:
services:
@@ -105,8 +111,8 @@ services:
context: .
dockerfile: java/Dockerfile
volumes:
- - .:/arrow:delegated
- - $HOME/.m2:/root/.m2:delegated
+ - .:/arrow:ro # ensures that docker won't contaminate the host directory
+ - maven-cache:/root/.m2:delegated
js:
image: arrow:js
@@ -267,7 +273,6 @@ services:
links:
- hdfs-namenode:hdfs-namenode
- # TODO(kszucs): pass hdfs client version explicitly as a build argument
hdfs-integration:
# Usage:
# export PYTHON_VERSION=3.6
@@ -275,6 +280,7 @@ services:
# docker-compose build python
# docker-compose build hdfs-integration
# docker-compose run hdfs-integration
+ image: arrow:hdfs-${HDFS_VERSION:-2.6.5}
links:
- hdfs-namenode:hdfs-namenode
- hdfs-datanode-1:hdfs-datanode-1
@@ -286,6 +292,8 @@ services:
build:
context: .
dockerfile: integration/hdfs/Dockerfile
+ args:
+ HDFS_VERSION: ${HDFS_VERSION:-2.6.5}
volumes: *ubuntu-volumes
# TODO(kszucs): pass dask version explicitly as a build argument
@@ -296,10 +304,29 @@ services:
# docker-compose build python
# docker-compose build dask-integration
# docker-compose run dask-integration
+ image: arrow:dask-integration
build:
context: .
dockerfile: integration/dask/Dockerfile
volumes: *ubuntu-volumes
+ spark-integration:
+ # Usage:
+ # export PYTHON_VERSION=3.6
+ # docker-compose build cpp
+ # docker-compose build python
+ # docker-compose build spark-integration
+ # docker-compose run spark-integration
+ image: arrow:spark-${SPARK_VERSION:-2.4.0}
+ environment:
+ - SPARK_VERSION=${SPARK_VERSION:-2.4.0}
+ build:
+ context: .
+ dockerfile: integration/spark/Dockerfile
+ volumes:
+ - .:/arrow:ro # ensures that docker won't contaminate the host directory
+ - ubuntu-cache:/build:delegated
+ - maven-cache:/root/.m2:delegated
+ - spark-cache:/spark:delegated
+
# TODO(kszucs): hive-integration
- # TODO(kszucs): spark-integration
diff --git a/integration/hdfs/Dockerfile b/integration/hdfs/Dockerfile
index 4fc266f267..4f72e254f0 100644
--- a/integration/hdfs/Dockerfile
+++ b/integration/hdfs/Dockerfile
@@ -32,7 +32,7 @@ RUN apt-get update -y && \
wget -q -O hadoop-$HADOOP_VERSION.tar.gz "https://www.apache.org/dyn/mirrors/mirrors.cgi?action=download&filename=hadoop/common/hadoop-$HADOOP_VERSION/hadoop-$HADOOP_VERSION.tar.gz" && \
tar -zxf /hadoop-$HADOOP_VERSION.tar.gz && \
rm /hadoop-$HADOOP_VERSION.tar.gz && \
- mv hadoop-$HADOOP_VERSION /usr/local/hadoop
+ mv /hadoop-$HADOOP_VERSION /usr/local/hadoop
ADD integration/hdfs/hdfs-site.xml $HADOOP_HOME/etc/hadoop/
# build cpp with tests
diff --git a/integration/hdfs/runtest.sh b/integration/hdfs/runtest.sh
index 2f090c8a81..44afb4a188 100755
--- a/integration/hdfs/runtest.sh
+++ b/integration/hdfs/runtest.sh
@@ -17,6 +17,7 @@
# specific language governing permissions and limitations
# under the License.
+# exit on any error
set -e
export CLASSPATH=`$HADOOP_HOME/bin/hadoop classpath --glob`
diff --git a/integration/spark/2.4.0.patch b/integration/spark/2.4.0.patch
new file mode 100644
index 0000000000..7992e010f6
--- /dev/null
+++ b/integration/spark/2.4.0.patch
@@ -0,0 +1,24 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+diff --git a/pom.xml b/pom.xml
+index f0e5ed9c56..b30d4d61d6 100644
+--- a/pom.xml
++++ b/pom.xml
+@@ -2092,0 +2093,2 @@
++ <arg>-Xmax-classfile-name</arg>
++ <arg>128</arg>
diff --git a/integration/spark/Dockerfile b/integration/spark/Dockerfile
new file mode 100644
index 0000000000..5c28cca0db
--- /dev/null
+++ b/integration/spark/Dockerfile
@@ -0,0 +1,57 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+FROM arrow:python-3.6
+
+# installing java and maven
+ARG MAVEN_VERSION=3.5.4
+ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 \
+ MAVEN_HOME=/usr/local/maven \
+ M2_HOME=/root/.m2 \
+ PATH=/root/.m2/bin:/usr/local/maven/bin:$PATH
+RUN apt-get update -q -y && \
+ apt-get install -q -y openjdk-8-jdk && \
+ wget -q -O maven-$MAVEN_VERSION.tar.gz "https://www.apache.org/dyn/mirrors/mirrors.cgi?action=download&filename=maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz" && \
+ tar -zxf /maven-$MAVEN_VERSION.tar.gz && \
+ rm /maven-$MAVEN_VERSION.tar.gz && \
+ mv /apache-maven-$MAVEN_VERSION /usr/local/maven
+
+# installing specific version of spark
+ARG SPARK_VERSION=2.4.0
+RUN mkdir /spark && \
+ cd /spark && \
+ wget -q -O spark.tar.gz https://github.com/apache/spark/archive/v$SPARK_VERSION.tar.gz && \
+ tar -xzf spark.tar.gz && \
+ rm spark.tar.gz
+
+# patching spark is required in order to:
+# - avoid too long filenames error https://issues.apache.org/jira/browse/SPARK-4820
+ADD integration/spark/$SPARK_VERSION.patch /arrow/integration/spark/$SPARK_VERSION.patch
+RUN cd /spark/spark-$SPARK_VERSION && \
+ patch -p1 < /arrow/integration/spark/$SPARK_VERSION.patch
+
+# build cpp with tests
+ENV CC=gcc \
+ CXX=g++ \
+ ARROW_PYTHON=ON \
+ ARROW_HDFS=ON \
+ ARROW_BUILD_TESTS=OFF
+
+# build and test
+CMD arrow/ci/docker_build_cpp.sh && \
+ arrow/ci/docker_build_python.sh && \
+ arrow/ci/docker_build_java.sh && \
+ arrow/integration/spark/runtest.sh
diff --git a/integration/spark/runtest.sh b/integration/spark/runtest.sh
new file mode 100755
index 0000000000..173f69efb2
--- /dev/null
+++ b/integration/spark/runtest.sh
@@ -0,0 +1,53 @@
+#!/usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# exit on any error
+set -e
+
+SPARK_VERSION=${SPARK_VERSION:-2.4.0}
+
+# rsynced source directory to build java libs
+arrow_src=/build/java/arrow
+
+pushd $arrow_src/java
+ ARROW_VERSION=`mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | sed -n -e '/^\[.*\]/ !{ /^[0-9]/ { p; q } }'`
+popd
+
+MAVEN_OPTS="-Xmx2g -XX:ReservedCodeCacheSize=512m -Dorg.slf4j.simpleLogger.defaultLogLevel=warn"
+
+# build Spark with Arrow
+pushd /spark/spark-${SPARK_VERSION}
+ # update Spark pom with the Arrow version just installed and build Spark, need package phase for pyspark
+ echo "Building Spark with Arrow $ARROW_VERSION"
+ mvn -q versions:set-property -Dproperty=arrow.version -DnewVersion=$ARROW_VERSION
+
+ build/mvn -DskipTests package -pl sql/core -pl assembly -am
+
+ SPARK_SCALA_TESTS=(
+ "org.apache.spark.sql.execution.arrow"
+ "org.apache.spark.sql.execution.vectorized.ColumnarBatchSuite"
+ "org.apache.spark.sql.execution.vectorized.ArrowColumnVectorSuite")
+
+ (echo "Testing Spark:"; IFS=$'\n'; echo "${SPARK_SCALA_TESTS[*]}")
+
+ # TODO: should be able to only build spark-sql tests with adding "-pl sql/core" but not currently working
+ build/mvn -Dtest=none -DwildcardSuites=$(IFS=,; echo "${SPARK_SCALA_TESTS[*]}") test
+
+ # Run pyarrow related Python tests only
+ echo "Testing PySpark:"
+ python/run-tests --modules pyspark-sql
+popd