Skip to content

Démarre httpbin pour les tests fonctionnels - #2443

Draft
stakovicz wants to merge 1 commit into
afup:masterfrom
stakovicz:chore/test-functional-httpbin
Draft

stakovicz wants to merge 1 commit into
afup:masterfrom
stakovicz:chore/test-functional-httpbin

Conversation

@stakovicz

Copy link
Copy Markdown
Member

Lié à #2441 (dépréciations avant Symfony 8).

Problème

En test, SLACK_URL vaut http://httpbin:8080/status/200 (voir .env.dist). Pourtant, les cibles make test-functional, test-functional-no-js et test-functional-js ne démarrent que dbtest, apachephptest et mailcatcher. Elles servent aussi en CI.

Chaque notification Slack échouait donc. C'est le cas par exemple au vote d'un talk (vote_new), qui notifie Slack dans un listener kernel.terminate :

request.CRITICAL: Uncaught PHP Exception Symfony\Component\HttpClient\Exception\TransportException:
"Could not resolve host: httpbin for "http://httpbin:8080/status/200"."

Comme l'exception arrive après l'envoi de la réponse, Symfony essaie d'envoyer une réponse d'erreur et déclenche cette dépréciation :

Since symfony/http-foundation 7.4: Trying to use "Symfony\Component\HttpFoundation\Response::sendHeaders()"
after headers have already been sent is deprecated and will throw a PHP warning in 8.0.

Les scénarios passaient quand même, parce que la réponse était déjà partie. L'erreur ne se voyait que dans les logs.

Changement

httpbin est ajouté aux stop / up -d des trois cibles test-functional* du Makefile. L'image est tirée telle quelle, sans build, donc rien à changer côté CI.

Vérification

J'ai lancé VoteVisiteur.feature et Cfp.feature avec httpbin démarré :

  • http_client.INFO: Response: "200 http://httpbin:8080/status/200" ;
  • plus aucun Could not resolve host.

Hors périmètre

Le même problème peut se produire en prod si Slack est injoignable : une exception dans kernel.terminate. Ce sera traité à part, en rendant SlackNotifier::sendMessage() tolérant aux erreurs de transport.

SLACK_URL pointe sur httpbin, qui n'était pas démarré : chaque
notification Slack levait une TransportException dans kernel.terminate.

Refs afup#2441
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant