diff --git a/.github/workflows/queues.yml b/.github/workflows/queues.yml index 257e0d4bf29c..c7827ba04931 100644 --- a/.github/workflows/queues.yml +++ b/.github/workflows/queues.yml @@ -82,113 +82,6 @@ jobs: DB_CONNECTION: sqlite QUEUE_CONNECTION: database - redis: - runs-on: ubuntu-24.04 - - services: - redis: - image: redis:7.0 - ports: - - 6379:6379 - options: --entrypoint redis-server - - strategy: - fail-fast: true - matrix: - client: ['phpredis', 'predis'] - - name: Redis (${{ matrix.client}}) Driver - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.2 - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql, :php-psr - tools: composer:v2 - coverage: none - - - name: Set Framework version - run: composer config version "12.x-dev" - - - name: Install dependencies - uses: nick-fields/retry@v3 - with: - timeout_minutes: 5 - max_attempts: 5 - command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress - - - name: Execute tests - run: vendor/bin/phpunit tests/Integration/Queue - env: - REDIS_CLIENT: ${{ matrix.client }} - QUEUE_CONNECTION: redis - - redis-cluster: - runs-on: ubuntu-24.04 - - strategy: - fail-fast: true - matrix: - client: ['phpredis', 'predis'] - - name: Redis Cluster (${{ matrix.client}}) Driver - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.2 - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql, :php-psr - tools: composer:v2 - coverage: none - - - name: Set Framework version - run: composer config version "12.x-dev" - - - name: Install dependencies - uses: nick-fields/retry@v3 - with: - timeout_minutes: 5 - max_attempts: 5 - command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress - - - name: Create Redis Cluster - run: | - sudo apt update - sudo apt-get install -y --fix-missing redis-server - sudo service redis-server stop - redis-server --daemonize yes --port 7000 --appendonly yes --cluster-enabled yes --cluster-config-file nodes-7000.conf - redis-server --daemonize yes --port 7001 --appendonly yes --cluster-enabled yes --cluster-config-file nodes-7001.conf - redis-server --daemonize yes --port 7002 --appendonly yes --cluster-enabled yes --cluster-config-file nodes-7002.conf - redis-cli --cluster create 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 --cluster-replicas 0 --cluster-yes - - - name: Check Redis Cluster is ready - uses: nick-fields/retry@v3 - with: - timeout_seconds: 5 - max_attempts: 5 - retry_wait_seconds: 5 - retry_on: error - command: | - redis-cli -c -h 127.0.0.1 -p 7000 cluster info | grep "cluster_state:ok" - redis-cli -c -h 127.0.0.1 -p 7001 cluster info | grep "cluster_state:ok" - redis-cli -c -h 127.0.0.1 -p 7002 cluster info | grep "cluster_state:ok" - - - name: Execute tests - run: vendor/bin/phpunit tests/Integration/Queue - env: - REDIS_CLIENT: ${{ matrix.client }} - REDIS_CLUSTER_HOSTS_AND_PORTS: 127.0.0.1:7000,127.0.0.1:7001,127.0.0.1:7002 - REDIS_QUEUE: '{default}' - QUEUE_CONNECTION: redis - beanstalkd: runs-on: ubuntu-24.04 diff --git a/.github/workflows/redis.yml b/.github/workflows/redis.yml new file mode 100644 index 000000000000..cb5dda5c095c --- /dev/null +++ b/.github/workflows/redis.yml @@ -0,0 +1,132 @@ +name: Redis and Redis Cluster + +on: + push: + branches: + - master + - '*.x' + pull_request: + +jobs: + redis: + runs-on: ubuntu-24.04 + + services: + redis: + image: redis:7.0 + ports: + - 6379:6379 + options: --entrypoint redis-server + + strategy: + fail-fast: true + matrix: + client: ['phpredis', 'predis'] + + name: Redis (${{ matrix.client}}) Driver + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.2 + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql, :php-psr + tools: composer:v2 + coverage: none + + - name: Set Framework version + run: composer config version "12.x-dev" + + - name: Install dependencies + uses: nick-fields/retry@v3 + with: + timeout_minutes: 5 + max_attempts: 5 + command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress + + - name: Execute Cache tests + run: vendor/bin/phpunit tests/Integration/Cache + env: + REDIS_CACHE_CONNECTION: cache + REDIS_CACHE_LOCK_CONNECTION: cache + REDIS_CLIENT: ${{ matrix.client }} + + - name: Execute Queue tests + run: vendor/bin/phpunit tests/Integration/Queue + env: + REDIS_CLIENT: ${{ matrix.client }} + QUEUE_CONNECTION: redis + + redis-cluster: + runs-on: ubuntu-24.04 + + strategy: + fail-fast: true + matrix: + client: ['phpredis', 'predis'] + + name: Redis Cluster (${{ matrix.client}}) Driver + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.2 + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql, :php-psr + tools: composer:v2 + coverage: none + + - name: Set Framework version + run: composer config version "12.x-dev" + + - name: Install dependencies + uses: nick-fields/retry@v3 + with: + timeout_minutes: 5 + max_attempts: 5 + command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress + + - name: Create Redis Cluster + run: | + sudo apt update + sudo apt-get install -y --fix-missing redis-server + sudo service redis-server stop + redis-server --daemonize yes --port 7000 --appendonly yes --cluster-enabled yes --cluster-config-file nodes-7000.conf + redis-server --daemonize yes --port 7001 --appendonly yes --cluster-enabled yes --cluster-config-file nodes-7001.conf + redis-server --daemonize yes --port 7002 --appendonly yes --cluster-enabled yes --cluster-config-file nodes-7002.conf + redis-cli --cluster create 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 --cluster-replicas 0 --cluster-yes + + - name: Check Redis Cluster is ready + uses: nick-fields/retry@v3 + with: + timeout_seconds: 5 + max_attempts: 5 + retry_wait_seconds: 5 + retry_on: error + command: | + redis-cli -c -h 127.0.0.1 -p 7000 cluster info | grep "cluster_state:ok" + redis-cli -c -h 127.0.0.1 -p 7001 cluster info | grep "cluster_state:ok" + redis-cli -c -h 127.0.0.1 -p 7002 cluster info | grep "cluster_state:ok" + + - name: Execute Cache tests + run: vendor/bin/phpunit tests/Integration/Cache + env: + REDIS_CACHE_CONNECTION: default + REDIS_CACHE_LOCK_CONNECTION: default + REDIS_CLIENT: ${{ matrix.client }} + REDIS_CLUSTER_HOSTS_AND_PORTS: 127.0.0.1:7000,127.0.0.1:7001,127.0.0.1:7002 + + - name: Execute Queue Tests + run: vendor/bin/phpunit tests/Integration/Queue + env: + REDIS_CLIENT: ${{ matrix.client }} + REDIS_CLUSTER_HOSTS_AND_PORTS: 127.0.0.1:7000,127.0.0.1:7001,127.0.0.1:7002 + REDIS_QUEUE: '{default}' + QUEUE_CONNECTION: redis + diff --git a/tests/Integration/Cache/MemoizedStoreTest.php b/tests/Integration/Cache/MemoizedStoreTest.php index 009906f1555f..e9ec1b435d51 100644 --- a/tests/Integration/Cache/MemoizedStoreTest.php +++ b/tests/Integration/Cache/MemoizedStoreTest.php @@ -13,6 +13,8 @@ use Illuminate\Cache\Events\WritingKey; use Illuminate\Contracts\Cache\Store; use Illuminate\Foundation\Testing\Concerns\InteractsWithRedis; +use Illuminate\Redis\Connections\PhpRedisClusterConnection; +use Illuminate\Redis\Connections\PredisClusterConnection; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Event; @@ -31,6 +33,12 @@ protected function setUp(): void $this->setUpRedis(); + $connection = $this->app['redis']->connection(); + $this->markTestSkippedWhen( + $connection instanceof PhpRedisClusterConnection || $connection instanceof PredisClusterConnection, + 'flushAll and many currently not supported for Redis Cluster connections', + ); + Config::set('cache.default', 'redis'); Redis::flushAll(); } diff --git a/tests/Integration/Cache/PhpRedisCacheLockTest.php b/tests/Integration/Cache/PhpRedisCacheLockTest.php index 1ebc7cc94d87..de33bd263864 100644 --- a/tests/Integration/Cache/PhpRedisCacheLockTest.php +++ b/tests/Integration/Cache/PhpRedisCacheLockTest.php @@ -3,6 +3,8 @@ namespace Illuminate\Tests\Integration\Cache; use Illuminate\Foundation\Testing\Concerns\InteractsWithRedis; +use Illuminate\Redis\Connections\PhpRedisClusterConnection; +use Illuminate\Redis\Connections\PhpRedisConnection; use Illuminate\Support\Facades\Cache; use Orchestra\Testbench\TestCase; use PHPUnit\Framework\Attributes\RequiresPhpExtension; @@ -17,6 +19,12 @@ protected function setUp(): void parent::setUp(); $this->setUpRedis(); + + $connection = $this->app['redis']->connection(); + $this->markTestSkippedUnless( + $connection instanceof PhpRedisConnection || $connection instanceof PhpRedisClusterConnection, + 'This test is for phpredis only', + ); } protected function tearDown(): void @@ -210,7 +218,6 @@ public function testRedisLockCanBeAcquiredAndReleasedWithLz4Compression() $this->markTestSkipped('Redis extension is not configured to support the lz4 compression.'); } - $this->app['config']->set('database.redis.client', 'phpredis'); $this->app['config']->set('cache.stores.redis.connection', 'default'); $this->app['config']->set('cache.stores.redis.lock_connection', 'default'); diff --git a/tests/Integration/Cache/RedisStoreTest.php b/tests/Integration/Cache/RedisStoreTest.php index 1cefcf252863..ede6e7c394f1 100644 --- a/tests/Integration/Cache/RedisStoreTest.php +++ b/tests/Integration/Cache/RedisStoreTest.php @@ -6,6 +6,7 @@ use Illuminate\Cache\RedisStore; use Illuminate\Foundation\Testing\Concerns\InteractsWithRedis; use Illuminate\Redis\Connections\PhpRedisClusterConnection; +use Illuminate\Redis\Connections\PredisClusterConnection; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Redis; use Illuminate\Support\Sleep; @@ -22,6 +23,12 @@ protected function setUp(): void { $this->afterApplicationCreated(function () { $this->setUpRedis(); + + $connection = $this->app['redis']->connection(); + $this->markTestSkippedWhen( + $connection instanceof PhpRedisClusterConnection || $connection instanceof PredisClusterConnection, + 'RedisStore currently does not support tags, many and some other on Redis Cluster cluster connections', + ); }); $this->beforeApplicationDestroyed(function () {