Skip to content

Add infra necessary to run API tests with specific server config#2468

Draft
acelaya wants to merge 4 commits into
shlinkio:developfrom
acelaya-forks:feature/server-config-api-tests
Draft

Add infra necessary to run API tests with specific server config#2468
acelaya wants to merge 4 commits into
shlinkio:developfrom
acelaya-forks:feature/server-config-api-tests

Conversation

@acelaya

@acelaya acelaya commented Jul 23, 2025

Copy link
Copy Markdown
Member

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

codecov Bot commented Jul 23, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.77%. Comparing base (53ac79e) to head (11fa0a1).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #2468      +/-   ##
=============================================
+ Coverage      94.21%   96.77%   +2.55%     
  Complexity      1605     1605              
=============================================
  Files            273      273              
  Lines           5017     5017              
=============================================
+ Hits            4727     4855     +128     
+ Misses           290      162     -128     

☔ View full report in Codecov by Harness.
📢 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

acelaya commented Jul 24, 2025

Copy link
Copy Markdown
Member Author

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
@acelaya acelaya force-pushed the feature/server-config-api-tests branch from 8892407 to e2ebae9 Compare June 10, 2026 17:26
@acelaya acelaya force-pushed the feature/server-config-api-tests branch from fd8dbcd to 11fa0a1 Compare June 11, 2026 08:35
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