Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run queue tests with Laravel 6 #504

Merged
merged 1 commit into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions features/fixtures/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ services:
published: 61258

laravel66:
init: true
build:
context: laravel66
args:
Expand Down
9 changes: 2 additions & 7 deletions features/fixtures/laravel66/.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,13 @@ APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
DB_CONNECTION=sqlite

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync
QUEUE_CONNECTION=database

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
Expand Down
3 changes: 3 additions & 0 deletions features/fixtures/laravel66/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ COPY --from=composer:2.2 /usr/bin/composer /usr/local/bin/composer
RUN composer install
RUN php artisan key:generate

# create database & apply migrations
RUN touch database/database.sqlite && php artisan migrate --no-interaction

CMD php artisan serve --port=8000 --host=0.0.0.0
26 changes: 26 additions & 0 deletions features/fixtures/laravel66/app/Jobs/HandledJob.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace App\Jobs;

use Bugsnag\BugsnagLaravel\Facades\Bugsnag;
use Exception;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class HandledJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

/**
* Execute the job.
*
* @return void
*/
public function handle()
{
Bugsnag::notifyException(new Exception('Handled :)'));
}
}
32 changes: 32 additions & 0 deletions features/fixtures/laravel66/app/Jobs/UnhandledJob.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use RuntimeException;

class UnhandledJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

public int $tries;

public function __construct(int $tries)
{
$this->tries = $tries;
}

/**
* Execute the job.
*
* @return void
*/
public function handle()
{
throw new RuntimeException('uh oh :o');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateJobsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('jobs', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('jobs');
}
}
9 changes: 9 additions & 0 deletions features/fixtures/laravel66/routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
|
*/

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

Route::get('/', function () {
Expand Down Expand Up @@ -52,6 +53,14 @@
Route::view('/handled_view_exception', 'handledexception');
Route::view('/handled_view_error', 'handlederror');

Route::get('/queue/unhandled', function (Request $request) {
\App\Jobs\UnhandledJob::dispatch((int) $request->query('tries', '1'));
});

Route::get('/queue/handled', function (Request $request) {
\App\Jobs\HandledJob::dispatch();
});

/**
* Return some diagnostics if an OOM did not happen when it should have.
*
Expand Down
6 changes: 3 additions & 3 deletions features/queues.feature
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Feature: Queue support

@not-laravel-latest @not-laravel51 @not-laravel56 @not-laravel58 @not-laravel66 @not-lumen8
@not-laravel-latest @not-laravel51 @not-laravel56 @not-laravel58 @not-lumen8
Scenario: Unhandled exceptions are delivered from queues
Given I start the laravel fixture
And I start the laravel queue worker
Expand All @@ -21,7 +21,7 @@ Scenario: Unhandled exceptions are delivered from queues
And the event "severityReason.type" equals "unhandledExceptionMiddleware"
And the event "severityReason.attributes.framework" equals "Laravel"

@not-laravel-latest @not-laravel51 @not-laravel56 @not-laravel58 @not-laravel66 @not-lumen8
@not-laravel-latest @not-laravel51 @not-laravel56 @not-laravel58 @not-lumen8
Scenario: Unhandled exceptions are delivered from queued jobs with multiple attmpts
Given I start the laravel fixture
And I start the laravel queue worker
Expand Down Expand Up @@ -78,7 +78,7 @@ Scenario: Unhandled exceptions are delivered from queued jobs with multiple attm
And the event "severityReason.type" equals "unhandledExceptionMiddleware"
And the event "severityReason.attributes.framework" equals "Laravel"

@not-laravel-latest @not-laravel51 @not-laravel56 @not-laravel58 @not-laravel66 @not-lumen8
@not-laravel-latest @not-laravel51 @not-laravel56 @not-laravel58 @not-lumen8
Scenario: Handled exceptions are delivered from queues
Given I start the laravel fixture
And I start the laravel queue worker
Expand Down