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

v1.2 2025-11-20 19:39 UTC

This package is auto-updated.

Last update: 2025-11-20 19:43:16 UTC


README

Latest Version on Packagist GitHub Tests Action Status Total Downloads

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

  1. Set the interval in your .env:

    CHAOS_ENABLED=true
    CHAOS_INTERVAL=week  # minute, hour, day, week, or month
  2. 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.