Important
CI/CD Pipeline Note: The CI build for this project is intentionally configured to fail.
This is by design to demonstrate the Agentic Self-Healing Hook.
The suite includes a negative test scenario (Attempt to create an invalid order) that triggers a failure, which in turn showcases the framework's ability to automatically scrape and report database error logs directly in the CI console.
A production-grade Ruby Order Management API secured with Keycloak/JWT, featuring an 'Agentic' BDD automation framework that auto-extracts database error logs upon test failure.
This is a complete, high-level Ruby ecosystem featuring:
- Structured REST API: A Sinatra-based Order Management service with custom JWT/OAuth2 AuthMiddleware and PostgreSQL persistence.
- Security Emulation: A dedicated
auth_mockservice that generates cryptographically signed JWTs, simulating a real-world Keycloak issuer. - Agentic BDD Framework: A Cucumber-based automation suite with a self-healing
Afterhook that proactively retrieves PostgreSQL error logs on failure for instant root-cause analysis. - Full Orchestration: Entire stack (API, Auth Mock, DB, and Tests) containerized via Docker Compose for seamless E2E execution.
The system is composed of several micro-services orchestrated via Docker Compose:
- Order API (
order_api/): A Sinatra-based RESTful service.- Security: Uses custom
AuthMiddlewareto validate JWT Bearer tokens. - Persistence: Connects to PostgreSQL to store order records.
- Logging: Implements a structured error logging mechanism into a dedicated DB table for observability.
- Security: Uses custom
- Auth Mock (
auth_mock/): Emulates a Keycloak OIDC issuer.- Generates cryptographically signed JWTs (HS256) for client credentials flow.
- PostgreSQL: Central database for orders and logs.
- Cucumber Tests (
features/): High-level BDD specifications.- ApiClient: Reusable Faraday wrapper with automated token injection.
- DbHelper: Direct SQL verification of API side-effects.
- Agentic Self-Healing Hook: An
Afterhook that automatically extracts DB error logs upon test failure for immediate root-cause analysis.
- Language: Ruby 3.2
- API Framework: Sinatra
- Web Server: Puma
- Database: PostgreSQL
- Testing: Cucumber, RSpec-Expectations, Faraday
- Containerization: Docker, Docker Compose
- Docker & Docker Compose
To spin up the entire environment and execute the BDD suite, simply run:
docker-compose up --build --exit-code-from testsThis will:
- Initialize the database via
init.sql. - Start the Auth Mock and Order API.
- Run the Cucumber tests and output results to the console.
If a test scenario fails, the framework automatically queries the error_logs table in PostgreSQL. It captures the specific error message and payload details injected by the API during the failure and appends it to the test report. This eliminates the need to manually check logs or DB state during debugging.
.
├── auth_mock/ # Keycloak Emulation
├── order_api/ # Order Management Service
│ ├── controllers/
│ └── lib/
├── features/ # BDD Specifications
│ ├── step_definitions/
│ └── support/ # Helpers & Hooks
├── lib/ # Shared Test Components
├── init.sql # DB Schema
└── docker-compose.yml # Infrastructure Orchestration