Repository navigation
200 lines (179 loc) · 7.7 KB
/
Copy pathrust-e2e.yml
File metadata and controls
200 lines (179 loc) · 7.7 KB
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# Copyright (c) 2026 Databricks, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# End-to-end tests against a live Databricks workspace.
#
# The `e2e` job covers the v0 surface (Session::open, execute,
# submit, await_result, metadata) via PAT + OAuth M2M. OAuth U2M is
# intentionally absent: it requires a browser flow that can't run in
# CI; `tests/oauth_u2m_integration.rs` covers it on developer
# machines.
#
# The `tls` job covers `TlsConfig` (custom CA + accept-self-signed)
# end-to-end through an intercepting mitmproxy. Full HTTP proxy
# coverage (driving `SessionBuilder::proxy` directly) lands with the
# v0.1 work that fleshes out the reserved `ProxyConfig` in
# `src/config.rs`. Tracked in `docs/migration-plan.md` §7.
name: Rust E2E Tests
on:
push:
branches: [main]
paths:
- "src/**"
- "tests/**"
- "Cargo.toml"
- "Cargo.lock"
- ".github/workflows/rust-e2e.yml"
pull_request:
branches: [main]
paths:
- "src/**"
- "tests/**"
- "Cargo.toml"
- "Cargo.lock"
- ".github/workflows/rust-e2e.yml"
concurrency:
group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-rust-e2e
cancel-in-progress: true
permissions:
contents: read
id-token: write
defaults:
run:
shell: bash
jobs:
e2e:
name: "v0 E2E surface"
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
runs-on:
group: databricks-protected-runner-group
labels: linux-ubuntu-latest
environment: azure-prod
env:
DATABRICKS_HOST: ${{ secrets.DATABRICKS_HOST }}
DATABRICKS_HTTP_PATH: ${{ secrets.DATABRICKS_HTTP_PATH }}
DATABRICKS_TOKEN: ${{ secrets.DATABRICKS_TOKEN }}
DATABRICKS_TEST_CLIENT_ID: ${{ secrets.DATABRICKS_TEST_CLIENT_ID }}
DATABRICKS_TEST_CLIENT_SECRET: ${{ secrets.DATABRICKS_TEST_CLIENT_SECRET }}
RUST_LOG: databricks_sql_kernel=debug
RUST_BACKTRACE: 1
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: "true"
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- uses: ./.github/actions/setup-jfrog
with:
cargo: "true"
- uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0
- name: Setup sccache
uses: Mozilla-Actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9
- name: Run v0 E2E tests
run: |
for suite in v0_session_e2e v0_execute_e2e v0_async_execute_e2e v0_metadata_e2e v0_query_tags_headers_e2e; do
echo "::group::cargo test --test ${suite}"
cargo test --test "${suite}" -- --ignored --nocapture
echo "::endgroup::"
done
# TLS end-to-end coverage: drive the v0 `Session` surface through an
# intercepting HTTPS proxy (mitmproxy) so the kernel's `TlsConfig`
# plumbing is exercised against a REAL TLS handshake to a live
# workspace, not just unit-level reqwest-builder construction.
#
# mitmproxy re-signs every connection with its own CA. A default
# (strict) client sees an untrusted cert and fails; supplying the
# CA via `TlsConfig::custom_ca_cert` — or disabling validation via
# `accept_self_signed` — makes the round-trip succeed. The three
# `#[ignore]`d tests in `tests/v0_tls_e2e.rs` cover exactly those
# outcomes. Ported from `adbc-drivers/databricks`'s `tls_e2e.rs`.
#
# The v0 public `ProxyConfig` is still reserved, so we route traffic
# by setting `HTTPS_PROXY` (which reqwest honours by default) rather
# than through `SessionBuilder::proxy`. When the v0 proxy surface
# lands, drive the proxy explicitly and add a fourth test.
tls:
name: "v0 TLS (mitmproxy)"
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
runs-on:
group: databricks-protected-runner-group
labels: linux-ubuntu-latest
environment: azure-prod
env:
DATABRICKS_HOST: ${{ secrets.DATABRICKS_HOST }}
DATABRICKS_HTTP_PATH: ${{ secrets.DATABRICKS_HTTP_PATH }}
DATABRICKS_TOKEN: ${{ secrets.DATABRICKS_TOKEN }}
DATABRICKS_TEST_CLIENT_ID: ${{ secrets.DATABRICKS_TEST_CLIENT_ID }}
DATABRICKS_TEST_CLIENT_SECRET: ${{ secrets.DATABRICKS_TEST_CLIENT_SECRET }}
RUST_LOG: databricks_sql_kernel=debug
RUST_BACKTRACE: 1
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: "true"
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- uses: ./.github/actions/setup-jfrog
with:
cargo: "true"
- uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0
- name: Setup sccache
uses: Mozilla-Actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9
- name: Start mitmproxy
run: |
docker run -d --name mitmproxy \
-p 8080:8080 \
mitmproxy/mitmproxy:12.2.1@sha256:743b6cdc817211d64bc269f5defacca8d14e76e647fc474e5c7244dbcb645141 \
mitmdump --set stream_large_bodies=0
for i in $(seq 1 15); do
if docker exec mitmproxy test -f /home/mitmproxy/.mitmproxy/mitmproxy-ca-cert.pem 2>/dev/null; then
echo "mitmproxy CA cert is ready"
break
fi
echo "Waiting for mitmproxy CA cert... ($i/15)"
sleep 1
done
- name: Extract mitmproxy CA certificate
run: |
docker cp mitmproxy:/home/mitmproxy/.mitmproxy/mitmproxy-ca-cert.pem /tmp/mitmproxy-ca-cert.pem
echo "MITMPROXY_CA_CERT=/tmp/mitmproxy-ca-cert.pem" >> "$GITHUB_ENV"
echo "Extracted mitmproxy CA cert:"
openssl x509 -in /tmp/mitmproxy-ca-cert.pem -noout -subject -issuer
# Compile the test binary BEFORE the proxy is in scope. The
# protected runner reaches crates via the JFrog proxy, so cargo's
# registry fetch must NOT be routed through mitmproxy (which can't
# reach the internal registry and would intercept it with an
# untrusted cert). We set HTTPS_PROXY only on the run step below.
- name: Build v0 TLS E2E test binary
run: cargo test --test v0_tls_e2e --no-run
- name: Run v0 TLS E2E tests
# HTTPS_PROXY is scoped to THIS step so only the test's own HTTP
# traffic flows through mitmproxy. `--no-run` already fetched +
# compiled everything, so cargo needs no registry access here.
env:
HTTPS_PROXY: http://localhost:8080
run: cargo test --test v0_tls_e2e -- --ignored --nocapture
- name: Verify traffic flowed through mitmproxy
if: always()
run: |
echo "=== mitmproxy logs (tail) ==="
docker logs mitmproxy 2>&1 | tail -50
echo "=== checking for proxied-connection entries ==="
docker logs mitmproxy 2>&1 \
| grep -i "CONNECT\|clientconnect\|<<" \
|| (echo "FAIL: no traffic in mitmproxy logs — proxy was not used" && exit 1)
- name: Cleanup mitmproxy
if: always()
run: docker rm -f mitmproxy 2>/dev/null || true