laravel-chaos / testing
A Laravel package for chaos engineering: deletes random files at random times.
Fund package maintenance!
:vendor_name
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/laravel-chaos/testing
Requires
- php: ^8.0
- illuminate/contracts: ^9.0|^10.0|^11.0|^12.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.9
- laravel/pint: ^1.14
- nunomaduro/collision: ^7.0|^8.0
- orchestra/testbench: ^8.0|^9.0
- pestphp/pest: ^2.0
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
- spatie/laravel-ray: ^1.35
README
A Laravel package for chaos engineering that deletes random files at random times. Use this to test your application's resilience against data loss or file system corruption.
Warning
This package deletes files. Do not use this in production unless you are absolutely sure what you are doing and have backups.
Installation
You can install the package via composer:
composer require laravel-chaos/testing
You can publish the config file with:
php artisan vendor:publish --tag="laravel-chaos-testing-config"
This is the contents of the published config file:
return [ /* |-------------------------------------------------------------------------- | Chaos Enabled |-------------------------------------------------------------------------- | | This option controls whether the chaos command is enabled. | It is recommended to keep this disabled in production unless you | really know what you are doing. | */ 'enabled' => env('CHAOS_ENABLED', false), /* |-------------------------------------------------------------------------- | Chaos Interval |-------------------------------------------------------------------------- | | How often chaos should occur. Supported values: | - 'minute' (every minute) | - 'hour' (every hour) | - 'day' (every day) | - 'week' (every week) | - 'month' (every month) | */ 'interval' => env('CHAOS_INTERVAL', 'week'), /* |-------------------------------------------------------------------------- | Target Paths |-------------------------------------------------------------------------- | | The paths where the chaos command will look for files to delete. | */ 'paths' => [ storage_path('logs'), ], /* |-------------------------------------------------------------------------- | Target Extensions |-------------------------------------------------------------------------- | | If specified, only files with these extensions will be deleted. | Leave empty to target all files. | */ 'extensions' => [], /* |-------------------------------------------------------------------------- | Filesystem Disk |-------------------------------------------------------------------------- | | The filesystem disk to use. | */ 'disk' => 'local', ];
Usage
Once installed and enabled, the package registers a scheduled command chaos:process that runs hourly.
The command checks if it's time to "unleash chaos" based on a random schedule within your configured interval (default: once per week). If it is time, it will pick a random file from your configured paths and delete it.
Configuration
-
Set the interval in your
.env:CHAOS_ENABLED=true CHAOS_INTERVAL=week # minute, hour, day, week, or month
-
Or publish and edit the config file:
php artisan vendor:publish --tag="laravel-chaos-testing-config"
You can also run the command manually:
php artisan chaos:process
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.