8.7 KiB
DBAL C++ Daemon Integration Test Results
Date: 2026-02-06 14:21 UTC
Location: /Users/rmac/Documents/metabuilder/dbal/production/tests/integration
Daemon Version: v1.0.0
Test Framework: pytest 9.0.2
Executive Summary
Result: 6/17 tests passing (35.3%) - MATCHES BASELINE Status: Health endpoints working, entity endpoints causing daemon crash Critical Issue: Daemon crashes on first entity endpoint request
Test Results by Category
✅ TestHealthEndpoints (6/6 PASSING - 100%)
All health, version, and status endpoints working correctly:
- ✅
test_health_endpoint_returns_200- PASSED - ✅
test_health_endpoint_json_format- PASSED - ✅
test_version_endpoint_returns_200- PASSED - ✅
test_version_endpoint_json_format- PASSED - ✅
test_status_endpoint_returns_200- PASSED - ✅
test_status_endpoint_has_server_info- PASSED
Endpoints Verified:
GET /health→{"service":"dbal","status":"healthy"}GET /version→ Returns version infoGET /status→ Returns server status with metadata
❌ TestEntityEndpoints (0/4 PASSING - 0%)
All entity tests fail with daemon crash:
-
❌
test_list_users_endpoint- DAEMON CRASH- Request:
GET /api/v1/test-tenant/core/user - Error:
RemoteDisconnected('Remote end closed connection without response') - Cause: Daemon crashes on first entity request
- Request:
-
❌
test_create_user_endpoint- DAEMON ALREADY CRASHED- Request:
POST /api/v1/test-tenant/core/user - Error:
ConnectionRefusedError: [Errno 111] Connection refused - Cause: Daemon crashed from previous test
- Request:
-
❌
test_invalid_tenant_returns_error- DAEMON ALREADY CRASHED- Request:
GET /api/v1/invalid-tenant/core/user - Error: Connection refused (daemon down)
- Request:
-
❌
test_invalid_entity_returns_error- DAEMON ALREADY CRASHED- Request:
GET /api/v1/test-tenant/core/nonexistent - Error: Connection refused (daemon down)
- Request:
❌ TestConcurrency (0/2 PASSING - 0%)
-
❌
test_concurrent_health_checks- DAEMON ALREADY CRASHED- 10 parallel requests to
/health - Error: Connection refused (daemon down from entity tests)
- 10 parallel requests to
-
❌
test_concurrent_status_checks- DAEMON ALREADY CRASHED- 10 parallel requests to
/status - Error: Connection refused (daemon down)
- 10 parallel requests to
❌ TestErrorHandling (0/3 PASSING - 0%)
-
❌
test_404_on_unknown_endpoint- DAEMON ALREADY CRASHED- Request:
GET /nonexistent - Error: Connection refused
- Request:
-
❌
test_invalid_json_in_post- DAEMON ALREADY CRASHED- Request:
POST /api/v1/test-tenant/core/userwith malformed JSON - Error: Connection refused
- Request:
-
❌
test_options_request_handling- DAEMON ALREADY CRASHED- Request:
OPTIONS /api/v1/test-tenant/core/user - Error: Connection refused
- Request:
❌ TestResponseHeaders (0/2 PASSING - 0%)
-
❌
test_content_type_json- DAEMON ALREADY CRASHED- Verify
Content-Type: application/jsonheader - Error: Connection refused
- Verify
-
❌
test_response_has_server_header- DAEMON ALREADY CRASHED- Verify
Server: dbal/1.0.0header - Error: Connection refused
- Verify
Comparison to Baseline
CLAUDE.md Baseline (Feb 5, 2026): 6/17 passing Current Result: 6/17 passing
Status: ⚠️ NO IMPROVEMENT - Same baseline failures
The baseline correctly identified the Drogon routing issue:
Blocker: Drogon route matching for
/{tenant}/{package}/{entity}- handlers implemented but not called
Root Cause Analysis
Critical Issue: Daemon Crash on Entity Requests
Symptom: Daemon process terminates immediately when receiving first entity endpoint request
Evidence:
- Health endpoints (
/health,/version,/status) work perfectly - First entity request (
GET /api/v1/test-tenant/core/user) causes:RemoteDisconnected: Remote end closed connection without response- Daemon process terminates (no longer responds to
ps aux | grep dbal)
- All subsequent tests fail with
Connection refused(daemon is down) - Daemon log shows no crash dump, just stops after "Daemon mode: Running in background"
Likely Causes:
-
Drogon Route Matching Issue (documented in CLAUDE.md):
- Pattern
/{tenant}/{package}/{entity}not matching requests - Handler is implemented but never called
- May need regex patterns or different syntax
- Pattern
-
Unhandled Exception in Route Handler:
- C++ exception thrown but not caught
- Terminates process instead of returning error response
- No try/catch blocks around handler logic
-
SQLite Adapter Initialization:
- Adapter may not be fully initialized when first request arrives
- Accessing uninitialized database connection
- Memory corruption or segfault
-
Missing YAML Schema Files:
- EntitySchemaLoader trying to load from disk
DBAL_SCHEMA_DIRenvironment variable not set- File not found exception crashes daemon
Daemon Configuration
Startup Command:
./build/dbal_daemon --bind 0.0.0.0 --port 8080 --daemon
Environment Variables (from CLAUDE.md):
DBAL_SCHEMA_DIR: Path to YAML entity schemas (REQUIRED)DBAL_TEMPLATE_DIR: Path to SQL Jinja2 templates (REQUIRED)DATABASE_URL::memory:(SQLite in-memory)
Issue: Daemon may be missing required env vars, causing schema load failure
Actionable Next Steps
Priority 1: Prevent Daemon Crash (CRITICAL)
-
Add Global Exception Handler:
try { // Route handler logic } catch (const std::exception& e) { LOG_ERROR << "Exception in route handler: " << e.what(); return error_response(500, e.what()); } -
Set Required Environment Variables:
export DBAL_SCHEMA_DIR=/workspace/dbal/shared/api/schema/entities export DBAL_TEMPLATE_DIR=/workspace/dbal/production/templates/sql ./build/dbal_daemon --bind 0.0.0.0 --port 8080 --daemon -
Enable Core Dumps:
ulimit -c unlimited ./build/dbal_daemon --bind 0.0.0.0 --port 8080(Run without
--daemonto see crash output on terminal)
Priority 2: Fix Drogon Routing (HIGH)
-
Check Drogon Path Parameter Syntax:
- Current:
app().registerHandler("/{tenant}/{package}/{entity}", ...) - Try:
app().registerHandler("/api/v1/{1}/{2}/{3}", ...) - Or:
app().registerHandler("/api/v1/(.*?)/(.*?)/(.*?)", ...)
- Current:
-
Add Route Debugging:
LOG_DEBUG << "Registering route: /api/v1/{tenant}/{package}/{entity}"; LOG_DEBUG << "Request received: " << req->path(); -
Test with Simpler Route:
app().registerHandler("/test/{tenant}", [](const HttpRequestPtr& req, std::function<void(const HttpResponsePtr&)>&& callback) { // Test if path parameters work at all }, {Get});
Priority 3: Add Logging (HIGH)
-
Log Request Entry:
LOG_INFO << "Entity list request: tenant=" << tenant << " package=" << package << " entity=" << entity; -
Log SQLite Operations:
LOG_DEBUG << "Executing SQL: " << sql_query; LOG_DEBUG << "SQLite result: " << rc; -
Run Daemon in Foreground (for debugging):
./build/dbal_daemon --bind 0.0.0.0 --port 8080 # (Remove --daemon flag to see stdout/stderr)
Priority 4: Schema Loading Verification (MEDIUM)
-
Check Schema Files Exist:
ls -la /workspace/dbal/shared/api/schema/entities/core/user.yaml ls -la /workspace/dbal/production/templates/sql/*.sql.j2 -
Test EntitySchemaLoader Standalone:
// Add test harness int main() { EntitySchemaLoader loader; auto schema = loader.loadSchema("user"); std::cout << "Loaded schema: " << schema.name << std::endl; }
Test Environment Details
Container: metabuilder-dev (dockerconan-dev)
OS: Ubuntu 22.04 (inside Docker)
Python: 3.10.12
Daemon Process: PID 22456 (until crash)
Port: 8080 (bound to 0.0.0.0)
Database: SQLite :memory:
Test Execution:
docker exec metabuilder-dev bash -c "
cd /workspace/dbal/production/tests/integration &&
pytest test_api_endpoints.py -v --tb=short
"
Conclusion
Status: Same baseline as CLAUDE.md (6/17 passing) Blocker: Daemon crashes on entity endpoint requests Impact: 65% of tests cannot run (11/17 blocked by crash)
Recommendations:
- Run daemon in foreground mode (remove
--daemon) to see crash output - Set
DBAL_SCHEMA_DIRandDBAL_TEMPLATE_DIRenvironment variables - Add try/catch exception handlers to all route handlers
- Investigate Drogon path parameter syntax for wildcard routes
- Enable core dumps or run under
gdbto get stack trace
Next Action: Debug daemon crash with foreground mode and proper env vars before attempting further fixes.