Page cover

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 framework

    • agents.test.ts: Tests for agent functionality

    • swarms.test.ts: Tests for swarm functionality

    • bridge.test.ts: Tests for bridge functionality

    • wallet.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:

  1. Start the server with debugging enabled:

  1. 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:

  1. Verify the server is running:

  2. Check the server port configuration in .env and config.toml

  3. Ensure no firewall is blocking the connection

  4. Check server logs for errors:

Memory or Performance Issues

Symptoms: Slow response times, high memory usage, crashes

Solutions:

  1. Check resource usage:

  2. Analyze garbage collection with logging:

  3. Use the Profile module to identify bottlenecks:

Node.js/TypeScript Issues

Bridge Connection Problems

Symptoms: Cannot connect to Julia backend, timeout errors

Solutions:

  1. Verify the Julia server is running

  2. Check connection settings in the bridge configuration:

  3. Check for network issues between client and server

TypeScript Compilation Errors

Symptoms: Build errors, type errors

Solutions:

  1. Check for type errors:

  2. Clean and rebuild:

  3. Update dependencies if needed:

Python Wrapper Issues

Installation Problems

Symptoms: Import errors, missing dependencies

Solutions:

  1. Reinstall the package in development mode:

  2. Check for Python version compatibility (requires Python 3.8+)

  3. Install with all optional dependencies:

Async Runtime Errors

Symptoms: Event loop errors, coroutine issues

Solutions:

  1. Ensure proper async/await usage:

  2. 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:

  1. Linting: Check code style and formatting

  2. Type Checking: Verify TypeScript types

  3. Unit Tests: Run tests for all components

  4. Integration Tests: Test component interactions

  5. Build Verification: Ensure all packages build correctly

To run CI checks locally before committing:

Additional Resources