22# Smoke test script for NLWebNet Docker container
33# Tests basic functionality and health endpoints
44
5- set -e
5+ set -euo pipefail
66
77CONTAINER_NAME=" nlwebnet-test-$( date +%s) "
88CONTAINER_PORT=" 8080"
@@ -25,7 +25,7 @@ trap cleanup EXIT
2525
2626# Start the container
2727echo " 🚀 Starting container..."
28- if ! docker run -d --name " $CONTAINER_NAME " -p " $HOST_PORT :$CONTAINER_PORT " " $IMAGE_NAME " ; then
28+ if ! docker run -d --name " $CONTAINER_NAME " -p " $HOST_PORT :$CONTAINER_PORT " --memory=512m --cpus=1 " $IMAGE_NAME " ; then
2929 echo " ❌ Failed to start container"
3030 exit 1
3131fi
@@ -57,11 +57,11 @@ sleep 5
5757
5858# Test basic health endpoint
5959echo " 🔍 Testing health endpoint..."
60- if curl -f -s " http://localhost:$HOST_PORT /health" > /dev/null; then
60+ if curl --max-time 10 - f -s " http://localhost:$HOST_PORT /health" > /dev/null; then
6161 echo " ✅ Health endpoint responds successfully"
6262
6363 # Get and display health response
64- health_response=$( curl -s " http://localhost:$HOST_PORT /health" )
64+ health_response=$( curl --max-time 10 - s " http://localhost:$HOST_PORT /health" )
6565 echo " 📊 Health response: $health_response "
6666else
6767 echo " ❌ Health endpoint failed"
7272
7373# Test if detailed health endpoint exists
7474echo " 🔍 Testing detailed health endpoint..."
75- if curl -f -s " http://localhost:$HOST_PORT /health/detailed" > /dev/null; then
75+ if curl --max-time 10 - f -s " http://localhost:$HOST_PORT /health/detailed" > /dev/null; then
7676 echo " ✅ Detailed health endpoint responds successfully"
77- detailed_health=$( curl -s " http://localhost:$HOST_PORT /health/detailed" )
77+ detailed_health=$( curl --max-time 10 - s " http://localhost:$HOST_PORT /health/detailed" )
7878 echo " 📊 Detailed health response: $detailed_health "
7979else
8080 echo " ⚠️ Detailed health endpoint not available or failed (this may be expected)"
8181fi
8282
8383# Test basic root endpoint
8484echo " 🔍 Testing root endpoint..."
85- if curl -f -s " http://localhost:$HOST_PORT /" > /dev/null; then
85+ if curl --max-time 10 - f -s " http://localhost:$HOST_PORT /" > /dev/null; then
8686 echo " ✅ Root endpoint responds successfully"
8787else
8888 echo " ⚠️ Root endpoint failed (this may be expected for API-only services)"
8989fi
9090
9191# Test if NLWebNet API endpoints are available
9292echo " 🔍 Testing NLWebNet API endpoints..."
93- if curl -f -s " http://localhost:$HOST_PORT /api/nlweb" > /dev/null 2>&1 ; then
93+ if curl --max-time 10 - f -s " http://localhost:$HOST_PORT /api/nlweb" > /dev/null 2>&1 ; then
9494 echo " ✅ NLWebNet API endpoint responds"
95- elif curl -f -s " http://localhost:$HOST_PORT /nlweb" > /dev/null 2>&1 ; then
95+ elif curl --max-time 10 - f -s " http://localhost:$HOST_PORT /nlweb" > /dev/null 2>&1 ; then
9696 echo " ✅ NLWebNet endpoint responds"
9797else
9898 echo " ⚠️ NLWebNet API endpoints may not be available or configured differently"
0 commit comments