This document provides a comprehensive testing plan for the serverless function execution platform, covering all functionalities as outlined in the project requirements.
- Operating System: Ubuntu 22.04 LTS (recommended) or compatible OS
- Docker properly installed and running
- Python 3.9+ installed
- Node.js installed (for JavaScript functions)
- gVisor runtime installed for second virtualization technology
-
Backend API Server:
# From the root directory pip install -r requirements.txt python backend/app.py -
Frontend Application:
# From the root directory pip install streamlit streamlit run frontend/app.py -
Access the Application:
- Backend API: http://localhost:8000
- Frontend UI: http://localhost:8501
-
Verify Git repository is initialized
git status
-
Verify all dependencies are installed
pip list | grep -E "fastapi|uvicorn|sqlalchemy|docker|streamlit"
-
Verify project folder structure
ls -la
-
Test API health endpoint
curl http://localhost:8000/health
Expected result:
{"status": "healthy"} -
Test API root endpoint
curl http://localhost:8000/
Expected result:
{"message": "Welcome to the Serverless Function Execution Platform"} -
Test database connection This is implicitly tested when the app starts
-
Create a new function (Python)
curl -X POST http://localhost:8000/functions/ \ -H "Content-Type: application/json" \ -d '{ "name": "hello-world-python", "route": "hello-python", "language": "python", "code": "def main(event):\n name = event.get(\"name\", \"World\")\n return {\"message\": f\"Hello, {name}!\"}\n", "timeout": 30 }'
Expected result: New function JSON with an ID
-
Create a new function (JavaScript)
curl -X POST http://localhost:8000/functions/ \ -H "Content-Type: application/json" \ -d '{ "name": "hello-world-js", "route": "hello-js", "language": "javascript", "code": "function main(event) {\n const name = event.name || \"World\";\n return {message: `Hello, ${name}!`};\n}\n", "timeout": 30 }'
-
List all functions
curl http://localhost:8000/functions/
Expected result: List of created functions
-
Get a specific function
# Replace <function_id> with actual ID curl http://localhost:8000/functions/<function_id>
Expected result: Function details
-
Update a function
# Replace <function_id> with actual ID curl -X PUT http://localhost:8000/functions/<function_id> \ -H "Content-Type: application/json" \ -d '{ "name": "updated-function", "route": "updated-route", "language": "python", "code": "def main(event):\n name = event.get(\"name\", \"Updated World\")\n return {\"message\": f\"Updated Hello, {name}!\"}\n", "timeout": 60 }'
Expected result: Updated function JSON
-
Delete a function
# Replace <function_id> with actual ID curl -X DELETE http://localhost:8000/functions/<function_id>
Expected result: HTTP 204 No Content
-
Test Docker connectivity
docker ps
Expected result: List of running containers
-
Execute a Python function in Docker
# Replace <function_id> with actual ID curl -X POST http://localhost:8000/functions/<function_id>/execute \ -H "Content-Type: application/json" \ -d '{"name": "Docker Test"}'
Expected result:
{"message": "Hello, Docker Test!"} -
Execute a JavaScript function in Docker
# Replace <function_id> with actual ID of JS function curl -X POST http://localhost:8000/functions/<function_id>/execute \ -H "Content-Type: application/json" \ -d '{"name": "Docker JS Test"}'
Expected result:
{"message": "Hello, Docker JS Test!"} -
Test timeout enforcement
# Create a function that sleeps for longer than the timeout curl -X POST http://localhost:8000/functions/ \ -H "Content-Type: application/json" \ -d '{ "name": "timeout-test", "route": "timeout", "language": "python", "code": "import time\n\ndef main(event):\n time.sleep(31)\n return {\"message\": \"Should not reach here\"}\n", "timeout": 5 }' # Then execute it # Replace <function_id> with actual ID curl -X POST http://localhost:8000/functions/<function_id>/execute
Expected result: Timeout error
-
Test function warm-up mechanism This is an internal mechanism, but we can test warm start execution time
# Execute a function twice to see if the second execution is faster (warm start) # Replace <function_id> with actual ID time curl -X POST http://localhost:8000/functions/<function_id>/execute time curl -X POST http://localhost:8000/functions/<function_id>/execute
Expected result: Second execution should be faster
-
Test container pool functionality This is also an internal mechanism but can be validated through Docker
# Create a function and check if warm containers are created # Replace <function_name> with actual function name docker ps | grep <function_name>
Expected result: Should see containers in the pool
-
Test request routing to appropriate function
# Execute a function via its route curl -X POST http://localhost:8000/invoke/hello-python \ -H "Content-Type: application/json" \ -d '{"name": "Route Test"}'
Expected result: Function result
-
Test gVisor runtime installation
docker info | grep runscExpected result: Should show runsc runtime
-
Execute function using gVisor
# Create a function specifically for gVisor curl -X POST http://localhost:8000/functions/ \ -H "Content-Type: application/json" \ -d '{ "name": "gvisor-test", "route": "gvisor", "language": "python", "code": "def main(event):\n return {\"message\": \"Running in gVisor\", \"data\": event}\n", "timeout": 30, "virtualization": "gvisor" }' # Execute it # Replace <function_id> with actual ID curl -X POST http://localhost:8000/functions/<function_id>/execute \ -H "Content-Type: application/json" \ -d '{"test": "gVisor Test"}'
Expected result:
{"message": "Running in gVisor", "data": {"test": "gVisor Test"}}
- Run the performance comparison script
Expected result: Performance metrics for Docker vs gVisor
python execution_engine/performance_comparison.py
-
Test metrics storage for a function
# Execute a function multiple times # Replace <function_id> with actual ID curl -X POST http://localhost:8000/functions/<function_id>/execute curl -X POST http://localhost:8000/functions/<function_id>/execute curl -X POST http://localhost:8000/functions/<function_id>/execute # Then fetch metrics curl http://localhost:8000/metrics/function/<function_id>
Expected result: Execution metrics for the function
-
Test system-wide metrics
curl http://localhost:8000/metrics/system
Expected result: System-wide metrics including total executions, avg response time, etc.
-
Test the frontend application launch
streamlit run frontend/app.py
Expected result: Streamlit application runs and opens in browser
-
Test function creation through UI
- Navigate to "Create Function" page
- Fill out the form with a new function
- Click "Create Function"
Expected result: New function created and success message shown
-
Test function listing and details
- Navigate to "Functions" page
- Verify functions are listed
- Select a function to view details
Expected result: Function details shown including code and metrics
-
Test function execution through UI
- Select a function
- Click "Execute Function"
Expected result: Function executes and results are shown
-
Test system dashboard
- Navigate to "Dashboard" page
- Check system-wide metrics
Expected result: Dashboard shows total functions, executions, and other metrics
-
Test function metrics visualization
- Select a function
- View the metrics section
Expected result: Charts showing function execution metrics
- Create a function through the UI
- Execute the function through the UI
- View metrics for the function
- Update the function code
- Execute again and verify changes
- Test with both virtualization technologies
-
Test auto-scaling functionality Create a load generator to execute many functions simultaneously
# Example with a simple bash loop for i in {1..50}; do curl -X POST http://localhost:8000/functions/<function_id>/execute & done
Expected result: Container count should increase
- Test environment variable support
Expected result:
# Create a function that uses environment variables curl -X POST http://localhost:8000/functions/ \ -H "Content-Type: application/json" \ -d '{ "name": "env-test", "route": "env", "language": "python", "code": "import os\n\ndef main(event):\n return {\"env_var\": os.environ.get(\"TEST_VAR\", \"not found\")}\n", "timeout": 30, "env_vars": {"TEST_VAR": "test value"} }' # Execute it # Replace <function_id> with actual ID curl -X POST http://localhost:8000/functions/<function_id>/execute
{"env_var": "test value"}
- Test additional programming languages (if implemented)
Expected result:
# Example for Go curl -X POST http://localhost:8000/functions/ \ -H "Content-Type: application/json" \ -d '{ "name": "go-test", "route": "go", "language": "go", "code": "package main\n\nimport (\n \"encoding/json\"\n \"fmt\"\n \"os\"\n)\n\nfunc main() {\n var event map[string]interface{}\n json.NewDecoder(os.Stdin).Decode(&event)\n name, ok := event[\"name\"].(string)\n if !ok {\n name = \"World\"\n }\n fmt.Printf(\"{\\\"message\\\": \\\"Hello, %s!\\\"}\", name)\n}\n", "timeout": 30 }' # Execute it # Replace <function_id> with actual ID curl -X POST http://localhost:8000/functions/<function_id>/execute \ -H "Content-Type: application/json" \ -d '{"name": "Go Test"}'
{"message": "Hello, Go Test!"}
-
Docker Connection Issues
sudo systemctl status docker sudo systemctl restart docker sudo usermod -aG docker $USER && newgrp docker
-
gVisor Runtime Issues
sudo runsc install sudo systemctl restart docker
-
Database Connection Issues
# Check if database file exists ls -la backend/db/ -
Port Conflicts
# Check if ports are already in use sudo lsof -i :8000 sudo lsof -i :8501
- Project environment setup complete
- Basic API server implemented
- Function metadata storage working
- CRUD endpoints for function management
- Docker set up as first virtualization technology
- Function execution in Docker containers
- Timeout enforcement implemented
- Request routing working
- Function warm-up mechanism implemented
- Container pool for improved performance
- Second virtualization technology (gVisor) implemented
- Performance comparison between virtualization technologies
- Metrics collection for function execution
- Frontend application implemented
- Function deployment interface working
- Function management views implemented
- Metrics visualization components working
- Dashboard displays metrics and statistics
- All components integrated successfully
- Documentation completed
- Auto-scaling based on request load
- Environment variables support in functions
- Cost analysis comparing virtualization technologies
- Support for additional programming languages