Skip to content

test(e2e): run invoice edit flows with credits enabled - #4589

Merged
turip merged 3 commits into
mainfrom
feat/invoice-edit-etoe
Jun 28, 2026
Merged

test(e2e): run invoice edit flows with credits enabled#4589
turip merged 3 commits into
mainfrom
feat/invoice-edit-etoe

Conversation

@turip

@turip turip commented Jun 28, 2026

Copy link
Copy Markdown
Member

Summary

This is a chore PR that enables credits by default for the e2e runtime and keeps quickstart aligned with that default.

The legacy credits-disabled checks stay covered, but they now live in an explicit compatibility package that runs after the default e2e suite.

Changes

  • Enable credits and credit-then-invoice in the default e2e config.
  • Enable credits and credit-then-invoice in quickstart config.
  • Split credits-disabled compatibility checks into e2e/creditsdisabled.
  • Run the default e2e suite first, then restart the stack with credits disabled for compatibility checks.
  • Add the billing worker to the e2e compose stack and readiness checks.
  • Add a credits-enabled assertion that new customers receive required ledger accounts.

Why

Credits are becoming the default billing runtime. The e2e stack should exercise that path by default, while still preserving temporary pre-credit compatibility coverage until the credits-disabled mode can be removed.

Summary by CodeRabbit

  • New Features

    • Credits are now enabled by default in the main setup, including “credit then invoice” behavior.
    • Added support for an additional billing worker in local and CI environments.
  • Bug Fixes

    • Improved health checks to wait for both core services before running tests.
    • Added coverage for credit-disabled upgrade and settlement scenarios.
  • Documentation

    • Added guidance for the temporary credits-disabled compatibility test suite.

@turip
turip requested a review from a team as a code owner June 28, 2026 06:53
@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Splits e2e execution into credits-enabled and credits-disabled phases, adds billing-worker compose support, enables credits in default configs, moves compatibility tests into a new package, adds settlement-mode and ledger-account coverage, and removes the moved settlement test from the main e2e file.

Changes

Credits E2E Split and Billing Worker Infrastructure

Layer / File(s) Summary
Billing-worker compose service and credits-disabled override
e2e/docker-compose.openmeter.yaml, e2e/docker-compose.openmeter-local.yaml, e2e/docker-compose.credits-disabled.yaml
Adds the billing-worker service to production and local compose files, and introduces a docker-compose override that disables credits across openmeter, sink-worker, and billing-worker.
Enable credits in default configs
e2e/config.yaml, quickstart/config.yaml
Changes the default e2e and quickstart credits settings to enabled, with enableCreditThenInvoice set to true in both configs.
CI and local e2e orchestration
.github/workflows/ci.yaml, e2e/Makefile
Splits local e2e execution into base and credits-disabled targets, adds extra compose file support, expands readiness checks to both worker endpoints, and changes CI to run base tests, restart compose with the credits-disabled override, then run credits-disabled tests.
creditsdisabled test package setup and migration
e2e/creditsdisabled/README.md, e2e/creditsdisabled/setup_test.go, e2e/creditsdisabled/ledger_backfill_test.go
Adds the creditsdisabled package README and helpers, changes the ledger backfill test package and helper calls, and updates its docker compose working directory.
Settlement mode tests under credits-disabled
e2e/creditsdisabled/settlement_mode_test.go
Adds TestSettlementMode with subtests that reject credit_only paths and accept credit_then_invoice paths while credits are disabled.
Ledger account creation e2e test
e2e/ledger_accounts_test.go
Adds a customer ledger-account verification test and the Postgres helper functions it uses to resolve namespaces, customer mappings, and business account ids.
Pending invoice progression test
e2e/billinginvoices_v3_test.go
Updates the pending invoice test data setup and switches invoice advancement to poll for a non-gathering invoice instead of invoking the pending-lines action directly.
Remove TestSettlementMode from productcatalog_test.go
e2e/productcatalog_test.go
Deletes TestSettlementMode and its gofakeit import from the main e2e test file.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • openmeterio/openmeter#4044: The new credits-disabled settlement-mode tests directly exercise the credit_only vs credit_then_invoice validation behavior from that PR.
  • openmeterio/openmeter#4136: The config and compose changes here wire the EnableCreditThenInvoice behavior that PR introduced.
  • openmeterio/openmeter#4193: The moved ledger backfill test still exercises the openmeter-jobs ledger backfill-accounts path introduced there.

Suggested labels

release-note/feature

Suggested reviewers

  • tothandras
  • borbelyr-kong
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and matches the main change: e2e invoice-edit coverage now runs with credits enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/invoice-edit-etoe

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@turip turip added area/billing release-note/misc Miscellaneous changes labels Jun 28, 2026
@greptile-apps

greptile-apps Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR makes credits the default e2e runtime while keeping credits-disabled compatibility coverage. The main changes are:

  • Enable credits and credit-then-invoice in e2e and quickstart config.
  • Add the billing worker to the e2e compose stack and readiness checks.
  • Split base and credits-disabled e2e test runs in CI and local Make targets.
  • Move credits-disabled settlement and ledger backfill tests into a dedicated package.
  • Add coverage for ledger accounts on newly created customers.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
.github/workflows/ci.yaml Adds billing-worker overrides, waits for both workers with failing health probes, and runs base then credits-disabled e2e tests.
e2e/Makefile Splits local e2e runs into base and credits-disabled targets and checks both worker health endpoints.
e2e/docker-compose.openmeter.yaml Adds the billing-worker service to the e2e compose stack.
e2e/docker-compose.credits-disabled.yaml Adds credits-disabled environment overrides for the e2e services.
e2e/config.yaml Enables credits and credit-then-invoice for the default e2e suite.
quickstart/config.yaml Aligns quickstart with the credits-enabled default.
e2e/creditsdisabled/settlement_mode_test.go Moves credits-disabled settlement-mode compatibility checks into a dedicated package.
e2e/creditsdisabled/ledger_backfill_test.go Moves ledger backfill compatibility coverage into the credits-disabled package.
e2e/ledger_accounts_test.go Adds coverage that new customers receive the expected ledger accounts.
e2e/billinginvoices_v3_test.go Updates invoice flow coverage to wait for the billing worker path under credits-enabled defaults.

Reviews (7): Last reviewed commit: "test: use stdlib invoice search helper" | Re-trigger Greptile

Comment thread .github/workflows/ci.yaml Outdated
Comment thread e2e/Makefile Outdated
@turip

turip commented Jun 28, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/ci.yaml:
- Around line 799-803: The worker readiness checks in the CI workflow use curl
in the wait steps without failing on non-2xx HTTP responses, so a 503 from
/healthz can still pass. Update the curl commands in the wait-for-ready steps to
include --fail alongside the existing retry options, and apply the same change
to both readiness blocks so the tests only proceed once the workers are actually
healthy.

In `@e2e/creditsdisabled/settlement_mode_test.go`:
- Around line 69-94: The negative settlement-mode checks in the credits-disabled
tests only assert HTTP 400, so they can pass for the wrong validation path.
Update the relevant assertions in the custom subscription test in
settlement_mode_test.go (and the other credits-disabled cases it matches) to
verify the response body/error detail contains "credits are not enabled on this
deployment of OpenMeter" using the existing CreateSubscriptionWithResponse flow,
so the guard in CreateSubscription is explicitly covered.

In `@e2e/creditsdisabled/setup_test.go`:
- Around line 46-57: The helper is assuming the 201 response body always decodes
into resp.JSON201 and its UsageAttribution field, which can panic if the payload
is empty or malformed. In the setup helper that calls
client.UpsertUsageAttributionWithResponse, add require.NotNil checks for
resp.JSON201 and resp.JSON201.UsageAttribution before accessing SubjectKeys, and
keep the existing status/assertion flow so failures stay readable.

In `@e2e/ledger_accounts_test.go`:
- Around line 32-38: The current assertion in the ledger_accounts_test.go flow
only verifies that business accounts exist after customer creation, but it does
not prove they were provisioned by that create path. Update the test around
getBusinessAccountIDs and the customer-create call to either use an isolated
namespace or capture a before/after snapshot of ledger.BusinessAccountTypes so
the test asserts a real delta for the new customer provisioning path. Keep the
existing account-type checks, but make them validate the accounts were created
by this specific test scenario rather than preexisting state.

In `@e2e/Makefile`:
- Around line 59-63: The wait-local target uses curl health checks that can
succeed on 4xx/5xx, so the suite may continue before services are actually
ready. Update both readiness probe commands in the wait-local rule to use curl’s
failure-on-HTTP-error behavior so non-2xx responses keep retrying. Keep the
change localized to the wait-local target and preserve the existing
retry/timeouts.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d5b145ea-50f5-450d-9831-ffbb30716b07

📥 Commits

Reviewing files that changed from the base of the PR and between dec8777 and cacc75b.

📒 Files selected for processing (13)
  • .github/workflows/ci.yaml
  • e2e/Makefile
  • e2e/config.yaml
  • e2e/creditsdisabled/README.md
  • e2e/creditsdisabled/ledger_backfill_test.go
  • e2e/creditsdisabled/settlement_mode_test.go
  • e2e/creditsdisabled/setup_test.go
  • e2e/docker-compose.credits-disabled.yaml
  • e2e/docker-compose.openmeter-local.yaml
  • e2e/docker-compose.openmeter.yaml
  • e2e/ledger_accounts_test.go
  • e2e/productcatalog_test.go
  • quickstart/config.yaml
💤 Files with no reviewable changes (1)
  • e2e/productcatalog_test.go

Comment thread .github/workflows/ci.yaml
Comment thread e2e/creditsdisabled/settlement_mode_test.go
Comment thread e2e/creditsdisabled/setup_test.go
Comment thread e2e/ledger_accounts_test.go
Comment thread e2e/Makefile Outdated
@turip
turip force-pushed the feat/invoice-edit-etoe branch 2 times, most recently from 57d94db to f4c9c51 Compare June 28, 2026 07:06

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@e2e/Makefile`:
- Around line 31-47: The teardown in the test-local-credits-disabled and
test-local-base targets only runs after successful commands, so failures in
wait-local or the test targets leave the compose stack running. Update these
Makefile targets to use a single shell flow with an EXIT trap or equivalent
always-run cleanup so env-local-down is executed even when setup or tests fail.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: eb9dda33-0fa7-47f4-a419-3b6b24fb91de

📥 Commits

Reviewing files that changed from the base of the PR and between 57d94db and f4c9c51.

📒 Files selected for processing (14)
  • .github/workflows/ci.yaml
  • e2e/Makefile
  • e2e/billinginvoices_v3_test.go
  • e2e/config.yaml
  • e2e/creditsdisabled/README.md
  • e2e/creditsdisabled/ledger_backfill_test.go
  • e2e/creditsdisabled/settlement_mode_test.go
  • e2e/creditsdisabled/setup_test.go
  • e2e/docker-compose.credits-disabled.yaml
  • e2e/docker-compose.openmeter-local.yaml
  • e2e/docker-compose.openmeter.yaml
  • e2e/ledger_accounts_test.go
  • e2e/productcatalog_test.go
  • quickstart/config.yaml
💤 Files with no reviewable changes (1)
  • e2e/productcatalog_test.go
✅ Files skipped from review due to trivial changes (4)
  • e2e/creditsdisabled/README.md
  • e2e/billinginvoices_v3_test.go
  • e2e/docker-compose.credits-disabled.yaml
  • e2e/config.yaml
🚧 Files skipped from review as they are similar to previous changes (8)
  • quickstart/config.yaml
  • e2e/docker-compose.openmeter-local.yaml
  • e2e/creditsdisabled/ledger_backfill_test.go
  • e2e/creditsdisabled/setup_test.go
  • .github/workflows/ci.yaml
  • e2e/creditsdisabled/settlement_mode_test.go
  • e2e/docker-compose.openmeter.yaml
  • e2e/ledger_accounts_test.go

Comment thread e2e/Makefile Outdated
@turip
turip force-pushed the feat/invoice-edit-etoe branch from f4c9c51 to 46eaab4 Compare June 28, 2026 07:12

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
e2e/billinginvoices_v3_test.go (1)

201-203: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Prefer slices.IndexFunc here (and the same pattern below).
This is just a simple scan, so the stdlib helper fits better than lo.Find; lo can stay focused on the pointer helpers in this test.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e/billinginvoices_v3_test.go` around lines 201 - 203, Replace the `lo.Find`
scan in the invoice test with the standard library helper `slices.IndexFunc`,
and apply the same change to the matching search pattern elsewhere in this test.
Update the surrounding logic in `billinginvoices_v3_test.go` so it uses the
returned index to access the item instead of relying on `foundStandard`, keeping
`lo` only for the pointer helpers used in this test.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@e2e/billinginvoices_v3_test.go`:
- Around line 201-203: Replace the `lo.Find` scan in the invoice test with the
standard library helper `slices.IndexFunc`, and apply the same change to the
matching search pattern elsewhere in this test. Update the surrounding logic in
`billinginvoices_v3_test.go` so it uses the returned index to access the item
instead of relying on `foundStandard`, keeping `lo` only for the pointer helpers
used in this test.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e0cc9a90-a030-4e34-9e82-4589da7d9015

📥 Commits

Reviewing files that changed from the base of the PR and between 46eaab4 and 78f7767.

📒 Files selected for processing (1)
  • e2e/billinginvoices_v3_test.go

Base automatically changed from feat/flat-fee-line-create-overrides to main June 28, 2026 11:44
@turip
turip force-pushed the feat/invoice-edit-etoe branch from 7148e87 to 2a9dc06 Compare June 28, 2026 11:47
@turip
turip enabled auto-merge (squash) June 28, 2026 11:49
@turip
turip merged commit 8edef47 into main Jun 28, 2026
29 checks passed
@turip
turip deleted the feat/invoice-edit-etoe branch June 28, 2026 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants