22
33set -uo pipefail
44
5+ # Source common test utilities
6+ SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
7+ # shellcheck source=/dev/null
8+ source " $SCRIPT_DIR /test_utils.sh"
9+
10+ LLAMA_STACK_BASE_URL=" http://127.0.0.1:8321"
11+
512function start_and_wait_for_llama_stack_container {
613 # Start llama stack
714 docker run \
815 -d \
916 --pull=never \
1017 --net=host \
1118 -p 8321:8321 \
12- --env INFERENCE_MODEL=" $INFERENCE_MODEL " \
19+ --env INFERENCE_MODEL=" $VLLM_INFERENCE_MODEL " \
1320 --env EMBEDDING_MODEL=" $EMBEDDING_MODEL " \
1421 --env VLLM_URL=" $VLLM_URL " \
1522 --env ENABLE_SENTENCE_TRANSFORMERS=True \
1623 --env EMBEDDING_PROVIDER=sentence-transformers \
1724 --env TRUSTYAI_LMEVAL_USE_K8S=False \
25+ --env VERTEX_AI_PROJECT=" $VERTEX_AI_PROJECT " \
26+ --env VERTEX_AI_LOCATION=" $VERTEX_AI_LOCATION " \
27+ --env GOOGLE_APPLICATION_CREDENTIALS=" /run/secrets/gcp-credentials" \
1828 --env POSTGRES_HOST=" ${POSTGRES_HOST:- localhost} " \
1929 --env POSTGRES_PORT=" ${POSTGRES_PORT:- 5432} " \
2030 --env POSTGRES_DB=" ${POSTGRES_DB:- llamastack} " \
2131 --env POSTGRES_USER=" ${POSTGRES_USER:- llamastack} " \
2232 --env POSTGRES_PASSWORD=" ${POSTGRES_PASSWORD:- llamastack} " \
33+ --volume " $GOOGLE_APPLICATION_CREDENTIALS :/run/secrets/gcp-credentials:ro" \
2334 --name llama-stack \
2435 " $IMAGE_NAME :$GITHUB_SHA "
2536 echo " Started Llama Stack container..."
@@ -28,7 +39,7 @@ function start_and_wait_for_llama_stack_container {
2839 echo " Waiting for Llama Stack server..."
2940 for i in {1..60}; do
3041 echo " Attempt $i to connect to Llama Stack..."
31- resp=$( curl -fsS http://127.0.0.1:8321 /v1/health)
42+ resp=$( curl -fsS $LLAMA_STACK_BASE_URL /v1/health)
3243 if [ " $resp " == ' {"status":"OK"}' ]; then
3344 echo " Llama Stack server is up!"
3445 return
@@ -42,36 +53,37 @@ function start_and_wait_for_llama_stack_container {
4253}
4354
4455function test_model_list {
45- for model in " $INFERENCE_MODEL " " $EMBEDDING_MODEL " ; do
46- echo " ===> Looking for model $model ..."
47- resp=$( curl -fsS http://127.0.0.1:8321/v1/models)
56+ validate_model_parameter " $1 "
57+ local model=" $1 "
58+ echo " ===> Looking for model $model ..."
59+ resp=$( curl -fsS $LLAMA_STACK_BASE_URL /v1/models)
60+ echo " Response: $resp "
61+ if echo " $resp " | grep -q " $model " ; then
62+ echo " Model $model was found :)"
63+ else
64+ echo " Model $model was not found :("
4865 echo " Response: $resp "
49- if echo " $resp " | grep -q " $model " ; then
50- echo " Model $model was found :)"
51- continue
52- else
53- echo " Model $model was not found :("
54- echo " Response: $resp "
55- echo " Container logs:"
56- docker logs llama-stack || true
57- return 1
58- fi
59- done
66+ echo " Container logs:"
67+ docker logs llama-stack || true
68+ return 1
69+ fi
6070 return 0
6171}
6272
6373function test_model_openai_inference {
64- echo " ===> Attempting to chat with model $INFERENCE_MODEL ..."
65- resp=$( curl -fsS http://127.0.0.1:8321/v1/chat/completions -H " Content-Type: application/json" -d " {\" model\" : \" vllm-inference/$INFERENCE_MODEL \" ,\" messages\" : [{\" role\" : \" user\" , \" content\" : \" What color is grass?\" }], \" max_tokens\" : 128, \" temperature\" : 0.0}" )
74+ validate_model_parameter " $1 "
75+ local model=" $1 "
76+ echo " ===> Attempting to chat with model $model ..."
77+ resp=$( curl -fsS $LLAMA_STACK_BASE_URL /v1/chat/completions -H " Content-Type: application/json" -d " {\" model\" : \" $model \" ,\" messages\" : [{\" role\" : \" user\" , \" content\" : \" What color is grass?\" }], \" max_tokens\" : 128, \" temperature\" : 0.0}" )
6678 if echo " $resp " | grep -q " green" ; then
6779 echo " ===> Inference is working :)"
68- return
80+ return 0
6981 else
7082 echo " ===> Inference is not working :("
7183 echo " Response: $resp "
7284 echo " Container logs:"
7385 docker logs llama-stack || true
74- exit 1
86+ return 1
7587 fi
7688}
7789
@@ -137,20 +149,43 @@ function test_postgres_populated {
137149main () {
138150 echo " ===> Starting smoke test..."
139151 start_and_wait_for_llama_stack_container
140- if ! test_model_list; then
141- echo " Model list test failed :("
142- exit 1
143- fi
144- test_model_openai_inference
152+
153+ # Track failures
154+ failed_checks=()
155+
156+ echo " ===> Testing model list for all models..."
157+ for model in " $VLLM_INFERENCE_MODEL " " $VERTEX_AI_INFERENCE_MODEL " " $EMBEDDING_MODEL " ; do
158+ if ! test_model_list " $model " ; then
159+ failed_checks+=(" model_list:$model " )
160+ fi
161+ done
162+
163+ echo " ===> Testing inference for all models..."
164+ for model in " $VLLM_INFERENCE_MODEL " " $VERTEX_AI_INFERENCE_MODEL " ; do
165+ if ! test_model_openai_inference " $model " ; then
166+ failed_checks+=(" inference:$model " )
167+ fi
168+ done
169+
170+ # Verify PostgreSQL tables and data
145171 if ! test_postgres_tables_exist; then
146- echo " PostgreSQL tables verification failed :("
147- exit 1
172+ failed_checks+=(" postgres:tables" )
148173 fi
149174 if ! test_postgres_populated; then
150- echo " PostgreSQL data verification failed :("
175+ failed_checks+=(" postgres:data" )
176+ fi
177+
178+ # Report results
179+ if [ ${# failed_checks[@]} -eq 0 ]; then
180+ echo " ===> Smoke test completed successfully!"
181+ return 0
182+ else
183+ echo " ===> Smoke test failed for the following:"
184+ for failure in " ${failed_checks[@]} " ; do
185+ echo " - $failure "
186+ done
151187 exit 1
152188 fi
153- echo " ===> Smoke test completed successfully!"
154189}
155190
156191main " $@ "
0 commit comments