44
55set -e
66
7- # Calculate WORKPATH - handle both local and CI environments
8- # If run from tests/ directory: WORKPATH = parent directory
9- # If run from root: WORKPATH = current directory
10- SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
11- if [ -f " $SCRIPT_DIR /../cogniwareims.py" ]; then
12- # We're in the CogniwareIms directory structure
13- WORKPATH=" $( cd " $SCRIPT_DIR /.." && pwd) "
14- elif [ -f " $SCRIPT_DIR /../../CogniwareIms/cogniwareims.py" ]; then
15- # We're in GenAIExamples/CogniwareIms/tests
16- WORKPATH=" $( cd " $SCRIPT_DIR /../.." && pwd) /CogniwareIms"
17- else
18- # Fallback: assume we're in the example directory
19- WORKPATH=" $( cd " $SCRIPT_DIR /.." && pwd) "
20- fi
21-
7+ WORKPATH=$( dirname " $PWD " )
228LOG_PATH=" $WORKPATH /tests"
239
24- # Debug output
25- echo " SCRIPT_DIR: $SCRIPT_DIR "
26- echo " WORKPATH: $WORKPATH "
27- echo " Verifying WORKPATH..."
28- if [ ! -f " $WORKPATH /cogniwareims.py" ] && [ ! -f " $WORKPATH /CogniwareIms/cogniwareims.py" ]; then
29- echo " WARNING: cogniwareims.py not found in WORKPATH. Attempting to locate..."
30- # Try to find it
31- if [ -f " $( dirname " $SCRIPT_DIR " ) /cogniwareims.py" ]; then
32- WORKPATH=" $( dirname " $SCRIPT_DIR " ) "
33- echo " Found cogniwareims.py at: $WORKPATH "
34- fi
35- fi
36-
3710# Get IP address with fallback to localhost
3811if command -v hostname > /dev/null 2>&1 ; then
3912 ip_address=$( hostname -I | awk ' {print $1}' 2> /dev/null || echo " 127.0.0.1" )
@@ -54,7 +27,7 @@ wait_for_service() {
5427 local service_name=$2
5528 local max_attempts=${3:- 30}
5629 local attempt=0
57-
30+
5831 echo " Waiting for $service_name ..."
5932 while [ $attempt -lt $max_attempts ]; do
6033 if curl -s -f " $url " > /dev/null 2>&1 ; then
@@ -65,49 +38,34 @@ wait_for_service() {
6538 echo " Waiting for $service_name ... (attempt $attempt /$max_attempts )"
6639 sleep 10
6740 done
68-
41+
6942 echo " ERROR: $service_name failed to become ready after $(( max_attempts * 10 )) seconds"
7043 return 1
7144}
7245
7346function build_docker_images() {
7447 echo " Building Docker images..."
75- if [ -d " $WORKPATH /docker_image_build" ]; then
76- cd " $WORKPATH /docker_image_build"
77- elif [ -d " $WORKPATH /CogniwareIms/docker_image_build" ]; then
78- cd " $WORKPATH /CogniwareIms/docker_image_build"
79- else
80- echo " ERROR: docker_image_build directory not found"
81- exit 1
82- fi
48+ cd $WORKPATH /docker_build_image
8349 docker compose -f build.yaml build
8450}
8551
8652function start_services() {
87- echo " Starting Cogniware IMS services on Intel Xeon..."
88- if [ -d " $WORKPATH /docker_compose/intel/cpu/xeon" ]; then
89- cd " $WORKPATH /docker_compose/intel/cpu/xeon"
90- elif [ -d " $WORKPATH /CogniwareIms/docker_compose/intel/cpu/xeon" ]; then
91- cd " $WORKPATH /CogniwareIms/docker_compose/intel/cpu/xeon"
92- else
93- echo " ERROR: docker_compose/intel/cpu/xeon directory not found"
94- exit 1
95- fi
53+ echo " Starting services on Intel Xeon..."
54+ cd $WORKPATH /docker_compose/intel/xeon
9655
9756 # Set environment variables
9857 export HUGGINGFACEHUB_API_TOKEN=${HUGGINGFACEHUB_API_TOKEN}
9958 export LLM_MODEL_ID=${LLM_MODEL_ID:- " Intel/neural-chat-7b-v3-3" }
10059 export EMBEDDING_MODEL_ID=${EMBEDDING_MODEL_ID:- " BAAI/bge-base-en-v1.5" }
10160 export RERANK_MODEL_ID=${RERANK_MODEL_ID:- " BAAI/bge-reranker-base" }
102- export POSTGRES_PASSWORD=${POSTGRES_PASSWORD:- " postgres" }
10361
10462 echo " Starting Docker Compose services..."
10563 docker compose up -d
10664
107- # Wait for services to be ready
65+ # Wait for services to be ready (increased wait time for CI)
10866 echo " Waiting for services to initialize..."
10967 sleep 90
110-
68+
11169 # Check if containers are running
11270 echo " Checking container status..."
11371 docker compose ps
@@ -131,35 +89,13 @@ function validate_services() {
13189 echo " Waiting for Redis container... (attempt $attempt /$max_attempts )"
13290 sleep 5
13391 done
134-
92+
13593 if [ $attempt -eq $max_attempts ]; then
13694 echo " ERROR: Redis failed to become ready"
13795 docker logs redis-vector-db || true
13896 exit 1
13997 fi
14098
141- # Check PostgreSQL
142- echo " Checking PostgreSQL..."
143- max_attempts=30
144- attempt=0
145- while [ $attempt -lt $max_attempts ]; do
146- if docker ps | grep -q " postgres-db" ; then
147- if docker exec postgres-db pg_isready -U postgres > /dev/null 2>&1 ; then
148- echo " PostgreSQL is ready!"
149- break
150- fi
151- fi
152- attempt=$(( attempt + 1 ))
153- echo " Waiting for PostgreSQL container... (attempt $attempt /$max_attempts )"
154- sleep 5
155- done
156-
157- if [ $attempt -eq $max_attempts ]; then
158- echo " ERROR: PostgreSQL failed to become ready"
159- docker logs postgres-db || true
160- exit 1
161- fi
162-
16399 # Check TGI service
164100 wait_for_service " http://${ip_address} :8008/health" " TGI service" 30 || exit 1
165101
@@ -178,94 +114,81 @@ function validate_services() {
178114 echo " All microservices are healthy!"
179115}
180116
181- function validate_backend () {
182- echo " Validating Cogniware IMS backend ..."
117+ function validate_megaservice () {
118+ echo " Validating InventoryMS megaservice ..."
183119
184120 # Check backend health
185- wait_for_service " http://${ip_address} :8000/api/ health" " Cogniware IMS backend" 30 || exit 1
121+ wait_for_service " http://${ip_address} :8888/ health" " InventoryMS backend" 30 || exit 1
186122
187- # Test chat endpoint
123+ # Test chat completion endpoint
188124 echo " Testing chat completion..."
189125 max_attempts=3
190126 attempt=0
191127 while [ $attempt -lt $max_attempts ]; do
192- response=$( curl -s -X POST http://${ip_address} :8000/api /chat \
128+ response=$( curl -s -X POST http://${ip_address} :8888/v1 /chat/completions \
193129 -H " Content-Type: application/json" \
194130 -d ' {
195- "message ": "What Intel processors are best for inventory systems?",
196- "session_id ": "test_session",
197- "user_role": "Inventory Manager"
131+ "messages ": [
132+ {"role ": "user", "content": "What Intel processors are available for data centers?"}
133+ ]
198134 }' || echo " " )
199-
135+
200136 if [ -z " $response " ]; then
201- echo " Empty response from chat endpoint (attempt $(( attempt + 1 )) /$max_attempts )"
137+ echo " Empty response from chat completion endpoint (attempt $(( attempt + 1 )) /$max_attempts )"
202138 attempt=$(( attempt + 1 ))
203139 sleep 5
204140 continue
205141 fi
206-
142+
207143 if echo " $response " | grep -qi " error" ; then
208- echo " Chat test failed!"
144+ echo " Chat completion test failed!"
209145 echo " Response: $response "
210146 attempt=$(( attempt + 1 ))
211147 if [ $attempt -ge $max_attempts ]; then
212148 exit 1
213149 fi
214150 sleep 5
215151 else
216- echo " Chat test successful!"
217- break
152+ echo " Chat completion test successful!"
153+ echo " Megaservice validation successful!"
154+ return 0
218155 fi
219156 done
220157
221- # Test knowledge stats
222- echo " Testing knowledge base stats..."
223- wait_for_service " http://${ip_address} :8000/api/knowledge/stats" " Knowledge base stats" 10 || exit 1
224-
225- echo " Backend validation successful!"
158+ exit 1
226159}
227160
228161function validate_frontend() {
229- echo " Validating Cogniware IMS frontend..."
162+ echo " Validating InventoryMS frontend..."
230163
231164 # Check UI health
232- wait_for_service " http://${ip_address} :3000" " Cogniware IMS UI" 30 || exit 1
165+ wait_for_service " http://${ip_address} :3000" " InventoryMS UI" 30 || exit 1
233166
234167 echo " Frontend validation successful!"
235168}
236169
237170function stop_services() {
238171 echo " Stopping services..."
239- if [ -d " $WORKPATH /docker_compose/intel/cpu/xeon" ]; then
240- cd " $WORKPATH /docker_compose/intel/cpu/xeon"
241- elif [ -d " $WORKPATH /CogniwareIms/docker_compose/intel/cpu/xeon" ]; then
242- cd " $WORKPATH /CogniwareIms/docker_compose/intel/cpu/xeon"
243- else
244- echo " Warning: docker_compose directory not found, attempting cleanup anyway"
245- fi
246- docker compose down -v 2> /dev/null || {
247- echo " Warning: Some containers may not have stopped cleanly"
248- docker ps -a | grep cogniware || true
249- }
172+ cd $WORKPATH /docker_compose/intel/xeon
173+ docker compose down -v
250174}
251175
252176function main() {
253177 echo " ========================================="
254- echo " Cogniware IMS E2E Test on Intel Xeon"
178+ echo " InventoryMS E2E Test on Intel Xeon"
255179 echo " ========================================="
256180
257181 stop_services
258182 build_docker_images
259183 start_services
260184 validate_services
261- validate_backend
185+ validate_megaservice
262186 validate_frontend
263187 stop_services
264188
265189 echo " ========================================="
266- echo " Cogniware IMS E2E Test Passed!"
190+ echo " InventoryMS E2E Test Passed!"
267191 echo " ========================================="
268192}
269193
270194main
271-
0 commit comments