77# Usage outside of docker:
88# $ tools/test-manylinux.sh
99
10- set -ex
10+ set -e
1111
12- echo " $0 running from $( pwd) "
13-
14- if [[ ! -z $1 ]]; then
15- WHEELHOUSE=$1
12+ if [[ $1 == " --in-docker" ]]; then
13+ IN_DOCKER=1
14+ shift
1615else
17- WHEELHOUSE=" wheelhouse"
16+ IN_DOCKER=0
17+ fi
18+
19+ if [[ -z $1 ]]; then
20+ echo " Usage: $0 <wheel-directory>"
21+ exit 1
1822fi
1923
24+ WHEELHOUSE=" $1 "
25+
26+ if [[ ! -d $WHEELHOUSE ]]; then
27+ echo " Wheelhouse directory $WHEELHOUSE does not exist"
28+ exit 1
29+ fi
30+
31+ echo " $0 running from $( pwd) "
2032
2133
2234function setup_centos {
2335 # CentOS container setup
24- yum install -q -y python epel-release
25- yum install -q -y python-pip
36+ yum install -q -y python python3 epel-release curl
2637}
2738
2839function setup_ubuntu {
2940 # Ubuntu container setup
3041 apt-get update
31- apt-get install -y python python-pip
42+ apt-get install -y python python3 curl
3243}
3344
3445
3546function run_single_in_docker {
3647 # Run single test inside docker container
37- local wheelhouse=/io/$1
48+ local wheelhouse=$1
49+ local testscript=$2
3850
3951 if [[ ! -d $wheelhouse ]]; then
4052 echo " On docker instance: wheelhouse $wheelhouse does not exist"
4153 exit 1
4254 fi
4355
4456 # Detect OS
45- if grep -qi centos /etc/system-release /etc/redhat-release ; then
57+ if grep -qi centos /etc/system-release /etc/redhat-release 2> /dev/null ; then
4658 setup_centos
47- elif grep -qiE ' ubuntu|debian' /etc/os-release ; then
59+ elif grep -qiE ' ubuntu|debian' /etc/os-release 2> /dev/null ; then
4860 setup_ubuntu
4961 else
5062 echo " WARNING: Don't know what platform I'm on: $( uname -a) "
5163 fi
5264
53- # Make sure pip itself is up to date
54- pip install -U pip
55- hash -r # let go of previous 'pip'
56-
57- # Install modules
58-
59- # TODO: revisit to avoid hardcoding dependencies
60- pip install " futures;python_version=='2.7'"
61- pip install " enum34;python_version=='2.7'"
62- pip install requests avro
63-
64- pip install confluent_kafka --no-index -f $wheelhouse
65-
66- # Pytest relies on a new version of six; later versions of pip fail to remove older versions gracefully
67- # https://github.com/pypa/pip/issues/5247
68- pip install pytest --ignore-installed six
69-
70- echo " Verifying OpenSSL and zlib are properly linked"
71- python -c '
72- import confluent_kafka
73-
74- p = confluent_kafka.Producer({"ssl.cipher.suites":"DEFAULT",
75- "compression.codec":"gzip"})
76- '
77-
78- echo " Verifying Interceptor installation"
79- python -c '
80- from confluent_kafka import Consumer
81-
82- c = Consumer({"group.id": "test-linux", "plugin.library.paths": "monitoring-interceptor"})
83- '
84-
85- pushd /io/tests
86- # Remove cached files from previous runs
87- rm -rf __pycache__ * .pyc
88- # Test
89- pytest --import-mode=append --ignore=avro
90- popd
65+ # Don't install pip from distro packaging since it pulls
66+ # in a plethora of possibly outdated Python requirements that
67+ # might interfere with the newer packages from PyPi, such as six.
68+ # Instead install it directly from PyPa.
69+ curl https://bootstrap.pypa.io/get-pip.py | python
9170
71+ /io/tools/smoketest.sh " $wheelhouse "
9272}
9373
9474function run_all_with_docker {
9575 # Run tests in all listed docker containers.
9676 # This is executed on the host.
9777 local wheelhouse=$1
9878
79+ if [[ ! -d ./$wheelhouse ]]; then
80+ echo " $wheelhouse must be a relative subdirectory of $( pwd) "
81+ exit 1
82+ fi
83+
9984 [[ ! -z $DOCKER_IMAGES ]] || \
10085 # LTS and stable release of popular Linux distros.
10186 # We require >= Python 2.7 to be avaialble (which rules out Centos 6.6)
@@ -113,16 +98,17 @@ function run_all_with_docker {
11398
11499 for DOCKER_IMAGE in $DOCKER_IMAGES ; do
115100 echo " # Testing on $DOCKER_IMAGE "
116- docker run -v $( pwd) :/io $DOCKER_IMAGE /io/tools/test-manylinux.sh " $wheelhouse " || \
101+ docker run -v $( pwd) :/io $DOCKER_IMAGE /io/tools/test-manylinux.sh --in-docker " /io/ $wheelhouse " || \
117102 (echo " Failed on $DOCKER_IMAGE " ; false)
118103
119104 done
120105}
121106
122107
123108
124- if [[ -f /.dockerenv && -d /io ]]; then
109+ if [[ $IN_DOCKER == 1 ]]; then
125110 # Called from within a docker container
111+ cd /io # Enter the confluent-kafka-python top level directory
126112 run_single_in_docker $WHEELHOUSE
127113
128114else
0 commit comments