Skip to content

Commit 22ffe8e

Browse files
authored
Revert "acc: Use fixed ports instead of dynamically allocated ones for run-local tests" (#3505)
Reverts #3490 The tests still failing https://github.com/databricks/cli/actions/runs/17289620395/job/49073700178 ``` +++ /var/folders/x7/ch5v91h56_zbvbd1y2f600dm0000gn/T/TestAcceptcmdworkspaceappsrun-local1357262386/001/output.txt @@ -10,25 +10,6 @@ === Waiting === Checking app is running... >>> curl -s -o - http://127.0.0.1:$(port)/ -{ - "Accept": "*/*", - "Accept-Encoding": "gzip", - "Host": "127.0.0.1:$(port)", - "User-Agent": "curl/(version)", - "X-Forwarded-Email": "[USERNAME]", - "X-Forwarded-Host": "localhost", - "X-Forwarded-Preferred-Username": "", - "X-Forwarded-User": "[USERNAME]", - "X-Real-Ip": "127.0.0.1", - "X-Request-Id": "[UUID]" -} +jq: parse error: Invalid numeric literal at line 1, column 6 ```
1 parent 451dfea commit 22ffe8e

File tree

7 files changed

+45
-28
lines changed

7 files changed

+45
-28
lines changed

acceptance/bin/allocate_ports.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#! /usr/bin/env python3
2+
import socket
3+
import sys
4+
5+
if len(sys.argv) != 2:
6+
print("Usage: allocate_ports.py <number_of_ports>", file=sys.stderr)
7+
sys.exit(1)
8+
9+
num_ports = int(sys.argv[1])
10+
11+
ports = []
12+
sockets = []
13+
for _ in range(num_ports):
14+
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
15+
s.bind(("127.0.0.1", 0))
16+
port = s.getsockname()[1]
17+
ports.append(str(port))
18+
sockets.append(s)
19+
for s in sockets:
20+
s.close()
21+
sys.stdout.write("\n".join(ports))
22+
sys.stdout.flush()
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Local = true
1+
Local = false
22
Cloud = false
33

44
[EnvMatrix]
5-
DATABRICKS_CLI_DEPLOYMENT = ["terraform"]
5+
DATABRICKS_CLI_DEPLOYMENT = ["terraform", "direct-exp"]

acceptance/cmd/workspace/apps/run-local-node/script

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ cd app
44
# so we don't need to start it in background. It will install the dependencies as part of the command
55
trace $CLI apps run-local --prepare-environment --entry-point test.yml 2>&1 | grep -w "Hello, world"
66

7-
PORT=8080
8-
DEBUG_PORT=5252
9-
PROXY_PORT=8081
7+
# Get 3 unique ports sequentially to avoid conflicts
8+
PORTS=$(allocate_ports.py 3 | tr -d '\r')
9+
10+
# Read ports into array
11+
PORTS_ARR=($(echo "$PORTS"))
12+
PORT="${PORTS_ARR[0]}"
13+
DEBUG_PORT="${PORTS_ARR[1]}"
14+
PROXY_PORT="${PORTS_ARR[2]}"
1015

1116
title "Starting the app in background..."
1217
trace $CLI apps run-local --prepare-environment --debug --port "$PROXY_PORT" --debug-port "$DEBUG_PORT" --app-port "$PORT" > ../out.run.txt 2>&1 &
@@ -23,11 +28,6 @@ while [ -z "$(grep -o "Server is running on port " out.run.txt 2>/dev/null)" ];
2328
sleep 1
2429
done
2530

26-
# Make sure the proxy is ready to serve requests
27-
while [ -z "$(grep -o "To access your app go to " out.run.txt 2>/dev/null)" ]; do
28-
sleep 1
29-
done
30-
3131
title "Checking app is running..."
3232
trace curl -s -o - http://127.0.0.1:$PROXY_PORT | grep -w "Hello From App"
3333

acceptance/cmd/workspace/apps/run-local-node/test.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
# Temporarily disabled due to the flakiness like here https://github.com/databricks/cli/actions/runs/17234131593/job/48894892423
12
Cloud = false
2-
Local = true
3+
Local = false
34
RecordRequests = false
45
Timeout = '2m'
56
TimeoutWindows = '10m'
@@ -20,6 +21,3 @@ New='127.0.0.1:$(port)'
2021
[[Repls]]
2122
Old='To debug your app, attach a debugger to port [0-9]+'
2223
New='To debug your app, attach a debugger to port $(debug_port)'
23-
24-
[EnvMatrix]
25-
DATABRICKS_CLI_DEPLOYMENT = ["terraform"]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Local = true
1+
Local = false
22
Cloud = false
33

44
[EnvMatrix]
5-
DATABRICKS_CLI_DEPLOYMENT = ["terraform"]
5+
DATABRICKS_CLI_DEPLOYMENT = ["terraform", "direct-exp"]

acceptance/cmd/workspace/apps/run-local/script

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@ trace errcode $CLI apps run-local --entry-point value-from.yml 2>&1
66
# so we don't need to start it in background. It will install the dependencies as part of the command
77
trace $CLI apps run-local --prepare-environment --entry-point test.yml 2>&1 | grep -w "Hello, world"
88

9-
PORT=8080
10-
DEBUG_PORT=5252
11-
PROXY_PORT=8081
9+
# Get 3 unique ports sequentially to avoid conflicts
10+
PORTS=$(allocate_ports.py 3 | tr -d '\r')
11+
12+
# Read ports into array
13+
PORTS_ARR=($(echo "$PORTS"))
14+
PORT="${PORTS_ARR[0]}"
15+
DEBUG_PORT="${PORTS_ARR[1]}"
16+
PROXY_PORT="${PORTS_ARR[2]}"
1217

1318
title "Starting the app in background..."
1419
trace $CLI apps run-local --prepare-environment --debug --port "$PROXY_PORT" --debug-port "$DEBUG_PORT" --app-port "$PORT" > ../out.run.txt 2>&1 &
@@ -25,11 +30,6 @@ while [ -z "$(grep -o "Python Flask app has started with" out.run.txt 2>/dev/nul
2530
sleep 1
2631
done
2732

28-
# Make sure the proxy is ready to serve requests
29-
while [ -z "$(grep -o "To access your app go to " out.run.txt 2>/dev/null)" ]; do
30-
sleep 1
31-
done
32-
3333
title "Checking app is running..."
3434
trace curl -s -o - http://127.0.0.1:$PROXY_PORT | jq
3535

acceptance/cmd/workspace/apps/run-local/test.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Cloud = false
2-
Local = true
2+
Local = false
33
RecordRequests = false
44
Timeout = '2m'
55
TimeoutWindows = '10m'
@@ -20,6 +20,3 @@ New='127.0.0.1:$(port)'
2020
[[Repls]]
2121
Old='To debug your app, attach a debugger to port [0-9]+'
2222
New='To debug your app, attach a debugger to port $(debug_port)'
23-
24-
[EnvMatrix]
25-
DATABRICKS_CLI_DEPLOYMENT = ["terraform"]

0 commit comments

Comments
 (0)