feat(ticket): implement LoadTestTicketDatasetService for generating load test datasets

- Added LoadTestTicketDatasetService to prepare disposable scanner tickets and generate a Postman importable dataset.
- Introduced console command `load-test🎟️prepare` for executing the dataset preparation.
- Updated README documentation with usage instructions for the load test command.
- Enhanced Postman collection generation script to include new parameters.
- Created tests for the load test command to ensure proper functionality and validation.
This commit is contained in:
2026-09-03 14:15:23 -03:00
parent 900ef6cf98
commit 703158bd06
6 changed files with 1097 additions and 152 deletions

View File

@@ -11,7 +11,7 @@ declare(strict_types=1);
$root = dirname(__DIR__);
chdir($root);
$command = escapeshellarg(PHP_BINARY).' artisan route:list --path=api --json';
$command = escapeshellarg(PHP_BINARY).' artisan route:list --json';
$routeJson = shell_exec($command);
if (! is_string($routeJson) || trim($routeJson) === '') {
@@ -20,6 +20,11 @@ if (! is_string($routeJson) || trim($routeJson) === '') {
}
$routes = json_decode($routeJson, true, flags: JSON_THROW_ON_ERROR);
$routes = array_values(array_filter(
$routes,
fn (array $route): bool => str_starts_with($route['uri'], 'api/')
|| $route['uri'] === 'auth/google/redirect',
));
const TINY_PNG = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==';
@@ -177,6 +182,10 @@ function bodyFor(string $method, string $uri): ?array
function queryFor(string $uri): array
{
return match ($uri) {
'auth/google/redirect' => [
['key' => 'tenant', 'value' => '{{tenant_code}}'],
['key' => 'return_url', 'value' => '{{storefront_url}}'],
],
'api/tenants/bootstrap' => [['key' => 'dominio', 'value' => '{{tenant_domain}}'], ['key' => 'path', 'value' => '/']],
'api/v1/adminapp/bootstrap/{dominio}', 'api/v1/scanner/bootstrap/{dominio}' => [['key' => 'path', 'value' => '/']],
'api/tenants/{tenant:codigo}/catalog-items' => [['key' => 'q', 'value' => 'demo'], ['key' => 'page', 'value' => '1']],
@@ -415,6 +424,7 @@ foreach ($tree as $section => $folders) {
$variables = [
'base_url' => 'http://localhost:8000',
'storefront_url' => 'http://localhost:4200',
'token' => '', 'admin_token' => '', 'scanner_token' => '',
'user_email' => 'usuario@example.com', 'user_password' => 'Password!123',
'admin_email' => 'admin@example.com', 'admin_password' => 'Password!123',