Skip to content

Commit 9fec64a

Browse files
SNOW-2208210 RHEL9 compatibility tests (#1304)
1 parent 3117bed commit 9fec64a

4 files changed

Lines changed: 218 additions & 2 deletions

File tree

.github/workflows/main.yml

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: DotNet Build and Test
22

3+
permissions:
4+
contents: read
5+
36
# Triggers the workflow on push or pull request events but only for the master branch
47
on:
58
push:
@@ -237,7 +240,7 @@ jobs:
237240
- name: Run Tests
238241
run: |
239242
cd Snowflake.Data.Tests
240-
dotnet-coverage collect "dotnet test --framework ${{ matrix.dotnet }} --no-build --logger junit;LogFilePath=windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_results.junit.xml --verbosity normal" --output macos_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_coverage.xml --output-format cobertura --settings coverage.config
243+
dotnet-coverage collect "dotnet test --framework ${{ matrix.dotnet }} --no-build --logger junit;LogFilePath=macos_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_results.junit.xml --verbosity normal" --output macos_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_coverage.xml --output-format cobertura --settings coverage.config
241244
env:
242245
snowflake_cloud_env: ${{ matrix.cloud_env }}
243246
net_version: ${{ matrix.dotnet }}
@@ -252,7 +255,7 @@ jobs:
252255
name: tests-performance_macos_${{ matrix.dotnet }}_${{ matrix.cloud_env }}
253256
path: Snowflake.Data.Tests/macos_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_performance.csv
254257
- name: Upload test results to Codecov
255-
if: ${{!cancelled()}}
258+
if: ${{ !cancelled() }}
256259
uses: codecov/test-results-action@v1
257260
with:
258261
token: ${{ secrets.CODE_COV_UPLOAD_TOKEN }}
@@ -263,3 +266,44 @@ jobs:
263266
token: ${{ secrets.CODE_COV_UPLOAD_TOKEN }}
264267
fail_ci_if_error: true
265268
files: Snowflake.Data.Tests/macos_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_coverage.xml
269+
270+
test-rockylinux9:
271+
name: Tests on Rocky Linux 9
272+
runs-on: ubuntu-latest
273+
strategy:
274+
fail-fast: false
275+
matrix:
276+
dotnet: ['net6.0', 'net7.0', 'net8.0', 'net9.0']
277+
cloud_env: ['AZURE', 'GCP', 'AWS']
278+
steps:
279+
- uses: actions/checkout@v4
280+
- name: Build and Run Tests in Docker
281+
run: ./ci/test_rockylinux9_docker.sh
282+
env:
283+
PARAMETER_SECRET: ${{ secrets.PARAMETER_SECRET }}
284+
snowflake_cloud_env: ${{ matrix.cloud_env }}
285+
net_version: ${{ matrix.dotnet }}
286+
DOTNET_COVERAGE_VERSION: "17.8.4"
287+
shell: bash
288+
- name: Upload Code Coverage Report
289+
uses: actions/upload-artifact@v4
290+
with:
291+
name: code-coverage-report_rockylinux9_${{ matrix.dotnet }}_${{ matrix.cloud_env }}
292+
path: Snowflake.Data.Tests/rockylinux9_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_coverage.xml
293+
- name: Upload Test Performance Report
294+
uses: actions/upload-artifact@v4
295+
with:
296+
name: tests-performance_rockylinux9_${{ matrix.dotnet }}_${{ matrix.cloud_env }}
297+
path: Snowflake.Data.Tests/linux_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_performance.csv
298+
- name: Upload test results to Codecov
299+
if: ${{ !cancelled() }}
300+
uses: codecov/test-results-action@v1
301+
with:
302+
token: ${{ secrets.CODE_COV_UPLOAD_TOKEN }}
303+
- name: Upload coverage reports to Codecov
304+
uses: codecov/codecov-action@v4
305+
with:
306+
# without the token code cov may fail because of Github limits https://github.com/codecov/codecov-action/issues/557
307+
token: ${{ secrets.CODE_COV_UPLOAD_TOKEN }}
308+
fail_ci_if_error: true
309+
files: Snowflake.Data.Tests/rockylinux9_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_coverage.xml
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
FROM rockylinux:9
2+
3+
USER root
4+
WORKDIR /
5+
6+
# Install Java 11 for wiremock
7+
RUN dnf -y update && \
8+
dnf install -y java-11-openjdk && \
9+
dnf clean all
10+
11+
# Set Java 11 as the default
12+
ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk
13+
ENV PATH="${JAVA_HOME}/bin:${PATH}"
14+
15+
# Install .NET from Microsoft repo (latest GA versions not available in Rocky's AppStream).
16+
# Exclude AppStream's .NET packages to avoid version conflicts and path mismatches.
17+
# See: https://learn.microsoft.com/en-us/dotnet/core/install/linux-package-mixup?pivots=os-linux-redhat
18+
RUN dnf install -y 'dnf-command(config-manager)' && \
19+
dnf config-manager --save --setopt="appstream.excludepkgs=dotnet*,aspnet*,netstandard*" && \
20+
dnf install -y https://packages.microsoft.com/config/rhel/9/packages-microsoft-prod.rpm && \
21+
dnf install -y \
22+
dotnet-sdk-6.0 \
23+
dotnet-sdk-7.0 \
24+
dotnet-sdk-8.0 \
25+
dotnet-sdk-9.0 && \
26+
dotnet --list-sdks && \
27+
dnf clean all
28+
29+
# Install dotnet-coverage tool to shared location (accessible by any user)
30+
ARG DOTNET_COVERAGE_VERSION
31+
ENV DOTNET_TOOLS=/opt/dotnet-tools
32+
ENV PATH="${PATH}:${DOTNET_TOOLS}"
33+
RUN dotnet tool install --tool-path ${DOTNET_TOOLS} dotnet-coverage --version ${DOTNET_COVERAGE_VERSION} && \
34+
dotnet-coverage --version
35+
36+
# Accept user ID as build argument to match host permissions
37+
ARG USER_ID=1001
38+
ARG GROUP_ID=1001
39+
40+
# Create user for proper permission testing
41+
RUN groupadd -g ${GROUP_ID} user && \
42+
useradd -u ${USER_ID} -g ${GROUP_ID} -m -s /bin/bash user && \
43+
mkdir -p /home/user/go && \
44+
chown -R user:user /home/user
45+
46+
USER user
47+
WORKDIR /home/user

ci/test_rockylinux9.sh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/bash -e
2+
#
3+
# Test Snowflake .NET Connector in Rocky Linux 9
4+
#
5+
# This script runs inside the Rocky Linux 9 Docker container.
6+
# It builds the .NET connector and runs tests for a specific target framework.
7+
#
8+
# Required environment variables:
9+
# - net_version: Target framework (e.g., "net8.0")
10+
# - snowflake_cloud_env: Cloud environment (e.g., "AWS", "AZURE", "GCP")
11+
# - PARAMETER_SECRET: GPG passphrase for decrypting test parameters
12+
#
13+
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
14+
CONNECTOR_DIR="$( dirname "${THIS_DIR}")"
15+
16+
# Validate required environment variables
17+
if [[ -z "$net_version" ]]; then
18+
echo "[ERROR] net_version environment variable not set."
19+
exit 1
20+
fi
21+
22+
if [[ -z "$snowflake_cloud_env" ]]; then
23+
echo "[ERROR] snowflake_cloud_env environment variable not set."
24+
exit 1
25+
fi
26+
echo "[INFO] Using cloud environment: ${snowflake_cloud_env}"
27+
28+
if [[ -z "$PARAMETER_SECRET" ]]; then
29+
echo "[ERROR] PARAMETER_SECRET environment variable is required"
30+
exit 1
31+
fi
32+
33+
# Decrypt parameters
34+
echo "[INFO] Decrypting test parameters for ${snowflake_cloud_env}..."
35+
gpg --quiet --batch --yes --decrypt --passphrase="$PARAMETER_SECRET" \
36+
"${CONNECTOR_DIR}/.github/workflows/parameters/parameters_${snowflake_cloud_env}.json.gpg" \
37+
> "${CONNECTOR_DIR}/Snowflake.Data.Tests/parameters.json"
38+
39+
# Decrypt RSA key
40+
echo "[INFO] Decrypting RSA key for ${snowflake_cloud_env}..."
41+
gpg --quiet --batch --yes --decrypt --passphrase="$PARAMETER_SECRET" \
42+
"${CONNECTOR_DIR}/.github/workflows/parameters/rsa_keys/rsa_key_dotnet_${snowflake_cloud_env}.p8.gpg" \
43+
> "${CONNECTOR_DIR}/Snowflake.Data.Tests/rsa_key_dotnet_${snowflake_cloud_env}.p8"
44+
45+
# Validate .NET SDK is installed
46+
if ! command -v dotnet &> /dev/null; then
47+
echo "[ERROR] dotnet command not found. Please ensure .NET SDK is installed."
48+
exit 1
49+
fi
50+
51+
# Display .NET version info
52+
echo "[INFO] .NET SDK version:"
53+
dotnet --version
54+
echo "[INFO] Available .NET runtimes:"
55+
dotnet --list-runtimes
56+
echo "[INFO] dotnet-coverage version:"
57+
dotnet-coverage --version
58+
59+
# Build from project root
60+
echo "[INFO] Building driver with SF_PUBLIC_ENVIRONMENT"
61+
pushd "${CONNECTOR_DIR}"
62+
dotnet restore
63+
dotnet build '-p:DefineAdditionalConstants=SF_PUBLIC_ENVIRONMENT'
64+
popd
65+
66+
# Run tests from Snowflake.Data.Tests directory
67+
echo "[INFO] Running tests for ${net_version}"
68+
pushd "${CONNECTOR_DIR}/Snowflake.Data.Tests"
69+
dotnet-coverage collect \
70+
"dotnet test --framework ${net_version} --no-build --logger \"junit;LogFilePath=rockylinux9_${net_version}_${snowflake_cloud_env}_results.junit.xml\" --verbosity normal" \
71+
--output "rockylinux9_${net_version}_${snowflake_cloud_env}_coverage.xml" \
72+
--output-format cobertura \
73+
--settings coverage.config
74+
popd
75+
76+
echo "[INFO] Tests completed successfully"

ci/test_rockylinux9_docker.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash -e
2+
#
3+
# Test Snowflake .NET Connector in Rocky Linux 9 Docker
4+
#
5+
# This script builds a Rocky Linux 9 Docker image with all required .NET SDKs
6+
# and runs the test script inside the container. It is called by GitHub Actions.
7+
#
8+
# Required environment variables (set by GHA workflow):
9+
# - net_version: Target framework (e.g., "net8.0")
10+
# - snowflake_cloud_env: Cloud environment (e.g., "AWS", "AZURE", "GCP")
11+
# - PARAMETER_SECRET: GPG passphrase (passed to container for decryption)
12+
# - DOTNET_COVERAGE_VERSION: dotnet-coverage tool version (e.g., "17.8.4")
13+
#
14+
15+
if [[ -z "$DOTNET_COVERAGE_VERSION" ]]; then
16+
echo "[ERROR] DOTNET_COVERAGE_VERSION environment variable is required"
17+
exit 1
18+
fi
19+
20+
# Set constants
21+
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
22+
CONNECTOR_DIR="$( dirname "${THIS_DIR}")"
23+
WORKSPACE=${WORKSPACE:-${CONNECTOR_DIR}}
24+
BASE_IMAGE="rockylinux:9"
25+
CONTAINER_NAME="test_dotnetconnector_rockylinux9"
26+
27+
echo "[INFO] Building Rocky Linux 9 Docker image with .NET SDKs"
28+
29+
# Get current user/group IDs to match host permissions
30+
USER_ID=$(id -u)
31+
GROUP_ID=$(id -g)
32+
33+
pushd $CONNECTOR_DIR
34+
docker build --pull -t ${CONTAINER_NAME}:1.0 \
35+
--build-arg USER_ID=$USER_ID \
36+
--build-arg GROUP_ID=$GROUP_ID \
37+
--build-arg DOTNET_COVERAGE_VERSION="${DOTNET_COVERAGE_VERSION}" \
38+
. -f ci/image/Dockerfile.dotnet-rhel9-build-test
39+
popd
40+
41+
echo "[INFO] Starting Rocky Linux 9 Docker container"
42+
docker run --network=host \
43+
-e CI \
44+
-e PARAMETER_SECRET \
45+
-e net_version \
46+
-e snowflake_cloud_env \
47+
--mount type=bind,source="${CONNECTOR_DIR}",target=/home/user/snowflake-connector-net \
48+
${CONTAINER_NAME}:1.0 \
49+
/home/user/snowflake-connector-net/ci/test_rockylinux9.sh

0 commit comments

Comments
 (0)