Spaces:
Sleeping
Sleeping
| echo "π§ͺ Testing OFP Floor Manager Backend" | |
| echo "======================================" | |
| echo "" | |
| # Start the server in background | |
| echo "π‘ Starting Gradio server..." | |
| python3 test_app.py > /tmp/gradio_test.log 2>&1 & | |
| SERVER_PID=$! | |
| # Wait for server to start | |
| echo "β³ Waiting for server to start..." | |
| sleep 5 | |
| # Check if server is running | |
| if ! ps -p $SERVER_PID > /dev/null; then | |
| echo "β Server failed to start. Check logs:" | |
| cat /tmp/gradio_test.log | |
| exit 1 | |
| fi | |
| echo "β Server started (PID: $SERVER_PID)" | |
| echo "" | |
| # Test 1: Create Session | |
| echo "π§ͺ Test 1: Creating new session..." | |
| RESPONSE=$(curl -s -X POST http://localhost:7860/api/predict \ | |
| -H "Content-Type: application/json" \ | |
| -d '{"fn_index": 0, "data": [], "session_hash": "test_session_1"}') | |
| if echo "$RESPONSE" | grep -q "session_"; then | |
| echo "β Session created successfully" | |
| SESSION_ID=$(echo "$RESPONSE" | grep -o 'session_[a-z0-9]*' | head -1) | |
| echo " Session ID: $SESSION_ID" | |
| else | |
| echo "β Failed to create session" | |
| echo " Response: $RESPONSE" | |
| fi | |
| echo "" | |
| # Test 2: Add Agent | |
| echo "π§ͺ Test 2: Adding agent 'Alice'..." | |
| RESPONSE=$(curl -s -X POST http://localhost:7860/api/predict \ | |
| -H "Content-Type: application/json" \ | |
| -d '{"fn_index": 1, "data": ["Alice"], "session_hash": "test_session_1"}') | |
| if echo "$RESPONSE" | grep -q "Alice"; then | |
| echo "β Agent added successfully" | |
| else | |
| echo "β Failed to add agent" | |
| fi | |
| echo "" | |
| # Test 3: Add Another Agent | |
| echo "π§ͺ Test 3: Adding agent 'Bob'..." | |
| RESPONSE=$(curl -s -X POST http://localhost:7860/api/predict \ | |
| -H "Content-Type: application/json" \ | |
| -d '{"fn_index": 1, "data": ["Bob"], "session_hash": "test_session_1"}') | |
| if echo "$RESPONSE" | grep -q "Bob"; then | |
| echo "β Agent added successfully" | |
| else | |
| echo "β Failed to add agent" | |
| fi | |
| echo "" | |
| # Test 4: Send Message | |
| echo "π§ͺ Test 4: Sending message from Alice..." | |
| RESPONSE=$(curl -s -X POST http://localhost:7860/api/predict \ | |
| -H "Content-Type: application/json" \ | |
| -d '{"fn_index": 2, "data": ["Alice", "Hello Bob!"], "session_hash": "test_session_1"}') | |
| if echo "$RESPONSE" | grep -q "Hello Bob"; then | |
| echo "β Message sent successfully" | |
| else | |
| echo "β Failed to send message" | |
| fi | |
| echo "" | |
| # Test 5: Grant Floor | |
| echo "π§ͺ Test 5: Granting floor to Bob..." | |
| RESPONSE=$(curl -s -X POST http://localhost:7860/api/predict \ | |
| -H "Content-Type: application/json" \ | |
| -d '{"fn_index": 3, "data": ["Bob"], "session_hash": "test_session_1"}') | |
| if echo "$RESPONSE" | grep -q "granted"; then | |
| echo "β Floor granted successfully" | |
| else | |
| echo "β Failed to grant floor" | |
| fi | |
| echo "" | |
| echo "======================================" | |
| echo "π All tests completed!" | |
| echo "" | |
| # Show server logs | |
| echo "π Server logs:" | |
| tail -20 /tmp/gradio_test.log | |
| echo "" | |
| echo "π Stopping server (PID: $SERVER_PID)..." | |
| kill $SERVER_PID | |
| wait $SERVER_PID 2>/dev/null | |
| echo "β Server stopped" | |
| echo "" | |
| echo "π‘ To run the server interactively: python3 test_app.py" | |