|
| 1 | +# Kernel Integration Tests for dbt-databricks. |
| 2 | +# |
| 3 | +# Runs the functional suite against the SQL-warehouse profile with the |
| 4 | +# databricks-sql-connector Rust kernel backend (use_kernel=True) instead of |
| 5 | +# the default Thrift backend, on a weekly Saturday schedule. Like |
| 6 | +# integration-spog.yml this is a scheduled smoke, not a PR gate — PR-targeting |
| 7 | +# and status-reporting are omitted. |
| 8 | +# |
| 9 | +# Why warehouse-only: the kernel routes over the SEA (Statement Execution API) |
| 10 | +# HTTP transport, which is warehouse-only — the connector rejects an |
| 11 | +# all-purpose-cluster http_path ("SEA only works for warehouses"). So the two |
| 12 | +# cluster profiles from the main matrix cannot run on the kernel and are not |
| 13 | +# included here. |
| 14 | +# |
| 15 | +# Auth: the kernel owns the OAuth token lifecycle itself and its auth bridge |
| 16 | +# rejects the connector credentials_provider dbt passes on the Thrift path. |
| 17 | +# When DBT_DATABRICKS_USE_KERNEL=1, tests/profiles.py sets use_kernel=True and |
| 18 | +# the adapter forwards the raw OAuth M2M client id/secret (or a PAT) instead — |
| 19 | +# see SqlUtils.prepare_connection_arguments. |
| 20 | +name: Kernel Integration Tests |
| 21 | +on: |
| 22 | + workflow_dispatch: |
| 23 | + schedule: |
| 24 | + - cron: "17 9 * * 6" # Weekly: Saturday 09:17 UTC (14:47 IST). Clear of the |
| 25 | + # daily 21:30 UTC nightly and the Sunday SPOG slot, |
| 26 | + # which share the peco warehouse. |
| 27 | + |
| 28 | +permissions: |
| 29 | + id-token: write |
| 30 | + contents: read |
| 31 | + |
| 32 | +concurrency: |
| 33 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 34 | + cancel-in-progress: true |
| 35 | + |
| 36 | +jobs: |
| 37 | + prepare-shards: |
| 38 | + runs-on: |
| 39 | + group: databricks-protected-runner-group |
| 40 | + labels: linux-ubuntu-latest |
| 41 | + env: |
| 42 | + UV_FROZEN: "1" |
| 43 | + steps: |
| 44 | + - name: Check out the repository |
| 45 | + uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 |
| 46 | + |
| 47 | + - name: Setup JFrog PyPI Proxy |
| 48 | + uses: ./.github/actions/setup-jfrog-pypi |
| 49 | + |
| 50 | + - name: Set up Python |
| 51 | + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 |
| 52 | + with: |
| 53 | + python-version: "3.10" |
| 54 | + |
| 55 | + - name: Install uv |
| 56 | + uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4 |
| 57 | + with: |
| 58 | + cache-local-path: ~/.cache/uv |
| 59 | + |
| 60 | + - name: Install Hatch |
| 61 | + uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc # install |
| 62 | + |
| 63 | + - name: Collect tests and assign to shards |
| 64 | + run: | |
| 65 | + set -euo pipefail |
| 66 | + mkdir -p shard-assignments |
| 67 | + hatch run pytest --collect-only -q --profile databricks_uc_sql_endpoint tests/functional 2>&1 \ |
| 68 | + | grep "::" \ |
| 69 | + > "shard-assignments/databricks_uc_sql_endpoint-collected.txt" |
| 70 | + python3 scripts/shard_assign.py \ |
| 71 | + --profile databricks_uc_sql_endpoint \ |
| 72 | + --num-shards 3 \ |
| 73 | + --input "shard-assignments/databricks_uc_sql_endpoint-collected.txt" \ |
| 74 | + --output-dir shard-assignments \ |
| 75 | + --algo lpt_historical_time \ |
| 76 | + --timings .github/test_timings.json |
| 77 | +
|
| 78 | + - name: Upload shard assignments |
| 79 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 |
| 80 | + with: |
| 81 | + name: shard-assignments-kernel |
| 82 | + path: shard-assignments/ |
| 83 | + retention-days: 5 |
| 84 | + |
| 85 | + uc-sql-endpoint: |
| 86 | + needs: prepare-shards |
| 87 | + strategy: |
| 88 | + fail-fast: false |
| 89 | + matrix: |
| 90 | + shard: [0, 1, 2] |
| 91 | + runs-on: |
| 92 | + group: databricks-protected-runner-group |
| 93 | + labels: linux-ubuntu-latest |
| 94 | + environment: azure-prod |
| 95 | + env: |
| 96 | + DBT_DATABRICKS_HOST_NAME: ${{ secrets.DATABRICKS_HOST }} |
| 97 | + DBT_DATABRICKS_CLIENT_ID: ${{ secrets.TEST_PECO_SP_ID }} |
| 98 | + DBT_DATABRICKS_CLIENT_SECRET: ${{ secrets.TEST_PECO_SP_SECRET }} |
| 99 | + DBT_DATABRICKS_HTTP_PATH: ${{ secrets.TEST_PECO_WAREHOUSE_HTTP_PATH }} |
| 100 | + DBT_DATABRICKS_UC_INITIAL_CATALOG: peco |
| 101 | + DBT_DATABRICKS_LOCATION_ROOT: ${{ secrets.TEST_PECO_EXTERNAL_LOCATION }}test |
| 102 | + # Wire the UC cluster id so build_cluster_http_path.py can populate |
| 103 | + # DBT_DATABRICKS_UC_CLUSTER_HTTP_PATH. The kernel-incompatible tests that |
| 104 | + # pin a model to that cluster path are @pytest.mark.skip_kernel and skip |
| 105 | + # here; this keeps the env var resolvable so their fixtures still parse. |
| 106 | + TEST_PECO_UC_CLUSTER_ID: ${{ secrets.TEST_PECO_UC_CLUSTER_ID }} |
| 107 | + TEST_PECO_SPOG_HOST: ${{ secrets.TEST_PECO_SPOG_HOST }} |
| 108 | + TEST_PECO_SPOG_WORKSPACE_ID: ${{ secrets.TEST_PECO_SPOG_WORKSPACE_ID }} |
| 109 | + # Route the whole suite through the connector's Rust kernel (SEA) backend. |
| 110 | + DBT_DATABRICKS_USE_KERNEL: "1" |
| 111 | + UV_FROZEN: "1" |
| 112 | + steps: |
| 113 | + - name: Check out repository |
| 114 | + uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 |
| 115 | + |
| 116 | + - name: Setup JFrog PyPI Proxy |
| 117 | + uses: ./.github/actions/setup-jfrog-pypi |
| 118 | + |
| 119 | + - name: Set up python |
| 120 | + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 |
| 121 | + with: |
| 122 | + python-version: "3.10" |
| 123 | + |
| 124 | + - name: Get http path from environment |
| 125 | + run: python .github/workflows/build_cluster_http_path.py |
| 126 | + shell: sh |
| 127 | + |
| 128 | + - name: Install uv |
| 129 | + uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4 |
| 130 | + with: |
| 131 | + cache-local-path: ~/.cache/uv |
| 132 | + |
| 133 | + - name: Install Hatch |
| 134 | + uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc # install |
| 135 | + |
| 136 | + - name: Install the connector kernel extra |
| 137 | + # The kernel backend ships in the optional databricks-sql-connector |
| 138 | + # [kernel] extra (a PyO3 wheel), which the frozen lock does not include. |
| 139 | + # Add it into the hatch env so use_kernel=True can import the kernel. |
| 140 | + run: | |
| 141 | + set -euo pipefail |
| 142 | + HATCH_PY="$(hatch run python -c 'import sys; print(sys.executable)')" |
| 143 | + hatch run python -c "import databricks.sql as s; print('connector version:', s.__version__)" |
| 144 | + uv pip install --python "$HATCH_PY" "databricks-sql-connector[kernel]" |
| 145 | + hatch run python -c "import databricks_sql_kernel; print('kernel extra installed')" |
| 146 | +
|
| 147 | + - name: Download shard assignments |
| 148 | + uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 |
| 149 | + with: |
| 150 | + name: shard-assignments-kernel |
| 151 | + path: shard-assignments/ |
| 152 | + |
| 153 | + - name: Resolve test list for this shard |
| 154 | + run: | |
| 155 | + set -euo pipefail |
| 156 | + SHARD_FILE="shard-assignments/databricks_uc_sql_endpoint-shard-${{ matrix.shard }}.txt" |
| 157 | + if [ ! -s "$SHARD_FILE" ]; then |
| 158 | + echo "::error::Shard file missing or empty: $SHARD_FILE" |
| 159 | + exit 1 |
| 160 | + fi |
| 161 | + echo "SHARD_TESTS_FILE=$SHARD_FILE" >> "$GITHUB_ENV" |
| 162 | + echo "Files in shard ${{ matrix.shard }}: $(wc -l < "$SHARD_FILE")" |
| 163 | +
|
| 164 | + - name: Run Sql Endpoint Functional Tests on kernel (shard ${{ matrix.shard }}) |
| 165 | + run: | |
| 166 | + mkdir -p logs |
| 167 | + DBT_TEST_USER=notnecessaryformosttests@example.com \ |
| 168 | + xargs -r hatch -v run pytest \ |
| 169 | + --color=yes -v \ |
| 170 | + --profile databricks_uc_sql_endpoint \ |
| 171 | + -n 10 --dist=loadfile \ |
| 172 | + --reruns 2 --reruns-delay 120 \ |
| 173 | + --junitxml=logs/junit-kernel-sql-endpoint-shard-${{ matrix.shard }}.xml \ |
| 174 | + < "$SHARD_TESTS_FILE" |
| 175 | +
|
| 176 | + - name: Upload Kernel SQL Endpoint Test Logs |
| 177 | + if: always() |
| 178 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 |
| 179 | + with: |
| 180 | + name: kernel-sql-endpoint-logs-shard-${{ matrix.shard }} |
| 181 | + path: logs/ |
| 182 | + retention-days: 14 |
0 commit comments