Skip to content

FEAT: Parrallel testing#4555

Merged
AxonC merged 20 commits intoVATSIM-UK:mainfrom
MrAdder:parrallel-testing
Mar 1, 2026
Merged

FEAT: Parrallel testing#4555
AxonC merged 20 commits intoVATSIM-UK:mainfrom
MrAdder:parrallel-testing

Conversation

@MrAdder
Copy link
Copy Markdown
Contributor

@MrAdder MrAdder commented Feb 22, 2026

Fixes #4552

Summary (Update)

This update extends the previous PR with support for dedicated parallel testing via ParaTest, adds robust CTS test database handling, and minor test/factory adjustments.


🧪 Parallel Testing via ParaTest

Changes

  • Added brianium/paratest as a dev dependency.
  • php artisan test --parallel now leverages ParaTest under the hood.
  • CI workflow already updated to run 4 parallel processes with automatic test DB recreation.

Benefits

  • ⚡ Further reduces CI runtime.
  • 🧩 Ensures compatibility with PHPUnit’s parallel execution features.

🏗 CTS Testing Database Improvements

MockCtsDatabase Updates

  • Added ensureCreated():
    • Checks that the CTS database exists.
    • Only creates tables if they do not already exist.
  • recreate() now:
    • Ensures DB exists
    • Destroys all tables
    • Recreates tables
  • ensureDatabaseExists() added for explicit DB creation before table operations.
  • destroy() wrapped in try/catch to avoid exceptions if DB missing.

Benefits

  • 🛡 Makes test setup idempotent.
  • 🔁 Allows safe re-running of tests without manually dropping databases.
  • ✅ Aligns test bootstrapping (CreatesApplication) to automatically ensure the CTS DB exists.

🧱 Test Factories Adjustments

  • BaseTrainingPanelTestCase:
    • Account factory creation simplified (removed hard-coded ID).
    • Member factory still ensures the account is linked.

💻 Database Configuration Adjustments

  • config/database.php:
    • CTS database name now supports dynamic test database suffixes using TEST_TOKEN in testing environments.
    • Ensures isolation between parallel test runs.

Overall Impact

  • 🚀 Parallelized and robust test execution.
  • 🧼 Cleaner CTS test database lifecycle.
  • ⚙ Improved CI stability and test isolation.
  • 🧩 Prepares for scaling tests across multiple processes safely.

No breaking changes; purely development/test improvements.

Old Time
image

New Time
image

@MrAdder
Copy link
Copy Markdown
Contributor Author

MrAdder commented Feb 22, 2026

These are from my internal testing on my internal git server

@MrAdder MrAdder marked this pull request as ready for review February 22, 2026 15:26
@MrAdder MrAdder changed the title WIP: Parrallel testing FEAT: Parrallel testing Feb 22, 2026
Comment thread tests/Unit/Mship/HasDiscordAccountTest.php
Comment thread composer.json Outdated
Comment thread .github/workflows/test.yml
Comment thread .github/workflows/test.yml
Update Composer to lock in paratest
Fix Ambiguous change with the HasDiscordAccountTest
Explicilty uses and configures TestCase for Parallel testing
and potential fix for the HasDiscord errors
Reverted TestCase.php
@MrAdder
Copy link
Copy Markdown
Contributor Author

MrAdder commented Feb 22, 2026

All issues now resolved and Tests passing again with no issues

@AxonC
Copy link
Copy Markdown
Member

AxonC commented Mar 1, 2026

Thanks this is really helpful for our setup.

@AxonC AxonC merged commit 97a4385 into VATSIM-UK:main Mar 1, 2026
3 checks passed
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.

Parallelise phpunit tests

2 participants