Skip to content

Commit f2dc235

Browse files
authored
Merge pull request #618 from IBM/fix-smoketest-2
Merged after rebase and CI tests passing
2 parents 76d2269 + 9b89611 commit f2dc235

File tree

3 files changed

+41
-17
lines changed

3 files changed

+41
-17
lines changed

.env.example

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,12 @@ CORS_ENABLED=true
131131
#####################################
132132

133133
RETRY_MAX_ATTEMPTS=3
134-
RETRY_BASE_DELAY=1.0 # seconds
135-
RETRY_MAX_DELAY=60.0 # seconds
136-
RETRY_JITTER_MAX=0.5 # fraction of delay
134+
# seconds
135+
RETRY_BASE_DELAY=1.0
136+
# seconds
137+
RETRY_MAX_DELAY=60.0
138+
# fraction of delay
139+
RETRY_JITTER_MAX=0.5
137140

138141
#####################################
139142
# Logging
@@ -253,9 +256,8 @@ UNHEALTHY_THRESHOLD=3
253256

254257
# This path is append with the system temp directory.
255258
# It is used to ensure that only one instance of the gateway health Check can run at a time.
256-
FILELOCK_NAME=gateway_healthcheck_init.lock # saved dir in /tmp/gateway_healthcheck_init.lock
257-
# FILELOCK_NAME=somefolder/gateway_healthcheck_init.lock # saved dir in /tmp/somefolder/gateway_healthcheck_init.lock#
258-
259+
# saved dir in /tmp/gateway_healthcheck_init.lock
260+
FILELOCK_NAME=gateway_healthcheck_init.lock
259261

260262
#####################################
261263
# Development Settings

Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,10 @@ clean:
223223
## --- Automated checks --------------------------------------------------------
224224
smoketest:
225225
@echo "🚀 Running smoketest..."
226-
@./smoketest.py --verbose || { echo "❌ Smoketest failed!"; exit 1; }
227-
@echo "✅ Smoketest passed!"
226+
@bash -c '\
227+
./smoketest.py --verbose || { echo "❌ Smoketest failed!"; exit 1; }; \
228+
echo "✅ Smoketest passed!" \
229+
'
228230

229231
test:
230232
@echo "🧪 Running tests..."
@@ -1194,7 +1196,7 @@ endef
11941196

11951197
# Containerfile to use (can be overridden)
11961198
#CONTAINER_FILE ?= Containerfile
1197-
CONTAINER_FILE ?= $(shell [ -f "Containerfile" ] && echo "Containerfile" || echo "Dockerfile")
1199+
CONTAINER_FILE ?= $(shell [ -f "Containerfile.lite" ] && echo "Containerfile.lite" || echo "Dockerfile")
11981200

11991201

12001202
# Define COMMA for the conditional Z flag
@@ -1267,6 +1269,7 @@ container-run-ssl: certs container-check-image
12671269
-$(CONTAINER_RUNTIME) stop $(PROJECT_NAME) 2>/dev/null || true
12681270
-$(CONTAINER_RUNTIME) rm $(PROJECT_NAME) 2>/dev/null || true
12691271
$(CONTAINER_RUNTIME) run --name $(PROJECT_NAME) \
1272+
-u $(id -u):$(id -g) \
12701273
--env-file=.env \
12711274
-e SSL=true \
12721275
-e CERT_FILE=certs/cert.pem \
@@ -1287,6 +1290,7 @@ container-run-ssl-host: certs container-check-image
12871290
-$(CONTAINER_RUNTIME) stop $(PROJECT_NAME) 2>/dev/null || true
12881291
-$(CONTAINER_RUNTIME) rm $(PROJECT_NAME) 2>/dev/null || true
12891292
$(CONTAINER_RUNTIME) run --name $(PROJECT_NAME) \
1293+
-u $(id -u):$(id -g) \
12901294
--network=host \
12911295
--env-file=.env \
12921296
-e SSL=true \

smoketest.py

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"-y",
6060
"supergateway",
6161
"--stdio",
62-
"uvx mcp-server-time --local-timezone=Europe/Dublin",
62+
"\"uvx mcp-server-time --local-timezone=Europe/Dublin\"",
6363
"--port",
6464
str(PORT_TIME_SERVER),
6565
]
@@ -296,9 +296,17 @@ def step_4_docker_run():
296296
def step_5_start_time_server(restart=False):
297297
global _supergw_proc, _supergw_log_file
298298

299+
nvm_sh = os.path.expanduser("~/.nvm/nvm.sh")
300+
cmd = f'source "{nvm_sh}" && nvm use default >/dev/null && npx --version'
301+
299302
# Check if npx is available
300303
try:
301-
npx_version = subprocess.check_output(["npx", "--version"], text=True, stderr=subprocess.DEVNULL).strip()
304+
npx_version = subprocess.check_output(
305+
["bash", "-c", cmd],
306+
text=True,
307+
stderr=subprocess.DEVNULL
308+
).strip()
309+
302310
logging.info("🔍 Found npx version: %s", npx_version)
303311
except (subprocess.CalledProcessError, FileNotFoundError):
304312
raise RuntimeError("npx not found. Please install Node.js and npm.")
@@ -337,8 +345,16 @@ def step_5_start_time_server(restart=False):
337345
logging.info("📝 Logging supergateway output to: %s", log_filename)
338346

339347
# Start the process with output capture
348+
cmd_str = " ".join(SUPERGW_CMD)
349+
bash_cmd = f'''
350+
export NVM_DIR="$HOME/.nvm"
351+
source "{nvm_sh}"
352+
nvm use default >/dev/null
353+
exec {cmd_str}
354+
'''
355+
340356
_supergw_proc = subprocess.Popen(
341-
SUPERGW_CMD,
357+
["bash", "-c", bash_cmd],
342358
stdout=_supergw_log_file,
343359
stderr=subprocess.STDOUT,
344360
text=True,
@@ -593,11 +609,13 @@ def main():
593609
logging.error(" - Check if port %d is already in use: lsof -i :%d", PORT_TIME_SERVER, PORT_TIME_SERVER)
594610
logging.error(" - Look for supergateway_*.log files for detailed output")
595611
logging.error(" - Try running with -v for verbose output")
596-
597-
if not failed:
598-
cleanup()
599-
else:
600-
logging.warning("⚠️ Skipping cleanup due to failure. Run with --cleanup-only to clean up manually.")
612+
finally:
613+
if not failed:
614+
cleanup()
615+
sys.exit(0)
616+
else:
617+
logging.warning("⚠️ Skipping cleanup due to failure. Run with --cleanup-only to clean up manually.")
618+
sys.exit(1)
601619

602620

603621
if __name__ == "__main__":

0 commit comments

Comments
 (0)