Skip to content

Conversation

@acelaya
Copy link
Member

@acelaya acelaya commented Jul 23, 2025

Part of #1009

Add necessary configuration to run API tests with a different server config, and one test using it as a proof of concept.

The process works as follows:

  1. Tests with the #[WithEnvVars([...])] attribute will cause the RoadRunner server to be restarted including the list of env vars.
  2. Once the test has been run, the server will be restarted again without those env vars.

For this to work, this PR defines a PHPUnit extension that registers two listeners.

  • One listener runs before tests, checking if the attribute is set. If so, it creates a temp env vars file, and restarts the RoadRunner server.
  • The other listener runs after every test. If the env vars temp file exists, it deletes it and restarts the server again, so that following tests do not run with the env vars from previous test.

@codecov
Copy link

codecov bot commented Jul 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.89%. Comparing base (1c38ab1) to head (8892407).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #2468      +/-   ##
=============================================
+ Coverage      93.61%   95.89%   +2.27%     
  Complexity      1760     1760              
=============================================
  Files            279      279              
  Lines           6012     6012              
=============================================
+ Hits            5628     5765     +137     
+ Misses           384      247     -137     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@acelaya
Copy link
Member Author

acelaya commented Jul 24, 2025

These changes seem to be working consistently in CI, but in my local dev env the tests are very flaky, or they even make other tests fail even if the env-specific tests pass.

I'm still not sure what's the reason. It feels like something is "cached" and the wrong env vars are loaded, or perhaps it's a timing issue, although I have tried adding some sleep calls and it doesn't seem to help.

Another thing that could be causing this is that an env var is set, and then reloading the server, even if the env vars file is no longer present, does not reset previously "promoted" env vars simply because the process is still running. I need to verify if this is the case.

@acelaya acelaya force-pushed the feature/server-config-api-tests branch from 7773102 to 8892407 Compare October 17, 2025 08:06
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