Testing & Debugging
Ensuring code quality and diagnosing issues are crucial parts of development with JuliaOS. This comprehensive guide covers testing strategies, debugging techniques, and troubleshooting common issues across all components of the system.
Testing Strategies
Test Types
Unit Tests: Test individual functions and components in isolation
Integration Tests: Test interactions between components
End-to-End Tests: Test complete workflows from user input to final output
Performance Tests: Measure and validate system performance
Property-Based Tests: Generate random inputs to test properties of functions
Test Coverage
Aim for high test coverage across all components:
Core functionality should have near 100% coverage
Edge cases should be thoroughly tested
Error handling should be verified
Performance-critical paths should have benchmarks
Running Tests
Julia Tests
Unit and integration tests for the Julia backend are located in /julia/test
.
Julia Test Organization
Tests in the Julia backend are organized by module:
/julia/test/test_agent_system.jl
: Tests for the agent system/julia/test/test_swarm_manager.jl
: Tests for swarm functionality/julia/test/test_bridge.jl
: Tests for bridge functionality/julia/test/test_storage.jl
: Tests for storage functionality/julia/test/test_wallet.jl
: Tests for wallet functionality
Node.js/TypeScript Tests
Tests for Node.js packages (CLI, framework, wallets, bridges) are organized by package and run using Jest.
TypeScript Test Organization
Tests in TypeScript packages follow this structure:
/packages/framework/tests/
: Tests for the frameworkagents.test.ts
: Tests for agent functionalityswarms.test.ts
: Tests for swarm functionalitybridge.test.ts
: Tests for bridge functionalitywallet.test.ts
: Tests for wallet functionality
Python Tests
Tests for the Python wrapper are located in /packages/python-wrapper/tests/
.
Python Test Organization
Python tests are organized by module:
/packages/python-wrapper/tests/test_agents.py
: Tests for agent functionality/packages/python-wrapper/tests/test_swarms.py
: Tests for swarm functionality/packages/python-wrapper/tests/test_bridge.py
: Tests for bridge functionality/packages/python-wrapper/tests/test_wallet.py
: Tests for wallet functionality/packages/python-wrapper/tests/test_langchain.py
: Tests for LangChain integration
Writing Effective Tests
Julia Test Best Practices
TypeScript Test Best Practices
Python Test Best Practices
Debugging
Julia Backend
Logging
JuliaOS uses the Julia Logging
module for structured logging. Logs are written to:
/julia/logs/server.log
: Main server log/julia/logs/error.log
: Error log/julia/logs/debug.log
: Debug log (when debug logging is enabled)
To configure logging levels, edit /julia/config/config.toml
:
Using the Julia Debugger
JuliaOS supports debugging with Debugger.jl
:
Remote Debugging
For debugging the running server:
Start the server with debugging enabled:
Connect to the running process using VS Code Julia extension or another IDE with Julia debugging support.
Node.js/TypeScript Packages
Console Logging
Use structured logging with different levels:
Using Node Inspector
Debug Node.js applications using the built-in inspector:
Then connect using:
Chrome DevTools: Navigate to
chrome://inspect
and click "Open dedicated DevTools for Node"VS Code: Use the JavaScript Debug Terminal or create a launch configuration
VS Code Launch Configuration
Create a .vscode/launch.json
file:
Python Wrapper
Python Logging
Use Python's built-in logging module:
Using Python Debugger
Use the built-in pdb
module:
VS Code Python Debugging
Create a .vscode/launch.json
file:
Troubleshooting Common Issues
Julia Backend Issues
Package Dependency Problems
Symptoms: UndefVarError
, missing modules, version conflicts
Solutions:
Server Connection Issues
Symptoms: Cannot connect to Julia server, connection refused
Solutions:
Verify the server is running:
Check the server port configuration in
.env
andconfig.toml
Ensure no firewall is blocking the connection
Check server logs for errors:
Memory or Performance Issues
Symptoms: Slow response times, high memory usage, crashes
Solutions:
Check resource usage:
Analyze garbage collection with logging:
Use the
Profile
module to identify bottlenecks:
Node.js/TypeScript Issues
Bridge Connection Problems
Symptoms: Cannot connect to Julia backend, timeout errors
Solutions:
Verify the Julia server is running
Check connection settings in the bridge configuration:
Check for network issues between client and server
TypeScript Compilation Errors
Symptoms: Build errors, type errors
Solutions:
Check for type errors:
Clean and rebuild:
Update dependencies if needed:
Python Wrapper Issues
Installation Problems
Symptoms: Import errors, missing dependencies
Solutions:
Reinstall the package in development mode:
Check for Python version compatibility (requires Python 3.8+)
Install with all optional dependencies:
Async Runtime Errors
Symptoms: Event loop errors, coroutine issues
Solutions:
Ensure proper async/await usage:
Check for mixing async and sync code incorrectly
Performance Profiling
Julia Profiling
Node.js Profiling
Python Profiling
Continuous Integration
JuliaOS uses GitHub Actions for continuous integration. The workflow includes:
Linting: Check code style and formatting
Type Checking: Verify TypeScript types
Unit Tests: Run tests for all components
Integration Tests: Test component interactions
Build Verification: Ensure all packages build correctly
To run CI checks locally before committing: