Skip to content

test(lago): replace the docker-dependent case with a mock endpoint - #13716

Open
AlinsRan wants to merge 2 commits into
apache:masterfrom
AlinsRan:test/restore-lago-schema-tests
Open

test(lago): replace the docker-dependent case with a mock endpoint#13716
AlinsRan wants to merge 2 commits into
apache:masterfrom
AlinsRan:test/restore-lago-schema-tests

Conversation

@AlinsRan

@AlinsRan AlinsRan commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

What this PR does

t/plugin/lago.t has been skipped as a whole file since #12903 (plan(skip_all)), leaving the lago plugin with no test-nginx coverage. The file has two cases:

  • TEST 1 — plain check_schema validation, no network, no docker. It was never the problem, just collateral damage of the file-level skip.
  • TEST 2 — ran pnpm test plugin/lago.spec.mts, which cloned getlago/lago over the network and brought up its docker compose stack. That is the actual flake (help request: Lago CI test failed to execute #12904).

This restores the schema tests and replaces the real-stack case with a deterministic one: a mock of Lago's batch endpoint (POST /api/v1/events/batch) in t/lib/server.lua records what the plugin sends, and the route drives one event through it.

Fixes #12904

Why this over just skipping TEST 2

The real-stack test provides zero value while skipped, and its flake is inherent to cloning a third-party repo plus booting a multi-container stack wrapped in test-nginx --- exec. A mock removes those dependencies entirely and runs on every PR, while covering the plugin's actual contract:

  • the default /api/v1/events/batch endpoint is used
  • Authorization: Bearer <token> is set
  • the event carries code / external_subscription_id / transaction_id
  • the ${var} templates are resolved (${status}200)

Coverage note

What the mock does not cover is that the real Lago API accepts the payload — contract drift. That is better caught by an optional non-gating nightly job against the real stack than by a per-PR test that blocks unrelated merges, and it provided no such coverage while skipped anyway.

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jul 20, 2026
lago.t was skipped as a whole file since apache#12903, leaving the plugin with
no test-nginx coverage: TEST 1 is plain check_schema validation and was
only collateral damage of the file-level skip, while TEST 2 cloned
getlago/lago over the network and brought up its docker compose stack,
which is the actual flake.

Restore the schema tests and replace the real-stack case with a
deterministic one: a mock of Lago's batch endpoint in t/lib/server.lua
records what the plugin sends, and the route drives one event through it.
This runs on every PR with no network clone or docker, and asserts the
plugin's real contract — the /api/v1/events/batch endpoint, the bearer
token, the event fields, and that the ${var} templates are resolved.

Fixes apache#12904
@AlinsRan
AlinsRan force-pushed the test/restore-lago-schema-tests branch from bd0a8f6 to cf864c3 Compare July 29, 2026 05:55
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Jul 29, 2026
@AlinsRan AlinsRan changed the title test(lago): restore schema tests, skip only the docker-dependent case test(lago): replace the docker-dependent case with a mock endpoint Jul 29, 2026
…ago-mock-endpoint

# Conflicts:
#	t/lib/server.lua
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

help request: Lago CI test failed to execute

1 participant