Skip to content

Commit 61ed693

Browse files
authored
Fix error in conformance test script (#26)
## Problem Some random process could be running on `8003`. Before: - We would not run the `mock_devrev_server.py` on `8003` if a process was already running on `8003`. - But if what as running on `8003` wasn't mock server, this would be problematic as reported by @gasperzgonec After: - If traffic is running on `8003`, stop it and start `mock_devrev_server.py` The same for port `8004` and `rate_limiting_proxy.py`.
1 parent a3e61b2 commit 61ed693

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

run_devrev_snapin_conformance_tests.sh

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -164,23 +164,30 @@ trap cleanup EXIT SIGINT SIGTERM
164164
check_and_kill_node_server 8000
165165
check_and_kill_node_server 8002
166166

167-
# Start the mock DevRev server if it's not already running
168-
if ! lsof -i :8003 -t >/dev/null 2>&1; then
169-
start_mock_devrev_server
170-
else
171-
printf "Mock DevRev server is already running on port 8003\n"
172-
MOCK_SERVER_PID=$(lsof -i :8003 -t)
167+
# Ensure nothing is running on port 8003, then start the mock DevRev server
168+
existing_pids=$(lsof -i :8003 -t 2>/dev/null)
169+
if [ ! -z "$existing_pids" ]; then
170+
printf "Killing existing process(es) on port 8003: %s\n" "$existing_pids"
171+
for pid in $existing_pids; do
172+
kill $pid 2>/dev/null
173+
done
174+
sleep 1
173175
fi
176+
start_mock_devrev_server
174177

175178
# Set HTTPS_PROXY environment variable to point to proxy server
176179
export HTTPS_PROXY="http://localhost:8004"
177180

178-
if ! lsof -i :8004 -t >/dev/null 2>&1; then
179-
start_proxy_server
180-
else
181-
printf "Proxy server is already running on port 8004\n"
182-
PROXY_SERVER_PID=$(lsof -i :8004 -t)
181+
# Ensure nothing is running on port 8004, then start the proxy server
182+
existing_pids_8004=$(lsof -i :8004 -t 2>/dev/null)
183+
if [ ! -z "$existing_pids_8004" ]; then
184+
printf "Killing existing process(es) on port 8004: %s\n" "$existing_pids_8004"
185+
for pid in $existing_pids_8004; do
186+
kill $pid 2>/dev/null
187+
done
188+
sleep 1
183189
fi
190+
start_proxy_server
184191

185192
# Check if chef-cli binary exists at CHEF_CLI_PATH
186193
if [ -z "$CHEF_CLI_PATH" ] || [ ! -f "$CHEF_CLI_PATH" ] || [ ! -x "$CHEF_CLI_PATH" ]; then

0 commit comments

Comments
 (0)