test: stop mercure tests hitting a public hub - #8489
Merged
Conversation
The fixture app declared two mercure hubs on the same URL. The bundle registers one messenger handler per hub and both are tagged for the same Update message, so every async update was published twice: once through TestHub, which the assertions read, and once straight to demo.mercure.rocks through an unguarded hub. That third party going down turned into red PHPUnit jobs on every branch. Collapse the second hub into a plain inner service so a single handler remains, and let TestHub record without forwarding unless the dedicated mercure env asks for it. MERCURE_URL now defaults to the local hub that env's CI service already runs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Mercure tests in the general PHPUnit matrix published to the public
https://demo.mercure.rocks. When that third party hiccups, jobs go red — it caused 2 of the reds on4.3today (PHPUnit (PHP 8.3),PHPUnit (PHP 8.5) (Symfony 8.1)), and a plain re-run went green with no code change.Root cause
The fixture app declared two mercure hubs on the same URL:
MercureBundle registers one messenger handler per hub, and both are tagged
messenger.message_handlerfor the sameUpdatemessage:mercure.hub.default.message_handler→mercure.hub.default.traceable→TestHub✅mercure.hub.debug.message_handler→ realHub❌So every async mercure update was published twice — once through
TestHub(recorded, and what the assertions read) and once straight over the network through an unguarded hub.TestHubwas also a decorator rather than a fake:publish()recorded and forwarded, even though nothing anywhere consumes its return value.The
debughub existed only to beTestHub's inner; nothing targets it by name.Change
app.mercure.inner_hubservice, so a single messenger handler remains and the duplicate publish is gone.TestHubgains$publishToHub(defaultfalse): it always records, and forwards only when asked.config_mercure.yml(APP_ENV=mercure) setsapp.mercure.publish_to_hub: true, so the dedicatedPHPUnit (Mercure)job keeps real end-to-end coverage against its local hub container.MERCURE_URLnow defaults tohttp://localhost:1337/.well-known/mercure— the hub that job already runs — instead of a public URL.TestHubTestlocks the invariant in, so re-introducing forwarding fails loudly instead of going quietly flaky.No changes to
.github/workflows/ci.ymlwere needed.Two assertions hardcoded
demo.mercure.rocksand were updated. NotetestNoDiscoveryLinkOnNonMercureEndpointpreviously asserted the absence of a.../hubURL that was never emitted, so it was vacuous; it now asserts the absence of the real discovery link.Verification
tests/Functional/Mercure/+SubscriptionTest: 9 tests, 84 assertions, green fully offline (before this change they died at 22 assertions).app.mercure.publish_to_hubresolvestrueunderAPP_ENV=mercure,falseundertest.Doctrine\ODM\MongoDBclass.notFoundnoise on untouched lines).I stopped a local full-suite run partway for thermal reasons — CI is the authority on the full matrix here.