You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The purchase-plan execution layer (internal/purchase/execution.go) runs each account's plan in parallel and tags execution records with cloud_account_id. Spec acceptance criterion E-2 requires that one account's failure must not fail others: if account A's credentials are invalid and account B's are valid, B's execution must complete successfully and A's must be marked failed in isolation.
The code path appears to support this (errgroup-style parallelism + per-account error capture), but it isn't covered by an automated test. Without one, an inadvertent refactor that swaps the errgroup for a serial loop, or that propagates an account-level error up the group, would silently regress the spec's central fault-tolerance promise.
Add an integration test in internal/purchase/execution_test.go (or a dedicated execution_multi_account_test.go) that:
Creates a purchase plan targeting two AWS accounts via plan_accounts: account-V with valid mock credentials, account-I with invalid mock credentials.
Executes the plan once.
Asserts two purchase_executions rows are written, one per account.
account-V's row: status=success, cloud_account_id set to V's ID, result_data non-empty.
account-I's row: status=failed, cloud_account_id set to I's ID, error message present, the error message does NOT contain credential material (regression guard for log-sanitisation).
Assert the two rows' result_data are independent (e.g., V's confirmation IDs are not present anywhere on I's row).
Assert the timestamps prove parallelism: abs(V.completed_at - I.completed_at) < 2s AND max(V.completed_at, I.completed_at) - min(V.started_at, I.started_at) < (V_duration + I_duration). (The exact bound depends on the mock latencies; pick a sentinel that fails on a serial loop but passes on errgroup.)
Out of scope
Load testing of CUDLY_MAX_ACCOUNT_PARALLELISM (separate ticket if needed).
Credential refresh failures mid-execution.
Mocking the actual AWS purchase APIs end-to-end — use the existing mock provider patterns (see internal/purchase/execution_test.go setup).
Gap
The purchase-plan execution layer (
internal/purchase/execution.go) runs each account's plan in parallel and tags execution records withcloud_account_id. Spec acceptance criterion E-2 requires that one account's failure must not fail others: if account A's credentials are invalid and account B's are valid, B's execution must complete successfully and A's must be marked failed in isolation.The code path appears to support this (errgroup-style parallelism + per-account error capture), but it isn't covered by an automated test. Without one, an inadvertent refactor that swaps the errgroup for a serial loop, or that propagates an account-level error up the group, would silently regress the spec's central fault-tolerance promise.
Spec section:
specs/multi-account-execution/acceptance.mdE-2.Acceptance criteria
Add an integration test in
internal/purchase/execution_test.go(or a dedicatedexecution_multi_account_test.go) that:plan_accounts: account-V with valid mock credentials, account-I with invalid mock credentials.purchase_executionsrows are written, one per account.status=success,cloud_account_idset to V's ID,result_datanon-empty.status=failed,cloud_account_idset to I's ID,errormessage present, the error message does NOT contain credential material (regression guard for log-sanitisation).result_dataare independent (e.g., V's confirmation IDs are not present anywhere on I's row).abs(V.completed_at - I.completed_at) < 2sANDmax(V.completed_at, I.completed_at) - min(V.started_at, I.started_at) < (V_duration + I_duration). (The exact bound depends on the mock latencies; pick a sentinel that fails on a serial loop but passes on errgroup.)Out of scope
CUDLY_MAX_ACCOUNT_PARALLELISM(separate ticket if needed).internal/purchase/execution_test.gosetup).References
specs/multi-account-execution/acceptance.mdscenario E-2internal/purchase/execution.gointernal/purchase/execution_test.gointernal/database/postgres/migrations/000011_cloud_accounts.up.sql:131-135(purchase_executions.cloud_account_id)