Chained Multi-Domain Workflows
Welcome to the Chained Multi-Domain Workflows documentation!
While unit tests isolate individual functions, true integration testing verifies that independent microservices can communicate correctly in production. Rumour excels at orchestrating these multi-domain workflows by seamlessly passing state from one API boundary to another.
In this example, we will simulate an e-commerce checkout flow spanning three different microservices: a Users API, an Inventory API, and a Payments API.
1. The Scenario Structure
First, initialize a workspace and scaffold a collection:
rumour init chained_examples
cd chained_examples
rumour new ecommerce_integration -y
Assume we have our integration test folder set up like this:
ecommerce_integration/requests/
├── 1_register_user.toml
├── 2_reserve_inventory.toml
└── 3_process_payment.toml
Our environment file points to the three distinct microservices (in this mock environment, they all run locally on the gateway):
workspace.env.toml:
users_api = "http://localhost:4000/api/v2"
inventory_api = "http://localhost:4000/api/v2/inventory"
payments_api = "http://localhost:4000/api/v2/payments"
2. Defining the Workflow
Step 1: User Registration
First, we interact with the Users API to create a new customer.
1_register_user.toml:
name = "Register Customer"
[request]
method = "POST"
url = "{{users_api}}/auth/register"
[body]
type = "json"
raw = '{"email": "customer_{{random}}@swahira.io", "password": "secure123"}'
[extract]
customer_id = "user.id"
[assert]
status = 201
Step 2: Inventory Reservation
Next, we interact with the Inventory API. We must wait for customer_id from the previous step to attach the reservation to the correct user.
2_reserve_inventory.toml:
name = "Reserve Product"
[dependencies]
"1_register_user.toml" = "customer_id"
[request]
method = "POST"
url = "{{inventory_api}}/reserve"
[body]
type = "json"
raw = '{"customer_id": "{{customer_id}}", "product_sku": "SWA-PRO-1"}'
[extract]
reservation_id = "reservation_id"
total_amount = "price"
[assert]
status = 200
Step 3: Payment Processing
Finally, we call the Payments API. This node requires two dependencies: it needs the customer_id from Step 1, and the reservation_id and total_amount from Step 2.
3_process_payment.toml:
name = "Process Checkout"
[dependencies]
"1_register_user.toml" = "customer_id"
"2_reserve_inventory.toml" = ["reservation_id", "total_amount"]
[request]
method = "POST"
url = "{{payments_api}}/charge"
[body]
type = "json"
raw = '{"customer_id": "{{customer_id}}", "reservation_id": "{{reservation_id}}", "amount": {{total_amount}}}'
[assert]
status = 200
"payment_status" = { equal = "SUCCESS" }
3. Workflow Execution
When you execute this suite, Rumour automatically connects the dots across the different API domains, transferring the output of one microservice into the payload of the next.
rumour run ./ecommerce_integration/requests/ -v
Execution Trace
POST http://localhost:4000/api/v2/auth/register
URL: http://localhost:4000/api/v2/auth/register
Body (json): {"email": "customer_b4d51cb6@swahira.io", "password": "secure123"}
✓ SUCCESS: ./1_register_user.toml (10ms)
POST http://localhost:4000/api/v2/inventory/reserve
URL: http://localhost:4000/api/v2/inventory/reserve
Body (json): {"customer_id": "4", "product_sku": "SWA-PRO-1"}
✓ SUCCESS: ./2_reserve_inventory.toml (5ms)
POST http://localhost:4000/api/v2/payments/charge
URL: http://localhost:4000/api/v2/payments/charge
Body (json): {"customer_id": "4", "reservation_id": "RES-338", "amount": 99.99}
✓ SUCCESS: ./3_process_payment.toml (5ms)
╭──────────────────────────────────────────────────────────────────────────╮
│ RUMOUR EXECUTION REPORT │
├──────────────────────────────────────────────────────────────────────────┤
│ Total Requests: 3 │
│ Successful: 3 │
│ Failed: 0 │
│ Skipped: 0 │
│ Success Rate: 100.0% │
│ Total Time: 34ms │
╰──────────────────────────────────────────────────────────────────────────╯
✓ Successful Requests:
- ./1_register_user.toml [201] [14ms]
- ./2_reserve_inventory.toml [200] [7ms]
- ./3_process_payment.toml [200] [12ms]
Actionable Recommendations:
→ Run with --json to export this report for your CI/CD pipeline.
By chaining workflows in this manner, you can simulate incredibly complex, asynchronous business logic in a readable, maintainable format.