File: test-manylinux.sh

package info (click to toggle)
python-confluent-kafka 1.7.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,904 kB
  • sloc: python: 8,335; ansic: 6,065; sh: 1,203; makefile: 178
file content (123 lines) | stat: -rwxr-xr-x 3,129 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/bash
#
#
# Tests the manylinux wheels on a plethora of bare-bone Linux docker images.
# To override docker images to test, set env DOCKER_IMAGES.
#
# Usage outside of docker:
#  $ tools/test-manylinux.sh

set -e

if [[ $1 == "--in-docker" ]]; then
    IN_DOCKER=1
    shift
else
    IN_DOCKER=0
fi

if [[ -z $1 ]]; then
    echo "Usage: $0 <wheel-directory>"
    exit 1
fi

WHEELHOUSE="$1"

if [[ ! -d $WHEELHOUSE ]]; then
    echo "Wheelhouse directory $WHEELHOUSE does not exist"
    exit 1
fi

echo "$0 running from $(pwd)"


function setup_centos {
    # CentOS container setup
    yum install -q -y python python3 epel-release curl
}

function setup_ubuntu {
    # Ubuntu container setup
    apt-get update
    apt-get install -y python python3 curl
    # python3-distutils is required on Ubuntu 18.04 and later but does
    # not exist on 14.04.
    apt-get install -y python3-distutils || true
}


function run_single_in_docker {
    # Run single test inside docker container
    local wheelhouse=$1
    local testscript=$2

    if [[ ! -d $wheelhouse ]]; then
        echo "On docker instance: wheelhouse $wheelhouse does not exist"
        exit 1
    fi

    # Detect OS
    if grep -qi centos /etc/system-release /etc/redhat-release 2>/dev/null ; then
        setup_centos
    elif grep -qiE 'ubuntu|debian' /etc/os-release 2>/dev/null ; then
        setup_ubuntu
    else
        echo "WARNING: Don't know what platform I'm on: $(uname -a)"
    fi

    # Don't install pip from distro packaging since it pulls
    # in a plethora of possibly outdated Python requirements that
    # might interfere with the newer packages from PyPi, such as six.
    # Instead install it directly from PyPa.
    curl https://bootstrap.pypa.io/get-pip.py | python

    /io/tools/smoketest.sh "$wheelhouse"
}

function run_all_with_docker {
    # Run tests in all listed docker containers.
    # This is executed on the host.
    local wheelhouse=$1

    if [[ ! -d ./$wheelhouse ]]; then
        echo "$wheelhouse must be a relative subdirectory of $(pwd)"
        exit 1
    fi

    [[ ! -z $DOCKER_IMAGES ]] || \
        # LTS and stable release of popular Linux distros.
        # We require >= Python 2.7 to be available (which rules out Centos 6.6)
        DOCKER_IMAGES="ubuntu:14.04 ubuntu:16.04 ubuntu:18.04 ubuntu:20.04 centos:7 centos:8"


    _wheels="$wheelhouse/*manylinux*.whl"
    if [[ -z $_wheels ]]; then
        echo "No wheels in $wheelhouse, must run build-manylinux.sh first"
        exit 1
    else
        echo "Wheels:"
        ls $wheelhouse/*.whl
    fi

    for DOCKER_IMAGE in $DOCKER_IMAGES; do
        echo "# Testing on $DOCKER_IMAGE"
        docker run -v $(pwd):/io $DOCKER_IMAGE /io/tools/test-manylinux.sh --in-docker "/io/$wheelhouse" || \
            (echo "Failed on $DOCKER_IMAGE" ; false)

    done
}



if [[ $IN_DOCKER == 1 ]]; then
    # Called from within a docker container
    cd /io  # Enter the confluent-kafka-python top level directory
    run_single_in_docker $WHEELHOUSE

else
    # Run from host, trigger runs for all docker images.

    run_all_with_docker $WHEELHOUSE
fi