1
0
Fork 0
mirror of https://github.com/archtechx/tenancy-queue-tester.git synced 2025-12-11 01:04:04 +00:00
No description
Find a file
2025-01-11 11:49:16 +01:00
cli replace all shebangs with bash 2024-12-31 07:21:22 +01:00
setup support PersistentQueueTenancyBootstrapper 2025-01-09 16:16:43 +01:00
.gitignore change perms on . instead of src, avoid using --force on laravel/installer 2024-12-31 07:08:18 +01:00
alternative_config.sh add persistence, sync, and forceRefresh assertions 2025-01-07 15:37:37 +01:00
docker-compose.yml add local dev tip comment 2025-01-11 11:49:16 +01:00
README.md add persistence, sync, and forceRefresh assertions 2025-01-07 15:37:37 +01:00
setup.sh ci: change chmod . to chmod src 2025-01-09 17:41:34 +01:00
test.sh chmod 777 temp files 2025-01-09 17:48:49 +01:00

Tenancy for Laravel queue test suite

In addition to the tests we can write using testbench, we have this repository which:

  1. Creates a new Laravel application
  2. Sets up Tenancy
  3. Creates a sample job
  4. Asserts that the queue worker is working as expected -- running in the correct context and responding to restart signals

This is mostly due to some past bugs that were hard to catch in our test suite.

With this repo, we can have a separate CI job validating queue behavior in a real application.

Persistence tests

Additionally, we can also test for queue worker persistence. This refers to the worker staying in the context of the tenant used in the last job. The benefit of that is significantly better third-party package support (especially in cases where said packages unserialize job payloads on e.g. JobProcessed).

In versions prior to v4:

  • 3.8.5 handles restarts correctly but is not persistent
  • 3.8.4 is persistent but doesn't respond to restarts correctly (if the last processed job was in the tenant context)

In v4, there's QueueTenancyBootstrapper that works similarly to 3.8.5 and PersistentQueueTenancyBootstrapper that works similarly to 3.8.4.

For the different setups:

  • 3.x should have only warns on missing persistence
    • 3.8.4 fails the restart-related assertions. The alternative config (./alternative_config.sh) makes them pass.
    • 3.8.4 fails the FORCEREFRESH-related assertions. Either run with FORCEREFRESH=0 or set QueueTenancyBootstrapper::$forceRefresh = true in a service provider.
  • 4.x should only show warns on missing persistence
    • With the alternative config, it should pass ALL tests without any warnings.

3.x (3.8.5+) tests:

./setup.sh
./test.sh

4.x tests:

./setup.sh
./test.sh

./alternative_config.sh
PERSISTENT=1 ./test.sh