#!/bin/bash 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"