Apache DataFusion SQL Query Engine
ARROW-2300: [C++/Python] Integration test for HDFS
Krisztián Szűcs3f3fcf91d231
diff --git a/dev/README.md b/dev/README.mdindex 62ffb0a8f1..971fb5f1dd 100644--- a/dev/README.md+++ b/dev/README.md@@ -120,4 +120,11 @@ For JavaScript-specific releases, use a different verification script:```shellbash dev/release/js-verify-release-candidate.sh 0.7.0 0-```\ No newline at end of file+```+# Integration testing++## HDFS C++ / Python support++```shell+run_docker_compose.sh hdfs_integration+```diff --git a/dev/docker-compose.yml b/dev/docker-compose.ymlindex b1e593cf48..c4500986ca 100644--- a/dev/docker-compose.yml+++ b/dev/docker-compose.yml@@ -16,25 +16,61 @@version: '3'services:- gen_apidocs:++ hdfs-namenode:+ image: gelog/hadoop+ shm_size: 2G+ ports:+ - "9000:9000"+ - "50070:50070"+ command: hdfs namenode+ hostname: hdfs-namenode++ hdfs-datanode:+ image: gelog/hadoop+ command: hdfs datanode+ ports:+ # The host port is randomly assigned by Docker, to allow scaling+ # to multiple DataNodes on the same host+ - "50075"+ links:+ - hdfs-namenode:hdfs-namenode++ hdfs_integration:+ links:+ - hdfs-namenode:hdfs-namenode+ - hdfs-datanode:hdfs-datanode+ environment:+ - ARROW_HDFS_TEST_HOST=hdfs-namenode+ - ARROW_HDFS_TEST_PORT=9000+ - ARROW_HDFS_TEST_USER=rootbuild:- context: gen_apidocs+ context: hdfs_integrationvolumes:- ../..:/apache-arrow- run_site:++ spark_integration:build:- context: run_site- ports:- - "4000:4000"+ context: spark_integrationvolumes:- - ../..:/apache-arrow+ - ../..:/apache-arrow+dask_integration:build:context: dask_integrationvolumes:- - ../..:/apache-arrow- spark_integration:- build:- context: spark_integration+ - ../..:/apache-arrow++ gen_apidocs:+ build:+ context: gen_apidocsvolumes:- ../..:/apache-arrow++ run_site:+ build:+ context: run_site+ ports:+ - "4000:4000"+ volumes:+ - ../..:/apache-arrowdiff --git a/dev/hdfs_integration/Dockerfile b/dev/hdfs_integration/Dockerfilenew file mode 100644index 0000000000..71dcbe3aa2--- /dev/null+++ b/dev/hdfs_integration/Dockerfile@@ -0,0 +1,75 @@+#+# 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 gelog/hadoop++ENV CC=gcc \+ CXX=g++ \+ PATH=/opt/conda/bin:$PATH++RUN apt-get update -y \+ && apt-get install -y \+ gcc \+ g++ \+ git \+ wget \+ pkg-config \+ ninja-build++# Miniconda - Python 3.6, 64-bit, x86, latest+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++# create conda env with the required dependences+RUN conda create -y -q -c conda-forge -n pyarrow-dev \+ python=3.6 \+ nomkl \+ numpy \+ six \+ setuptools \+ cython \+ pandas \+ pytest \+ cmake \+ flatbuffers \+ rapidjson \+ boost-cpp \+ thrift-cpp \+ snappy \+ zlib \+ gflags \+ brotli \+ jemalloc \+ lz4-c \+ zstd \+ && conda clean --all++# installing in the previous step boost=1.60 and boost-cpp=1.67 gets installed,+# cmake finds 1.60 and parquet fails to compile+# installing it in a separate step, boost=1.60 and boost-cpp=1.64 gets+# installed, cmake finds 1.64+# libhdfs3 needs to be pinned,see ARROW-1465 and ARROW-1445+RUN conda install -y -q -n pyarrow-dev -c conda-forge \+ hdfs3 \+ libhdfs3=2.2.31 \+ && conda clean --all++ADD . /apache-arrow+WORKDIR /apache-arrow++CMD arrow/dev/hdfs_integration/hdfs_integration.shdiff --git a/dev/hdfs_integration/hdfs_integration.sh b/dev/hdfs_integration/hdfs_integration.shnew file mode 100755index 0000000000..c67f18d28a--- /dev/null+++ b/dev/hdfs_integration/hdfs_integration.sh@@ -0,0 +1,101 @@+#!/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++# cwd is mounted from host machine to+# and contains both arrow and parquet-cpp++# Activate conda environment+source activate pyarrow-dev++# Arrow build variables+export ARROW_BUILD_TYPE=debug+export ARROW_BUILD_TOOLCHAIN=$CONDA_PREFIX+export PARQUET_BUILD_TOOLCHAIN=$CONDA_PREFIX+export ARROW_HOME=$CONDA_PREFIX+export PARQUET_HOME=$CONDA_PREFIX++# Hadoop variables+export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HADOOP_HOME/lib/native/+export CLASSPATH=`$HADOOP_HOME/bin/hadoop classpath --glob`++# For newer GCC per https://arrow.apache.org/docs/python/development.html#known-issues+export CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"+export PYARROW_CXXFLAGS=$CXXFLAGS+export PYARROW_CMAKE_GENERATOR=Ninja++# Install arrow-cpp+mkdir -p arrow/cpp/hdfs-integration-build+pushd arrow/cpp/hdfs-integration-build++cmake -GNinja \+ -DCMAKE_BUILD_TYPE=$ARROW_BUILD_TYPE \+ -DCMAKE_INSTALL_PREFIX=$ARROW_HOME \+ -DARROW_PYTHON=ON \+ -DARROW_PLASMA=ON \+ -DARROW_HDFS=ON \+ -DARROW_BUILD_TESTS=ON \+ -DCMAKE_CXX_FLAGS=$CXXFLAGS \+ ..+ninja+ninja install++popd++# Install parquet-cpp+mkdir -p parquet-cpp/hdfs-integration-build+pushd parquet-cpp/hdfs-integration-build++cmake -GNinja \+ -DCMAKE_BUILD_TYPE=$ARROW_BUILD_TYPE \+ -DCMAKE_INSTALL_PREFIX=$PARQUET_HOME \+ -DPARQUET_BUILD_BENCHMARKS=OFF \+ -DPARQUET_BUILD_EXECUTABLES=OFF \+ -DPARQUET_BUILD_TESTS=ON \+ -DCMAKE_CXX_FLAGS=$CXXFLAGS \+ ..+ninja+ninja install++popd++# Install pyarrow+pushd arrow/python++# Clear the build directory so we are guaranteed a fresh set of extensions+rm -rf build/++python setup.py build_ext \+ --build-type=$ARROW_BUILD_TYPE \+ --with-parquet \+ --with-plasma \+ --inplace++popd++# Run tests+export LIBHDFS3_CONF=arrow/dev/hdfs_integration/libhdfs3-client-config.xml++# Python+python -m pytest -vv -r sxX -s arrow/python/pyarrow \+ --only-parquet --only-hdfs++# C+++arrow/cpp/hdfs-integration-build/debug/io-hdfs-testdiff --git a/dev/hdfs_integration/libhdfs3-client-config.xml b/dev/hdfs_integration/libhdfs3-client-config.xmlnew file mode 100644index 0000000000..f929929b38--- /dev/null+++ b/dev/hdfs_integration/libhdfs3-client-config.xml@@ -0,0 +1,332 @@+<?xml version="1.0" encoding="UTF-8"?>++<!--+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 Apache HAWQ (incubating) -->++<configuration>++<!-- KDC+ <property>+ <name>hadoop.security.authentication</name>+ <value>kerberos</value>+ </property>+KDC -->++<!-- HA+ <property>+ <name>dfs.nameservices</name>+ <value>phdcluster</value>+ </property>++ <property>+ <name>dfs.ha.namenodes.phdcluster</name>+ <value>nn1,nn2</value>+ </property>6++ <property>+ <name>dfs.namenode.rpc-address.phdcluster.nn1</name>+ <value>mdw:9000</value>+ </property>++ <property>+ <name>dfs.namenode.rpc-address.phdcluster.nn2</name>+ <value>smdw:9000</value>+ </property>++ <property>+ <name>dfs.namenode.http-address.phdcluster.nn1</name>+ <value>mdw:50070</value>+ </property>++ <property>+ <name>dfs.namenode.http-address.phdcluster.nn2</name>+ <value>smdw:50070</value>+ </property>++HA -->++ <!-- RPC client configuration -->+ <property>+ <name>rpc.client.timeout</name>+ <value>3600000</value>+ <description>+ timeout interval of a RPC invocation in millisecond. default is 3600000.+ </description>+ </property>+ <property>+ <name>rpc.client.connect.tcpnodelay</name>+ <value>true</value>+ <description>+ whether set socket TCP_NODELAY to true when connect to RPC server. default is true.+ </description>+ </property>++ <property>+ <name>rpc.client.max.idle</name>+ <value>10000</value>+ <description>+ the max idle time of a RPC connection in millisecond. default is 10000.+ </description>+ </property>++ <property>+ <name>rpc.client.ping.interval</name>+ <value>10000</value>+ <description>+ the interval which the RPC client send a heart beat to server. 0 means disable, default is 10000.+ </description>+ </property>++ <property>+ <name>rpc.client.connect.timeout</name>+ <value>600000</value>+ <description>+ the timeout interval in millisecond when the RPC client is trying to setup the connection. default is 600000.+ </description>+ </property>++ <property>+ <name>rpc.client.connect.retry</name>+ <value>10</value>+ <description>+ the max retry times if the RPC client fail to setup the connection to server. default is 10.+ </description>+ </property>++ <property>+ <name>rpc.client.read.timeout</name>+ <value>3600000</value>+ <description>+ the timeout interval in millisecond when the RPC client is trying to read from server. default is 3600000.+ </description>+ </property>++ <property>+ <name>rpc.client.write.timeout</name>+ <value>3600000</value>+ <description>+ the timeout interval in millisecond when the RPC client is trying to write to server. default is 3600000.+ </description>+ </property>++ <property>+ <name>rpc.client.socket.linger.timeout</name>+ <value>-1</value>+ <description>+ set value to socket SO_LINGER when connect to RPC server. -1 means default OS value. default is -1.+ </description>+ </property>++ <!-- dfs client configuration -->+ <property>+ <name>dfs.client.read.shortcircuit</name>+ <value>false</value>+ <description>+ whether reading block file bypass datanode if the block and the client are on the same node. default is true.+ </description>+ </property>++ <property>+ <name>dfs.default.replica</name>+ <value>1</value>+ <description>+ the default number of replica. default is 3.+ </description>+ </property>++ <property>+ <name>dfs.prefetchsize</name>+ <value>10</value>+ <description>+ the default number of blocks which information will be prefetched. default is 10.+ </description>+ </property>++ <property>+ <name>dfs.client.failover.max.attempts</name>+ <value>15</value>+ <description>+ if multiply namenodes are configured, it is the max retry times when the dfs client try to issue a RPC call. default is 15.+ </description>+ </property>++ <property>+ <name>dfs.default.blocksize</name>+ <value>134217728</value>+ <description>+ default block size. default is 134217728.+ </description>+ </property>++ <property>+ <name>dfs.client.log.severity</name>+ <value>INFO</value>+ <description>+ the minimal log severity level, valid values include FATAL, ERROR, INFO, DEBUG1, DEBUG2, DEBUG3. default is INFO.+ </description>+ </property>++ <!-- input client configuration -->+ <property>+ <name>input.connect.timeout</name>+ <value>600000</value>+ <description>+ the timeout interval in millisecond when the input stream is trying to setup the connection to datanode. default is 600000.+ </description>+ </property>++ <property>+ <name>input.read.timeout</name>+ <value>3600000</value>+ <description>+ the timeout interval in millisecond when the input stream is trying to read from datanode. default is 3600000.+ </description>+ </property>++ <property>+ <name>input.write.timeout</name>+ <value>3600000</value>+ <description>+ the timeout interval in millisecond when the input stream is trying to write to datanode. default is 3600000.+ </description>+ </property>++ <property>+ <name>input.localread.default.buffersize</name>+ <value>2097152</value>+ <description>+ number of bytes of the buffer which is used to hold the data from block file and verify checksum.+ it is only used when "dfs.client.read.shortcircuit" is set to true. default is 1048576.+ </description>+ </property>++ <property>+ <name>input.localread.blockinfo.cachesize</name>+ <value>1000</value>+ <description>+ the size of block file path information cache. default is 1000.+ </description>+ </property>++ <property>+ <name>input.read.getblockinfo.retry</name>+ <value>3</value>+ <description>+ the max retry times when the client fail to get block information from namenode. default is 3.+ </description>+ </property>++ <!-- output client configuration -->+ <property>+ <name>output.replace-datanode-on-failure</name>+ <value>false</value>+ <description>+ whether the client add new datanode into pipeline if the number of nodes in pipeline is less the specified number of replicas. default is false.+ </description>+ </property>++ <property>+ <name>output.default.chunksize</name>+ <value>512</value>+ <description>+ the number of bytes of a chunk in pipeline. default is 512.+ </description>+ </property>++ <property>+ <name>output.default.packetsize</name>+ <value>65536</value>+ <description>+ the number of bytes of a packet in pipeline. default is 65536.+ </description>+ </property>++ <property>+ <name>output.default.write.retry</name>+ <value>10</value>+ <description>+ the max retry times when the client fail to setup the pipeline. default is 10.+ </description>+ </property>++ <property>+ <name>output.connect.timeout</name>+ <value>600000</value>+ <description>+ the timeout interval in millisecond when the output stream is trying to setup the connection to datanode. default is 600000.+ </description>+ </property>++ <property>+ <name>output.read.timeout</name>+ <value>3600000</value>+ <description>+ the timeout interval in millisecond when the output stream is trying to read from datanode. default is 3600000.+ </description>+ </property>++ <property>+ <name>output.write.timeout</name>+ <value>3600000</value>+ <description>+ the timeout interval in millisecond when the output stream is trying to write to datanode. default is 3600000.+ </description>+ </property>++ <property>+ <name>output.packetpool.size</name>+ <value>1024</value>+ <description>+ the max number of packets in a file's packet pool. default is 1024.+ </description>+ </property>++ <property>+ <name>output.close.timeout</name>+ <value>900000</value>+ <description>+ the timeout interval in millisecond when close an output stream. default is 900000.+ </description>+ </property>++ <property>+ <name>dfs.domain.socket.path</name>+ <value>/var/lib/hadoop-hdfs/dn_socket</value>+ <description>+ Optional. This is a path to a UNIX domain socket that will be used for+ communication between the DataNode and local HDFS clients.+ If the string "_PORT" is present in this path, it will be replaced by the+ TCP port of the DataNode.+ </description>+ </property>++ <property>+ <name>dfs.client.use.legacy.blockreader.local</name>+ <value>false</value>+ <description>+ Legacy short-circuit reader implementation based on HDFS-2246 is used+ if this configuration parameter is true.+ This is for the platforms other than Linux+ where the new implementation based on HDFS-347 is not available.+ </description>+ </property>++</configuration>diff --git a/dev/spark_integration/spark_integration.sh b/dev/spark_integration/spark_integration.shindex 8ca4dc3ac9..6c0a3f0bb5 100755--- a/dev/spark_integration/spark_integration.sh+++ b/dev/spark_integration/spark_integration.sh@@ -87,6 +87,5 @@ build/mvn -Dtest=none -DwildcardSuites="$SPARK_SCALA_TESTS" test# Run pyarrow related Python tests onlySPARK_PYTHON_TESTS="ArrowTests PandasUDFTests ScalarPandasUDFTests GroupedMapPandasUDFTests GroupedAggPandasUDFTests"echo "Testing PySpark: $SPARK_PYTHON_TESTS"-SPARK_TESTING=1 bin/pyspark pyspark.sql.tests $SPARK_PYTHON_TESTS+SPARK_TESTING=1 bin/pyspark pyspark.sql.tests $SPARK_PYTHON_TESTSpopd-