Skip to content

Commit f1ea979

Browse files
SNOW-1834269: Add rockylinux9 jobs to Github Actions checks (RHEL9 support) (#2575)
Co-authored-by: Patryk Cyrek <[email protected]>
1 parent 1b63402 commit f1ea979

File tree

7 files changed

+236
-8
lines changed

7 files changed

+236
-8
lines changed

.github/workflows/build_test.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,56 @@ jobs:
446446
path: |
447447
junit.py${{ env.shortver }}-lambda-ci-dev.xml
448448
449+
test-rockylinux9:
450+
name: Test Rocky Linux 9 rockylinux9-${{ matrix.python-version }}-${{ matrix.cloud-provider }}
451+
needs: lint
452+
runs-on: ubuntu-latest
453+
strategy:
454+
fail-fast: false
455+
matrix:
456+
# Rocky Linux 9 has Python 3.9, 3.11, and 3.12 available
457+
python-version: ["3.9", "3.11", "3.12"]
458+
cloud-provider: [aws, azure, gcp]
459+
steps:
460+
- name: Set shortver
461+
run: echo "shortver=${longver//./}" >> $GITHUB_ENV
462+
env:
463+
longver: ${{ matrix.python-version }}
464+
shell: bash
465+
- uses: actions/checkout@v4
466+
- name: Build wheel for Rocky Linux
467+
uses: pypa/[email protected]
468+
env:
469+
CIBW_BUILD: cp${{ env.shortver }}-manylinux_x86_64
470+
MACOSX_DEPLOYMENT_TARGET: 10.14
471+
with:
472+
output-dir: dist
473+
- name: Show wheels built
474+
run: ls -lh dist
475+
shell: bash
476+
- name: Setup parameters file
477+
shell: bash
478+
env:
479+
PARAMETERS_SECRET: ${{ secrets.PARAMETERS_SECRET }}
480+
run: |
481+
gpg --quiet --batch --yes --decrypt --passphrase="$PARAMETERS_SECRET" \
482+
.github/workflows/parameters/public/parameters_${{ matrix.cloud-provider }}.py.gpg > test/parameters.py
483+
- name: Setup private key file
484+
shell: bash
485+
env:
486+
PARAMETERS_SECRET: ${{ secrets.PARAMETERS_SECRET }}
487+
run: |
488+
gpg --quiet --batch --yes --decrypt --passphrase="$PARAMETERS_SECRET" \
489+
.github/workflows/parameters/public/rsa_keys/rsa_key_python_${{ matrix.cloud-provider }}.p8.gpg > test/rsa_key_python_${{ matrix.cloud-provider }}.p8
490+
- name: Run tests
491+
run: ./ci/test_rockylinux9_docker.sh ${PYTHON_VERSION}
492+
env:
493+
PYTHON_VERSION: ${{ matrix.python-version }}
494+
cloud_provider: ${{ matrix.cloud-provider }}
495+
PYTEST_ADDOPTS: --color=yes --tb=short
496+
TOX_PARALLEL_NO_SPINNER: 1
497+
shell: bash
498+
449499
combine-coverage:
450500
if: always()
451501
name: Combine coverage
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
ARG BASE_IMAGE=rockylinux:9
2+
FROM $BASE_IMAGE
3+
4+
# Install required packages for testing
5+
RUN dnf install -y --allowerasing \
6+
gcc \
7+
gcc-c++ \
8+
make \
9+
openssl \
10+
openssl-devel \
11+
libffi-devel \
12+
redhat-rpm-config \
13+
java-11-openjdk \
14+
python3.9 \
15+
python3.9-devel \
16+
python3.11 \
17+
python3.11-devel \
18+
python3.12 \
19+
python3.12-devel \
20+
git \
21+
curl \
22+
&& dnf clean all
23+
24+
# Bootstrap pip for Python 3.11 and 3.12 (Python 3.9 already has pip)
25+
RUN python3.11 -m ensurepip --upgrade && \
26+
python3.11 -m pip install --upgrade pip setuptools wheel
27+
RUN python3.12 -m ensurepip --upgrade && \
28+
python3.12 -m pip install --upgrade pip setuptools wheel
29+
30+
# Install Rust toolchain (required for cryptography builds)
31+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
32+
ENV PATH="/root/.cargo/bin:${PATH}"
33+
34+
# This is to solve permission issue, read https://denibertovic.com/posts/handling-permissions-with-docker-volumes/
35+
ARG GOSU_URL=https://github.com/tianon/gosu/releases/download/1.14/gosu-amd64
36+
ENV GOSU_PATH=${GOSU_URL}
37+
RUN curl -o /usr/local/bin/gosu -SL $GOSU_PATH
38+
RUN chmod +x /usr/local/bin/gosu
39+
40+
COPY scripts/entrypoint.sh /usr/local/bin/entrypoint.sh
41+
RUN chmod +x /usr/local/bin/entrypoint.sh
42+
43+
WORKDIR /home/user
44+
RUN chmod 777 /home/user
45+
46+
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
# Add local user
4+
# Either use the LOCAL_USER_ID if passed in at runtime or
5+
# fallback
6+
7+
USER_ID=${LOCAL_USER_ID:-9001}
8+
9+
echo "Starting with UID : $USER_ID"
10+
useradd --shell /bin/bash -u $USER_ID -o -c "" -m user
11+
export HOME=/home/user
12+
13+
/usr/local/bin/gosu user "$@"

ci/set_base_image.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ if [[ -n "$NEXUS_PASSWORD" ]]; then
1010
docker login --username "$NEXUS_USER" --password "$NEXUS_PASSWORD" $INTERNAL_REPO
1111
export BASE_IMAGE_MANYLINUX2014=nexus.int.snowflakecomputing.com:8086/docker/manylinux2014_x86_64:2025.02.12-1
1212
export BASE_IMAGE_MANYLINUX2014AARCH64=nexus.int.snowflakecomputing.com:8086/docker/manylinux2014_aarch64:2025.02.12-1
13+
export BASE_IMAGE_ROCKYLINUX9=nexus.int.snowflakecomputing.com:8086/docker/rockylinux:9
1314
else
1415
echo "[INFO] Pull docker images from public registry"
1516
export BASE_IMAGE_MANYLINUX2014=quay.io/pypa/manylinux2014_x86_64
1617
export BASE_IMAGE_MANYLINUX2014AARCH64=quay.io/pypa/manylinux2014_aarch64
18+
export BASE_IMAGE_ROCKYLINUX9=rockylinux:9
1719
fi

ci/test_rockylinux9.sh

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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

ci/test_rockylinux9_docker.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash -e
2+
# Test Snowflake Python Connector in Rocky Linux 9 Docker
3+
# NOTES:
4+
# - By default this script runs Python 3.9 tests, as these are installed in dev vms
5+
# - To compile only a specific version(s) pass in versions like: `./test_rockylinux9_docker.sh "3.9 3.11"`
6+
7+
set -o pipefail
8+
9+
# In case this is ran from dev-vm
10+
PYTHON_ENV=${1:-3.9}
11+
12+
# Set constants
13+
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
14+
CONNECTOR_DIR="$( dirname "${THIS_DIR}")"
15+
WORKSPACE=${WORKSPACE:-${CONNECTOR_DIR}}
16+
source $THIS_DIR/set_base_image.sh
17+
18+
cd $THIS_DIR/docker/connector_test_rockylinux9
19+
20+
CONTAINER_NAME=test_pyconnector_rockylinux9
21+
22+
echo "[Info] Building docker image for Rocky Linux 9"
23+
BASE_IMAGE=${BASE_IMAGE_ROCKYLINUX9:-rockylinux:9}
24+
GOSU_URL=https://github.com/tianon/gosu/releases/download/1.14/gosu-amd64
25+
26+
docker build --pull -t ${CONTAINER_NAME}:1.0 --build-arg BASE_IMAGE=$BASE_IMAGE --build-arg GOSU_URL="$GOSU_URL" . -f Dockerfile
27+
28+
user_id=$(id -u ${USER})
29+
docker run --network=host \
30+
-e TERM=vt102 \
31+
-e PIP_DISABLE_PIP_VERSION_CHECK=1 \
32+
-e LOCAL_USER_ID=${user_id} \
33+
-e AWS_ACCESS_KEY_ID \
34+
-e AWS_SECRET_ACCESS_KEY \
35+
-e SF_REGRESS_LOGS \
36+
-e SF_PROJECT_ROOT \
37+
-e cloud_provider \
38+
-e JENKINS_HOME \
39+
-e is_old_driver \
40+
-e GITHUB_ACTIONS \
41+
-e USE_PASSWORD \
42+
--mount type=bind,source="${CONNECTOR_DIR}",target=/home/user/snowflake-connector-python \
43+
${CONTAINER_NAME}:1.0 \
44+
/home/user/snowflake-connector-python/ci/test_rockylinux9.sh ${PYTHON_ENV}

test/integ/sso_it/test_unit_mfa_cache.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,7 @@ def test_body(conn_cfg):
163163
if IS_LINUX:
164164
conn_cfg["client_request_mfa_token"] = True
165165

166-
if IS_MACOS or IS_WINDOWS:
167-
with patch(
168-
"keyring.delete_password", Mock(side_effect=mock_del_password)
169-
), patch("keyring.set_password", Mock(side_effect=mock_set_password)), patch(
170-
"keyring.get_password", Mock(side_effect=mock_get_password)
171-
):
172-
test_body(conn_cfg)
173-
else:
166+
with patch("keyring.delete_password", Mock(side_effect=mock_del_password)), patch(
167+
"keyring.set_password", Mock(side_effect=mock_set_password)
168+
), patch("keyring.get_password", Mock(side_effect=mock_get_password)):
174169
test_body(conn_cfg)

0 commit comments

Comments
 (0)