mirror of
https://github.com/lightbroker/llmsecops-research.git
synced 2026-03-31 00:59:35 +02:00
fix garak config paths
This commit is contained in:
49
.github/scripts/test_api.sh
vendored
49
.github/scripts/test_api.sh
vendored
@@ -1,18 +1,47 @@
|
||||
#!/bin/bash
|
||||
# Local-only usage: ./test_api.sh --local
|
||||
|
||||
set -e # Exit on error
|
||||
|
||||
cd $GITHUB_WORKSPACE
|
||||
# Parse command line arguments
|
||||
LOCAL=false
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--local)
|
||||
LOCAL=true
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$LOCAL" = false ]; then
|
||||
cd $GITHUB_WORKSPACE
|
||||
fi
|
||||
|
||||
echo "Making API request..."
|
||||
curl -X POST -i http://localhost:9999/api/conversations \
|
||||
-d '{ "prompt": "describe a random planet in our solar system in 10 words or less" }' \
|
||||
-H "Content-Type: application/json" > logs/test_request.log 2>&1
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Test API request failed"
|
||||
cat logs/test_request.log
|
||||
# Wait for server to start and verify it's running
|
||||
max_retries=30
|
||||
retry_count=0
|
||||
server_ready=false
|
||||
|
||||
while [ $retry_count -lt $max_retries ] && [ "$server_ready" = false ]; do
|
||||
echo "Waiting for server to start (attempt $retry_count/$max_retries)..."
|
||||
if curl -s -o /dev/null -w "%{http_code}" localhost:9999 > /dev/null 2>&1; then
|
||||
server_ready=true
|
||||
echo "Server is running"
|
||||
else
|
||||
sleep 2
|
||||
retry_count=$((retry_count + 1))
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$server_ready" = false ]; then
|
||||
echo "::error::Server failed to start after $max_retries attempts"
|
||||
exit 1
|
||||
else
|
||||
echo "Test API request succeeded"
|
||||
cat logs/test_request.log
|
||||
fi
|
||||
Reference in New Issue
Block a user