|
| 1 | +#!/bin/bash -e |
| 2 | +# |
| 3 | +# Test Snowflake Connector in Rocky Linux 9 |
| 4 | +# NOTES: |
| 5 | +# - Versions to be tested should be passed in as the first argument, e.g: "3.9 3.11". If omitted 3.9-3.13 will be assumed. |
| 6 | +# - This script assumes that ../dist has the wheel(s) built for all versions to be tested |
| 7 | +# - This is the script that test_rockylinux9_docker.sh runs inside of the docker container |
| 8 | + |
| 9 | + |
| 10 | +PYTHON_VERSIONS="${1:-3.9 3.11 3.12}" |
| 11 | +THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 12 | +CONNECTOR_DIR="$( dirname "${THIS_DIR}")" |
| 13 | + |
| 14 | +# Get first available Python version for initial setup |
| 15 | +SETUP_PYTHON_VERSION=$(echo ${PYTHON_VERSIONS} | awk '{print $1}') |
| 16 | +echo "[Info] Using Python ${SETUP_PYTHON_VERSION} for initial setup" |
| 17 | + |
| 18 | +# Install one copy of tox using the first available Python version |
| 19 | +python${SETUP_PYTHON_VERSION} -m pip install -U tox>=4 |
| 20 | + |
| 21 | +source ${THIS_DIR}/log_analyze_setup.sh |
| 22 | + |
| 23 | +if [[ -d ${CLIENT_LOG_DIR_PATH_DOCKER} ]]; then |
| 24 | + rm -rf ${CLIENT_LOG_DIR_PATH_DOCKER}/* |
| 25 | +else |
| 26 | + mkdir ${CLIENT_LOG_DIR_PATH_DOCKER} |
| 27 | +fi |
| 28 | + |
| 29 | +# Replace test password with a more complex one, and generate known ssm file |
| 30 | +# This is only needed for Jenkins, not GitHub Actions |
| 31 | +if [[ "$GITHUB_ACTIONS" != "true" ]]; then |
| 32 | + python${SETUP_PYTHON_VERSION} -m pip install -U snowflake-connector-python --only-binary=cffi >& /dev/null |
| 33 | + python${SETUP_PYTHON_VERSION} ${THIS_DIR}/change_snowflake_test_pwd.py |
| 34 | + mv ${CONNECTOR_DIR}/test/parameters_jenkins.py ${CONNECTOR_DIR}/test/parameters.py |
| 35 | +else |
| 36 | + echo "[Info] Running in GitHub Actions, skipping password change step" |
| 37 | + echo "[Info] Checking if test/parameters.py exists:" |
| 38 | + ls -la ${CONNECTOR_DIR}/test/parameters.py || echo "[ERROR] parameters.py NOT FOUND!" |
| 39 | + echo "[Info] Checking if RSA key file exists:" |
| 40 | + ls -la ${CONNECTOR_DIR}/test/rsa_key_python_*.p8 || echo "[ERROR] RSA key NOT FOUND!" |
| 41 | +fi |
| 42 | + |
| 43 | +# Fetch wiremock |
| 44 | +curl https://repo1.maven.org/maven2/org/wiremock/wiremock-standalone/3.11.0/wiremock-standalone-3.11.0.jar --output ${CONNECTOR_DIR}/.wiremock/wiremock-standalone.jar |
| 45 | + |
| 46 | +# Run tests |
| 47 | +cd $CONNECTOR_DIR |
| 48 | +if [[ "$is_old_driver" == "true" ]]; then |
| 49 | + # Old Driver Test |
| 50 | + echo "[Info] Running old connector tests" |
| 51 | + python${SETUP_PYTHON_VERSION} -m tox -e olddriver |
| 52 | +else |
| 53 | + for PYTHON_VERSION in ${PYTHON_VERSIONS}; do |
| 54 | + echo "[Info] Testing with Python ${PYTHON_VERSION}" |
| 55 | + |
| 56 | + # Check if the Python version is installed |
| 57 | + if ! command -v python${PYTHON_VERSION} &> /dev/null; then |
| 58 | + echo "[Warning] Python ${PYTHON_VERSION} not found, skipping..." |
| 59 | + continue |
| 60 | + fi |
| 61 | + |
| 62 | + SHORT_VERSION=$(python${PYTHON_VERSION} -c "print('${PYTHON_VERSION}'.replace('.', ''))") |
| 63 | + |
| 64 | + # Look for manylinux wheels (Rocky Linux 9 should be compatible with manylinux wheels) |
| 65 | + CONNECTOR_WHL=$(ls $CONNECTOR_DIR/dist/snowflake_connector_python*cp${SHORT_VERSION}*manylinux*.whl 2>/dev/null | sort -r | head -n 1) |
| 66 | + |
| 67 | + if [[ -z "$CONNECTOR_WHL" ]]; then |
| 68 | + echo "[Warning] No manylinux wheel found for Python ${PYTHON_VERSION}, skipping..." |
| 69 | + continue |
| 70 | + fi |
| 71 | + |
| 72 | + TEST_LIST=`echo py${PYTHON_VERSION/\./}-{extras,unit-parallel,integ-parallel,pandas-parallel,sso}-ci | sed 's/ /,/g'` |
| 73 | + TEST_ENVLIST=fix_lint,$TEST_LIST,py${PYTHON_VERSION/\./}-coverage |
| 74 | + echo "[Info] Running tox for ${TEST_ENVLIST}" |
| 75 | + |
| 76 | + python${PYTHON_VERSION} -m tox run -e ${TEST_ENVLIST} --installpkg ${CONNECTOR_WHL} |
| 77 | + done |
| 78 | +fi |
0 commit comments