mirror of
https://github.com/archtechx/tenancy-queue-tester.git
synced 2025-12-12 06:44:05 +00:00
support PersistentQueueTenancyBootstrapper
This commit is contained in:
parent
6a047d3686
commit
8fabbbd58b
2 changed files with 13 additions and 2 deletions
|
|
@ -12,3 +12,7 @@ cp ../setup/alternative/database.php config/database.php
|
||||||
|
|
||||||
rm app/Providers/AppServiceProvider.php
|
rm app/Providers/AppServiceProvider.php
|
||||||
cp ../setup/alternative/AppServiceProvider.php app/Providers/AppServiceProvider.php
|
cp ../setup/alternative/AppServiceProvider.php app/Providers/AppServiceProvider.php
|
||||||
|
|
||||||
|
if [ -f vendor/stancl/tenancy/src/Bootstrappers/PersistentQueueTenancyBootstrapper.php ]; then
|
||||||
|
sed -i 's/QueueTenancyBootstrapper/PersistentQueueTenancyBootstrapper/g' config/tenancy.php
|
||||||
|
fi
|
||||||
|
|
|
||||||
11
test.sh
11
test.sh
|
|
@ -90,6 +90,8 @@ expect_worker_context() {
|
||||||
rm -f src/database.sqlite
|
rm -f src/database.sqlite
|
||||||
rm -f src/database/tenantfoo.sqlite
|
rm -f src/database/tenantfoo.sqlite
|
||||||
rm -f src/database/tenantbar.sqlite
|
rm -f src/database/tenantbar.sqlite
|
||||||
|
rm -f src/abc
|
||||||
|
rm -f src/sync_context
|
||||||
|
|
||||||
docker compose up -d redis # in case it's not running - the below setup code needs Redis to be running
|
docker compose up -d redis # in case it's not running - the below setup code needs Redis to be running
|
||||||
|
|
||||||
|
|
@ -231,6 +233,9 @@ echo
|
||||||
echo "-------- SYNC PHASE --------"
|
echo "-------- SYNC PHASE --------"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
|
# The only thing we can check here is that dispatching a job doesn't revert the context to central
|
||||||
|
# when executed synchronously.
|
||||||
|
|
||||||
docker compose run --rm queue php artisan tinker -v --execute "tenancy()->initialize('foo'); App\Jobs\FooJob::dispatchSync(); file_put_contents('sync_context', tenant() ? ('tenant_' . tenant('id')) : 'central');"
|
docker compose run --rm queue php artisan tinker -v --execute "tenancy()->initialize('foo'); App\Jobs\FooJob::dispatchSync(); file_put_contents('sync_context', tenant() ? ('tenant_' . tenant('id')) : 'central');"
|
||||||
without_queue_assertions assert_tenant_users foo 5
|
without_queue_assertions assert_tenant_users foo 5
|
||||||
without_queue_assertions assert_tenant_users bar 1
|
without_queue_assertions assert_tenant_users bar 1
|
||||||
|
|
@ -256,10 +261,12 @@ assert_tenant_users bar 2
|
||||||
assert_central_users 2
|
assert_central_users 2
|
||||||
echo "OK: User created in tenant bar"
|
echo "OK: User created in tenant bar"
|
||||||
|
|
||||||
docker compose exec -T queue php artisan tinker --execute "\$tenant = App\Models\Tenant::find('bar'); \$tenant->update(['abc' => 'def']); \$tenant->run(function () { dispatch(new App\Jobs\LogAbcJob); });"
|
EXPECTED_ABC=$(openssl rand -base64 12)
|
||||||
|
|
||||||
|
docker compose exec -T queue php artisan tinker --execute "\$tenant = App\Models\Tenant::find('bar'); \$tenant->update(['abc' => '${EXPECTED_ABC}']); \$tenant->run(function () { dispatch(new App\Jobs\LogAbcJob); });"
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
if grep -q 'def' src/abc; then
|
if grep -q $EXPECTED_ABC src/abc; then
|
||||||
echo "OK: Worker notices changes made to the current tenant outside the worker"
|
echo "OK: Worker notices changes made to the current tenant outside the worker"
|
||||||
else
|
else
|
||||||
if [ "$FORCEREFRESH" -eq 1 ]; then
|
if [ "$FORCEREFRESH" -eq 1 ]; then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue