Skip to content

Commit ceb956f

Browse files
authored
acc: run ssh/connect-serverless-cpu locally (#5941)
## Changes - Flip to `Local = true` / `Cloud = false`. The bare `ssh connect` (serverless CPU) now runs against the in-process testserver, whose driver-proxy `/ssh` websocket is backed by a real `sshd` — so the test asserts both the submitted bootstrap job and a full handshake + remote exec over the tunnel. - Linux-only (`[GOOS]`), skipped when `sshd` is absent, matching the sibling SSH tests. - Add a `Repls` for `databricks-cpu-<hash>`: with no `--name`, the connection name is derived from a hash of the workspace host (a random localhost port locally), so it's normalized to keep the submitted job payload deterministic. - Keep the `CLOUD_ENV` branch so the real serverless-CPU path is preserved for when cloud `ssh connect` is re-enabled. ## Why `Cloud = false` reflects that cloud `ssh connect` is currently disabled (#4838); the real coverage now comes from the local run. Consistent with `connect-serverless-gpu` and `connection`.
1 parent dd02458 commit ceb956f

5 files changed

Lines changed: 93 additions & 9 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# not actually checked by tests; accept-new appends the ephemeral host key here

acceptance/ssh/connect-serverless-cpu/out.test.toml

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
=== CLI ssh connect (local sshd)
3+
4+
>>> print_requests.py //api/2.2/jobs/runs/submit
5+
{
6+
"method": "POST",
7+
"path": "/api/2.2/jobs/runs/submit",
8+
"body": {
9+
"environments": [
10+
{
11+
"environment_key": "ssh_tunnel_serverless",
12+
"spec": {
13+
"environment_version": "4"
14+
}
15+
}
16+
],
17+
"run_name": "ssh-server-bootstrap-[CPU_CONN]",
18+
"tasks": [
19+
{
20+
"environment_key": "ssh_tunnel_serverless",
21+
"notebook_task": {
22+
"base_parameters": {
23+
"authorizedKeySecretName": "client-public-key",
24+
"maxClients": "10",
25+
"secretScopeName": "[USERNAME]-[CPU_CONN]-ssh-tunnel-keys",
26+
"serverless": "true",
27+
"sessionId": "[CPU_CONN]",
28+
"shutdownDelay": "10m0s",
29+
"version": "[CLI_VERSION]"
30+
},
31+
"notebook_path": "/Workspace/Users/[USERNAME]/.databricks/ssh-tunnel/[CLI_VERSION]/[CPU_CONN]/ssh-server-bootstrap"
32+
},
33+
"task_key": "start_ssh_server",
34+
"timeout_seconds": 86400
35+
}
36+
],
37+
"timeout_seconds": 86400
38+
}
39+
}
Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
1-
errcode $CLI ssh connect --releases-dir=$CLI_RELEASES_DIR -- "echo 'Connection successful'" >out.stdout.txt 2>LOG.stderr
1+
if [ -n "${CLOUD_ENV:-}" ]; then
2+
# Cloud: real serverless CPU runs the command; dump the run on failure.
3+
title "CLI ssh connect (serverless CPU)\n"
4+
errcode $CLI ssh connect --releases-dir=$CLI_RELEASES_DIR -- "echo 'Connection successful'" >out.stdout.txt 2>LOG.stderr
5+
if ! grep -q "Connection successful" out.stdout.txt; then
6+
run_id=$(cat LOG.stderr | grep -o "Job submitted successfully with run ID: [0-9]*" | grep -o "[0-9]*$")
7+
trace $CLI jobs get-run "$run_id" > LOG.job
8+
fi
9+
else
10+
# Local: the test server backs the /ssh websocket with a real sshd, so this
11+
# asserts the bootstrap job plus a full handshake over the tunnel. Skip when
12+
# sshd is absent (only task test-exp-ssh provisions it).
13+
if [ -z "$(command -v sshd || ls /usr/sbin/sshd /usr/local/sbin/sshd /sbin/sshd 2>/dev/null)" ]; then
14+
echo "SKIP_TEST sshd (openssh-server) not installed"
15+
exit 0
16+
fi
217

3-
if ! grep -q "Connection successful" out.stdout.txt; then
4-
run_id=$(cat LOG.stderr | grep -o "Job submitted successfully with run ID: [0-9]*" | grep -o "[0-9]*$")
5-
trace $CLI jobs get-run "$run_id" > LOG.job
18+
# No release artifacts locally and they're never executed; stand in empty archives.
19+
mkdir -p releases
20+
touch releases/databricks_cli_linux_amd64.zip
21+
touch releases/databricks_cli_linux_arm64.zip
22+
CLI_RELEASES_DIR="$PWD/releases"
23+
24+
title "CLI ssh connect (local sshd)\n"
25+
errcode $CLI ssh connect --releases-dir=$CLI_RELEASES_DIR --user-known-hosts-file=known_hosts -- "echo 'Connection successful'" >out.stdout.txt 2>LOG.stderr
26+
trace print_requests.py //api/2.2/jobs/runs/submit
627
fi
Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,28 @@
1-
Local = false
2-
Cloud = true
1+
Local = true
2+
Cloud = false
33

4-
# Serverless requires Unity Catalog
4+
# Serverless requires Unity Catalog.
55
RequiresUnityCatalog = true
66

7+
# Record requests so we can assert the bootstrap job the CLI submits.
8+
RecordRequests = true
9+
10+
# Stand-in release archives staged by the local run; not golden output.
11+
Ignore = [
12+
"releases",
13+
]
14+
15+
# The local run drives a real sshd, reliable only on Linux.
16+
[GOOS]
17+
linux = true
18+
darwin = false
19+
windows = false
20+
21+
# No --name: the connection name is a hash of the (random) local host, so
22+
# normalize it to keep the submitted job payload deterministic.
23+
[[Repls]]
24+
Old = 'databricks-cpu-[0-9a-f]{8}'
25+
New = "[CPU_CONN]"
26+
727
[EnvMatrix]
828
DATABRICKS_BUNDLE_ENGINE = ["direct"]

0 commit comments

Comments
 (0)