minor #36647 Execute docker dependent tests with github actions (jakzal)
This PR was merged into the 4.4 branch.
Discussion
----------
Execute docker dependent tests with github actions
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Tickets | Fixes #36427
| License | MIT
| Doc PR | -
* redis, memcached, rabbitmq and vulcain dependent tests moved to the github action
* run on PHP 7.1 and 7.4 only
* use the `integration` group for all tests that depend on docker services
* do not exclude the `integration` group on Travis, but make sure tests that depend on docker services are skipped properly
[<img width="1222" alt="image" src="https://user-images.githubusercontent.com/190447/80806323-48339100-8bb2-11ea-95cd-5ce773c74ce6.png">](https://github.com/jakzal/symfony/runs/636461875?check_suite_focus=true)
Commits
-------
d710c1b654
Execute docker dependent tests with github actions
This commit is contained in:
commit
0a7fa8f35d
101
.github/workflows/tests.yml
vendored
Normal file
101
.github/workflows/tests.yml
vendored
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
name: Tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
integration:
|
||||||
|
name: Integration
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
php: ['7.1', '7.4']
|
||||||
|
|
||||||
|
services:
|
||||||
|
redis:
|
||||||
|
image: redis:6.0.0
|
||||||
|
ports:
|
||||||
|
- 6379:6379
|
||||||
|
redis-cluster:
|
||||||
|
image: grokzen/redis-cluster:5.0.4
|
||||||
|
ports:
|
||||||
|
- 7000:7000
|
||||||
|
- 7001:7001
|
||||||
|
- 7002:7002
|
||||||
|
- 7003:7003
|
||||||
|
- 7004:7004
|
||||||
|
- 7005:7005
|
||||||
|
- 7006:7006
|
||||||
|
- 7007:7007
|
||||||
|
env:
|
||||||
|
STANDALONE: true
|
||||||
|
memcached:
|
||||||
|
image: memcached:1.6.5
|
||||||
|
ports:
|
||||||
|
- 11211:11211
|
||||||
|
rabbitmq:
|
||||||
|
image: rabbitmq:3.8.3
|
||||||
|
ports:
|
||||||
|
- 5672:5672
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
coverage: "none"
|
||||||
|
extensions: "memcached,redis,xsl"
|
||||||
|
ini-values: "memory_limit=-1"
|
||||||
|
php-version: "${{ matrix.php }}"
|
||||||
|
tools: flex
|
||||||
|
|
||||||
|
- name: Configure composer
|
||||||
|
run: |
|
||||||
|
([ -d ~/.composer ] || mkdir ~/.composer) && cp .github/composer-config.json ~/.composer/config.json
|
||||||
|
SYMFONY_VERSION=$(cat composer.json | grep '^ *\"dev-master\". *\"[1-9]' | grep -o '[0-9.]*')
|
||||||
|
echo "::set-env name=SYMFONY_VERSION::$SYMFONY_VERSION"
|
||||||
|
echo "::set-env name=COMPOSER_ROOT_VERSION::$SYMFONY_VERSION.x-dev"
|
||||||
|
|
||||||
|
- name: Determine composer cache directory
|
||||||
|
id: composer-cache
|
||||||
|
run: echo "::set-output name=directory::$(composer config cache-dir)"
|
||||||
|
|
||||||
|
- name: Cache composer dependencies
|
||||||
|
uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
path: ${{ steps.composer-cache.outputs.directory }}
|
||||||
|
key: ${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||||
|
restore-keys: ${{ matrix.php }}-composer-
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
echo "::group::composer update"
|
||||||
|
composer update --no-progress --no-suggest --ansi
|
||||||
|
echo "::endgroup::"
|
||||||
|
echo "::group::install phpunit"
|
||||||
|
./phpunit install
|
||||||
|
echo "::endgroup::"
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: ./phpunit --verbose --group integration
|
||||||
|
env:
|
||||||
|
SYMFONY_DEPRECATIONS_HELPER: 'max[indirect]=7'
|
||||||
|
REDIS_HOST: localhost
|
||||||
|
REDIS_CLUSTER_HOSTS: 'localhost:7000 localhost:7001 localhost:7002 localhost:7003 localhost:7004 localhost:7005'
|
||||||
|
MESSENGER_REDIS_DSN: redis://127.0.0.1:7006/messages
|
||||||
|
MESSENGER_AMQP_DSN: amqp://localhost/%2f/messages
|
||||||
|
MEMCACHED_HOST: localhost
|
||||||
|
|
||||||
|
- name: Run HTTP push tests
|
||||||
|
if: matrix.php == '7.4'
|
||||||
|
run: |
|
||||||
|
[ -d .phpunit ] && mv .phpunit .phpunit.bak
|
||||||
|
wget -q https://github.com/symfony/binary-utils/releases/download/v0.1/vulcain_0.1.3_Linux_x86_64.tar.gz -O - | tar xz && mv vulcain /usr/local/bin
|
||||||
|
docker run --rm -e COMPOSER_ROOT_VERSION -e SYMFONY_VERSION -v $(pwd):/app -v $(which composer):/usr/local/bin/composer -v /usr/local/bin/vulcain:/usr/local/bin/vulcain -w /app php:7.4-alpine ./phpunit --verbose src/Symfony/Component/HttpClient/Tests/CurlHttpClientTest.php --filter testHttp2Push
|
||||||
|
sudo rm -rf .phpunit
|
||||||
|
[ -d .phpunit.bak ] && mv .phpunit.bak .phpunit
|
31
.travis.yml
31
.travis.yml
@ -13,14 +13,11 @@ addons:
|
|||||||
- slapd
|
- slapd
|
||||||
- zookeeperd
|
- zookeeperd
|
||||||
- libzookeeper-mt-dev
|
- libzookeeper-mt-dev
|
||||||
- rabbitmq-server
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
- MIN_PHP=7.1.3
|
- MIN_PHP=7.1.3
|
||||||
- SYMFONY_PROCESS_PHP_TEST_BINARY=~/.phpenv/shims/php
|
- SYMFONY_PROCESS_PHP_TEST_BINARY=~/.phpenv/shims/php
|
||||||
- MESSENGER_AMQP_DSN=amqp://localhost/%2f/messages
|
|
||||||
- MESSENGER_REDIS_DSN=redis://127.0.0.1:7006/messages
|
|
||||||
- SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE=1
|
- SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE=1
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
@ -39,13 +36,6 @@ cache:
|
|||||||
- php-$MIN_PHP
|
- php-$MIN_PHP
|
||||||
- ~/php-ext
|
- ~/php-ext
|
||||||
|
|
||||||
services:
|
|
||||||
- memcached
|
|
||||||
- mongodb
|
|
||||||
- redis-server
|
|
||||||
- rabbitmq
|
|
||||||
- docker
|
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- |
|
- |
|
||||||
# Enable Sury ppa
|
# Enable Sury ppa
|
||||||
@ -56,12 +46,6 @@ before_install:
|
|||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install -y librabbitmq-dev libsodium-dev
|
sudo apt install -y librabbitmq-dev libsodium-dev
|
||||||
|
|
||||||
- |
|
|
||||||
# Start Redis cluster
|
|
||||||
docker pull grokzen/redis-cluster:5.0.4
|
|
||||||
docker run -d -p 7000:7000 -p 7001:7001 -p 7002:7002 -p 7003:7003 -p 7004:7004 -p 7005:7005 -p 7006:7006 -p 7007:7007 -e "STANDALONE=true" --name redis-cluster grokzen/redis-cluster:5.0.4
|
|
||||||
export REDIS_CLUSTER_HOSTS='localhost:7000 localhost:7001 localhost:7002 localhost:7003 localhost:7004 localhost:7005'
|
|
||||||
|
|
||||||
- |
|
- |
|
||||||
# General configuration
|
# General configuration
|
||||||
set -e
|
set -e
|
||||||
@ -141,12 +125,6 @@ before_install:
|
|||||||
(cd php-$MIN_PHP && ./configure --enable-sigchild --enable-pcntl && make -j2)
|
(cd php-$MIN_PHP && ./configure --enable-sigchild --enable-pcntl && make -j2)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- |
|
|
||||||
# Install vulcain
|
|
||||||
wget https://github.com/symfony/binary-utils/releases/download/v0.1/vulcain_0.1.3_Linux_x86_64.tar.gz -O - | tar xz
|
|
||||||
sudo mv vulcain /usr/local/bin
|
|
||||||
docker pull php:7.3-alpine
|
|
||||||
|
|
||||||
- |
|
- |
|
||||||
# php.ini configuration
|
# php.ini configuration
|
||||||
for PHP in $TRAVIS_PHP_VERSION $php_extra; do
|
for PHP in $TRAVIS_PHP_VERSION $php_extra; do
|
||||||
@ -268,15 +246,6 @@ install:
|
|||||||
set -e
|
set -e
|
||||||
export PHP=$1
|
export PHP=$1
|
||||||
|
|
||||||
if [[ !$deps && $PHP = 7.2 ]]; then
|
|
||||||
phpenv global $PHP
|
|
||||||
tfold 'composer update' $COMPOSER_UP
|
|
||||||
[ -d .phpunit ] && mv .phpunit .phpunit.bak
|
|
||||||
tfold src/Symfony/Component/HttpClient.h2push "docker run -it --rm -v $(pwd):/app -v $(phpenv which composer):/usr/local/bin/composer -v /usr/local/bin/vulcain:/usr/local/bin/vulcain -w /app php:7.3-alpine ./phpunit src/Symfony/Component/HttpClient/Tests/CurlHttpClientTest.php --filter testHttp2Push"
|
|
||||||
sudo rm .phpunit -rf
|
|
||||||
[ -d .phpunit.bak ] && mv .phpunit.bak .phpunit
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $PHP != 7.4* && $PHP != $TRAVIS_PHP_VERSION && $TRAVIS_PULL_REQUEST != false ]]; then
|
if [[ $PHP != 7.4* && $PHP != $TRAVIS_PHP_VERSION && $TRAVIS_PULL_REQUEST != false ]]; then
|
||||||
echo -e "\\n\\e[33;1mIntermediate PHP version $PHP is skipped for pull requests.\\e[0m"
|
echo -e "\\n\\e[33;1mIntermediate PHP version $PHP is skipped for pull requests.\\e[0m"
|
||||||
return
|
return
|
||||||
|
@ -26,9 +26,12 @@ class CachePoolsTest extends AbstractWebTestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @requires extension redis
|
* @requires extension redis
|
||||||
|
* @group integration
|
||||||
*/
|
*/
|
||||||
public function testRedisCachePools()
|
public function testRedisCachePools()
|
||||||
{
|
{
|
||||||
|
$this->skipIfRedisUnavailable();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->doTestCachePools(['root_config' => 'redis_config.yml', 'environment' => 'redis_cache'], RedisAdapter::class);
|
$this->doTestCachePools(['root_config' => 'redis_config.yml', 'environment' => 'redis_cache'], RedisAdapter::class);
|
||||||
} catch (\PHPUnit\Framework\Error\Warning $e) {
|
} catch (\PHPUnit\Framework\Error\Warning $e) {
|
||||||
@ -51,9 +54,12 @@ class CachePoolsTest extends AbstractWebTestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @requires extension redis
|
* @requires extension redis
|
||||||
|
* @group integration
|
||||||
*/
|
*/
|
||||||
public function testRedisCustomCachePools()
|
public function testRedisCustomCachePools()
|
||||||
{
|
{
|
||||||
|
$this->skipIfRedisUnavailable();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->doTestCachePools(['root_config' => 'redis_custom_config.yml', 'environment' => 'custom_redis_cache'], RedisAdapter::class);
|
$this->doTestCachePools(['root_config' => 'redis_custom_config.yml', 'environment' => 'custom_redis_cache'], RedisAdapter::class);
|
||||||
} catch (\PHPUnit\Framework\Error\Warning $e) {
|
} catch (\PHPUnit\Framework\Error\Warning $e) {
|
||||||
@ -121,4 +127,13 @@ class CachePoolsTest extends AbstractWebTestCase
|
|||||||
{
|
{
|
||||||
return parent::createKernel(['test_case' => 'CachePools'] + $options);
|
return parent::createKernel(['test_case' => 'CachePools'] + $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function skipIfRedisUnavailable()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
(new \Redis())->connect(getenv('REDIS_HOST'));
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
self::markTestSkipped($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,9 +34,10 @@ abstract class AbstractRedisAdapterTest extends AdapterTestCase
|
|||||||
if (!\extension_loaded('redis')) {
|
if (!\extension_loaded('redis')) {
|
||||||
self::markTestSkipped('Extension redis required.');
|
self::markTestSkipped('Extension redis required.');
|
||||||
}
|
}
|
||||||
if (!@((new \Redis())->connect(getenv('REDIS_HOST')))) {
|
try {
|
||||||
$e = error_get_last();
|
(new \Redis())->connect(getenv('REDIS_HOST'));
|
||||||
self::markTestSkipped($e['message']);
|
} catch (\Exception $e) {
|
||||||
|
self::markTestSkipped($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,9 @@ use Psr\Cache\CacheItemPoolInterface;
|
|||||||
use Symfony\Component\Cache\Adapter\AbstractAdapter;
|
use Symfony\Component\Cache\Adapter\AbstractAdapter;
|
||||||
use Symfony\Component\Cache\Adapter\MemcachedAdapter;
|
use Symfony\Component\Cache\Adapter\MemcachedAdapter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
*/
|
||||||
class MemcachedAdapterTest extends AdapterTestCase
|
class MemcachedAdapterTest extends AdapterTestCase
|
||||||
{
|
{
|
||||||
protected $skippedTests = [
|
protected $skippedTests = [
|
||||||
|
@ -14,6 +14,9 @@ namespace Symfony\Component\Cache\Tests\Adapter;
|
|||||||
use Predis\Connection\StreamConnection;
|
use Predis\Connection\StreamConnection;
|
||||||
use Symfony\Component\Cache\Adapter\RedisAdapter;
|
use Symfony\Component\Cache\Adapter\RedisAdapter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
*/
|
||||||
class PredisAdapterTest extends AbstractRedisAdapterTest
|
class PredisAdapterTest extends AbstractRedisAdapterTest
|
||||||
{
|
{
|
||||||
public static function setUpBeforeClass(): void
|
public static function setUpBeforeClass(): void
|
||||||
|
@ -11,6 +11,9 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
namespace Symfony\Component\Cache\Tests\Adapter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
*/
|
||||||
class PredisClusterAdapterTest extends AbstractRedisAdapterTest
|
class PredisClusterAdapterTest extends AbstractRedisAdapterTest
|
||||||
{
|
{
|
||||||
public static function setUpBeforeClass(): void
|
public static function setUpBeforeClass(): void
|
||||||
|
@ -13,6 +13,9 @@ namespace Symfony\Component\Cache\Tests\Adapter;
|
|||||||
|
|
||||||
use Symfony\Component\Cache\Adapter\RedisAdapter;
|
use Symfony\Component\Cache\Adapter\RedisAdapter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
*/
|
||||||
class PredisRedisClusterAdapterTest extends AbstractRedisAdapterTest
|
class PredisRedisClusterAdapterTest extends AbstractRedisAdapterTest
|
||||||
{
|
{
|
||||||
public static function setUpBeforeClass(): void
|
public static function setUpBeforeClass(): void
|
||||||
|
@ -15,6 +15,9 @@ use Psr\Cache\CacheItemPoolInterface;
|
|||||||
use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
|
use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
|
||||||
use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait;
|
use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
*/
|
||||||
class PredisTagAwareAdapterTest extends PredisAdapterTest
|
class PredisTagAwareAdapterTest extends PredisAdapterTest
|
||||||
{
|
{
|
||||||
use TagAwareTestTrait;
|
use TagAwareTestTrait;
|
||||||
|
@ -15,6 +15,9 @@ use Psr\Cache\CacheItemPoolInterface;
|
|||||||
use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
|
use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
|
||||||
use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait;
|
use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
*/
|
||||||
class PredisTagAwareClusterAdapterTest extends PredisClusterAdapterTest
|
class PredisTagAwareClusterAdapterTest extends PredisClusterAdapterTest
|
||||||
{
|
{
|
||||||
use TagAwareTestTrait;
|
use TagAwareTestTrait;
|
||||||
|
@ -14,6 +14,9 @@ namespace Symfony\Component\Cache\Tests\Adapter;
|
|||||||
use Symfony\Component\Cache\Adapter\AbstractAdapter;
|
use Symfony\Component\Cache\Adapter\AbstractAdapter;
|
||||||
use Symfony\Component\Cache\Adapter\RedisAdapter;
|
use Symfony\Component\Cache\Adapter\RedisAdapter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
*/
|
||||||
class RedisAdapterSentinelTest extends AbstractRedisAdapterTest
|
class RedisAdapterSentinelTest extends AbstractRedisAdapterTest
|
||||||
{
|
{
|
||||||
public static function setUpBeforeClass(): void
|
public static function setUpBeforeClass(): void
|
||||||
|
@ -16,6 +16,9 @@ use Symfony\Component\Cache\Adapter\AbstractAdapter;
|
|||||||
use Symfony\Component\Cache\Adapter\RedisAdapter;
|
use Symfony\Component\Cache\Adapter\RedisAdapter;
|
||||||
use Symfony\Component\Cache\Traits\RedisProxy;
|
use Symfony\Component\Cache\Traits\RedisProxy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
*/
|
||||||
class RedisAdapterTest extends AbstractRedisAdapterTest
|
class RedisAdapterTest extends AbstractRedisAdapterTest
|
||||||
{
|
{
|
||||||
public static function setUpBeforeClass(): void
|
public static function setUpBeforeClass(): void
|
||||||
|
@ -11,6 +11,9 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Cache\Tests\Adapter;
|
namespace Symfony\Component\Cache\Tests\Adapter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
*/
|
||||||
class RedisArrayAdapterTest extends AbstractRedisAdapterTest
|
class RedisArrayAdapterTest extends AbstractRedisAdapterTest
|
||||||
{
|
{
|
||||||
public static function setUpBeforeClass(): void
|
public static function setUpBeforeClass(): void
|
||||||
|
@ -16,6 +16,9 @@ use Symfony\Component\Cache\Adapter\AbstractAdapter;
|
|||||||
use Symfony\Component\Cache\Adapter\RedisAdapter;
|
use Symfony\Component\Cache\Adapter\RedisAdapter;
|
||||||
use Symfony\Component\Cache\Traits\RedisClusterProxy;
|
use Symfony\Component\Cache\Traits\RedisClusterProxy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
*/
|
||||||
class RedisClusterAdapterTest extends AbstractRedisAdapterTest
|
class RedisClusterAdapterTest extends AbstractRedisAdapterTest
|
||||||
{
|
{
|
||||||
public static function setUpBeforeClass(): void
|
public static function setUpBeforeClass(): void
|
||||||
|
@ -16,6 +16,9 @@ use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
|
|||||||
use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait;
|
use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait;
|
||||||
use Symfony\Component\Cache\Traits\RedisProxy;
|
use Symfony\Component\Cache\Traits\RedisProxy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
*/
|
||||||
class RedisTagAwareAdapterTest extends RedisAdapterTest
|
class RedisTagAwareAdapterTest extends RedisAdapterTest
|
||||||
{
|
{
|
||||||
use TagAwareTestTrait;
|
use TagAwareTestTrait;
|
||||||
|
@ -15,6 +15,9 @@ use Psr\Cache\CacheItemPoolInterface;
|
|||||||
use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
|
use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
|
||||||
use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait;
|
use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
*/
|
||||||
class RedisTagAwareArrayAdapterTest extends RedisArrayAdapterTest
|
class RedisTagAwareArrayAdapterTest extends RedisArrayAdapterTest
|
||||||
{
|
{
|
||||||
use TagAwareTestTrait;
|
use TagAwareTestTrait;
|
||||||
|
@ -16,6 +16,9 @@ use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
|
|||||||
use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait;
|
use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait;
|
||||||
use Symfony\Component\Cache\Traits\RedisClusterProxy;
|
use Symfony\Component\Cache\Traits\RedisClusterProxy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
*/
|
||||||
class RedisTagAwareClusterAdapterTest extends RedisClusterAdapterTest
|
class RedisTagAwareClusterAdapterTest extends RedisClusterAdapterTest
|
||||||
{
|
{
|
||||||
use TagAwareTestTrait;
|
use TagAwareTestTrait;
|
||||||
|
@ -37,9 +37,10 @@ abstract class AbstractRedisCacheTest extends CacheTestCase
|
|||||||
if (!\extension_loaded('redis')) {
|
if (!\extension_loaded('redis')) {
|
||||||
self::markTestSkipped('Extension redis required.');
|
self::markTestSkipped('Extension redis required.');
|
||||||
}
|
}
|
||||||
if (!@((new \Redis())->connect(getenv('REDIS_HOST')))) {
|
try {
|
||||||
$e = error_get_last();
|
(new \Redis())->connect(getenv('REDIS_HOST'));
|
||||||
self::markTestSkipped($e['message']);
|
} catch (\Exception $e) {
|
||||||
|
self::markTestSkipped($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ use Symfony\Component\Cache\Simple\MemcachedCache;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @group legacy
|
* @group legacy
|
||||||
|
* @group integration
|
||||||
*/
|
*/
|
||||||
class MemcachedCacheTest extends CacheTestCase
|
class MemcachedCacheTest extends CacheTestCase
|
||||||
{
|
{
|
||||||
|
@ -17,6 +17,7 @@ use Symfony\Component\Cache\Simple\MemcachedCache;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @group legacy
|
* @group legacy
|
||||||
|
* @group integration
|
||||||
*/
|
*/
|
||||||
class MemcachedCacheTextModeTest extends MemcachedCacheTest
|
class MemcachedCacheTextModeTest extends MemcachedCacheTest
|
||||||
{
|
{
|
||||||
|
@ -13,6 +13,7 @@ namespace Symfony\Component\Cache\Tests\Simple;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @group legacy
|
* @group legacy
|
||||||
|
* @group integration
|
||||||
*/
|
*/
|
||||||
class RedisArrayCacheTest extends AbstractRedisCacheTest
|
class RedisArrayCacheTest extends AbstractRedisCacheTest
|
||||||
{
|
{
|
||||||
|
@ -15,6 +15,7 @@ use Symfony\Component\Cache\Simple\RedisCache;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @group legacy
|
* @group legacy
|
||||||
|
* @group integration
|
||||||
*/
|
*/
|
||||||
class RedisCacheTest extends AbstractRedisCacheTest
|
class RedisCacheTest extends AbstractRedisCacheTest
|
||||||
{
|
{
|
||||||
|
@ -13,6 +13,7 @@ namespace Symfony\Component\Cache\Tests\Simple;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @group legacy
|
* @group legacy
|
||||||
|
* @group integration
|
||||||
*/
|
*/
|
||||||
class RedisClusterCacheTest extends AbstractRedisCacheTest
|
class RedisClusterCacheTest extends AbstractRedisCacheTest
|
||||||
{
|
{
|
||||||
|
@ -44,6 +44,11 @@ abstract class AbstractRedisSessionHandlerTestCase extends TestCase
|
|||||||
if (!\extension_loaded('redis')) {
|
if (!\extension_loaded('redis')) {
|
||||||
self::markTestSkipped('Extension redis required.');
|
self::markTestSkipped('Extension redis required.');
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
(new \Redis())->connect(getenv('REDIS_HOST'));
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
self::markTestSkipped($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
$host = getenv('REDIS_HOST') ?: 'localhost';
|
$host = getenv('REDIS_HOST') ?: 'localhost';
|
||||||
|
|
||||||
|
@ -13,6 +13,9 @@ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler;
|
|||||||
|
|
||||||
use Predis\Client;
|
use Predis\Client;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
*/
|
||||||
class PredisClusterSessionHandlerTest extends AbstractRedisSessionHandlerTestCase
|
class PredisClusterSessionHandlerTest extends AbstractRedisSessionHandlerTestCase
|
||||||
{
|
{
|
||||||
protected function createRedisClient(string $host): Client
|
protected function createRedisClient(string $host): Client
|
||||||
|
@ -13,6 +13,9 @@ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler;
|
|||||||
|
|
||||||
use Predis\Client;
|
use Predis\Client;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
*/
|
||||||
class PredisSessionHandlerTest extends AbstractRedisSessionHandlerTestCase
|
class PredisSessionHandlerTest extends AbstractRedisSessionHandlerTestCase
|
||||||
{
|
{
|
||||||
protected function createRedisClient(string $host): Client
|
protected function createRedisClient(string $host): Client
|
||||||
|
@ -11,6 +11,9 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler;
|
namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
*/
|
||||||
class RedisArraySessionHandlerTest extends AbstractRedisSessionHandlerTestCase
|
class RedisArraySessionHandlerTest extends AbstractRedisSessionHandlerTestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -11,6 +11,9 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler;
|
namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
*/
|
||||||
class RedisClusterSessionHandlerTest extends AbstractRedisSessionHandlerTestCase
|
class RedisClusterSessionHandlerTest extends AbstractRedisSessionHandlerTestCase
|
||||||
{
|
{
|
||||||
public static function setUpBeforeClass(): void
|
public static function setUpBeforeClass(): void
|
||||||
|
@ -11,6 +11,9 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler;
|
namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
*/
|
||||||
class RedisSessionHandlerTest extends AbstractRedisSessionHandlerTestCase
|
class RedisSessionHandlerTest extends AbstractRedisSessionHandlerTestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -19,6 +19,7 @@ use Symfony\Component\Lock\Store\MemcachedStore;
|
|||||||
* @author Jérémy Derussé <jeremy@derusse.com>
|
* @author Jérémy Derussé <jeremy@derusse.com>
|
||||||
*
|
*
|
||||||
* @requires extension memcached
|
* @requires extension memcached
|
||||||
|
* @group integration
|
||||||
*/
|
*/
|
||||||
class MemcachedStoreTest extends AbstractStoreTest
|
class MemcachedStoreTest extends AbstractStoreTest
|
||||||
{
|
{
|
||||||
|
@ -13,6 +13,7 @@ namespace Symfony\Component\Lock\Tests\Store;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Jérémy Derussé <jeremy@derusse.com>
|
* @author Jérémy Derussé <jeremy@derusse.com>
|
||||||
|
* @group integration
|
||||||
*/
|
*/
|
||||||
class PredisStoreTest extends AbstractRedisStoreTest
|
class PredisStoreTest extends AbstractRedisStoreTest
|
||||||
{
|
{
|
||||||
|
@ -15,6 +15,7 @@ namespace Symfony\Component\Lock\Tests\Store;
|
|||||||
* @author Jérémy Derussé <jeremy@derusse.com>
|
* @author Jérémy Derussé <jeremy@derusse.com>
|
||||||
*
|
*
|
||||||
* @requires extension redis
|
* @requires extension redis
|
||||||
|
* @group integration
|
||||||
*/
|
*/
|
||||||
class RedisArrayStoreTest extends AbstractRedisStoreTest
|
class RedisArrayStoreTest extends AbstractRedisStoreTest
|
||||||
{
|
{
|
||||||
@ -23,9 +24,10 @@ class RedisArrayStoreTest extends AbstractRedisStoreTest
|
|||||||
if (!class_exists('RedisArray')) {
|
if (!class_exists('RedisArray')) {
|
||||||
self::markTestSkipped('The RedisArray class is required.');
|
self::markTestSkipped('The RedisArray class is required.');
|
||||||
}
|
}
|
||||||
if (!@((new \Redis())->connect(getenv('REDIS_HOST')))) {
|
try {
|
||||||
$e = error_get_last();
|
(new \Redis())->connect(getenv('REDIS_HOST'));
|
||||||
self::markTestSkipped($e['message']);
|
} catch (\Exception $e) {
|
||||||
|
self::markTestSkipped($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ namespace Symfony\Component\Lock\Tests\Store;
|
|||||||
* @author Jérémy Derussé <jeremy@derusse.com>
|
* @author Jérémy Derussé <jeremy@derusse.com>
|
||||||
*
|
*
|
||||||
* @requires extension redis
|
* @requires extension redis
|
||||||
|
* @group integration
|
||||||
*/
|
*/
|
||||||
class RedisClusterStoreTest extends AbstractRedisStoreTest
|
class RedisClusterStoreTest extends AbstractRedisStoreTest
|
||||||
{
|
{
|
||||||
|
@ -17,14 +17,16 @@ use Symfony\Component\Lock\Store\RedisStore;
|
|||||||
* @author Jérémy Derussé <jeremy@derusse.com>
|
* @author Jérémy Derussé <jeremy@derusse.com>
|
||||||
*
|
*
|
||||||
* @requires extension redis
|
* @requires extension redis
|
||||||
|
* @group integration
|
||||||
*/
|
*/
|
||||||
class RedisStoreTest extends AbstractRedisStoreTest
|
class RedisStoreTest extends AbstractRedisStoreTest
|
||||||
{
|
{
|
||||||
public static function setUpBeforeClass(): void
|
public static function setUpBeforeClass(): void
|
||||||
{
|
{
|
||||||
if (!@((new \Redis())->connect(getenv('REDIS_HOST')))) {
|
try {
|
||||||
$e = error_get_last();
|
(new \Redis())->connect(getenv('REDIS_HOST'));
|
||||||
self::markTestSkipped($e['message']);
|
} catch (\Exception $e) {
|
||||||
|
self::markTestSkipped($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @requires extension amqp
|
* @requires extension amqp
|
||||||
|
* @group integration
|
||||||
*/
|
*/
|
||||||
class AmqpExtIntegrationTest extends TestCase
|
class AmqpExtIntegrationTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -17,14 +17,14 @@ use Symfony\Component\Messenger\Transport\RedisExt\Connection;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @requires extension redis >= 4.3.0
|
* @requires extension redis >= 4.3.0
|
||||||
|
* @group integration
|
||||||
*/
|
*/
|
||||||
class ConnectionTest extends TestCase
|
class ConnectionTest extends TestCase
|
||||||
{
|
{
|
||||||
public static function setUpBeforeClass(): void
|
public static function setUpBeforeClass(): void
|
||||||
{
|
{
|
||||||
$redis = Connection::fromDsn('redis://localhost/queue');
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
$redis = Connection::fromDsn('redis://localhost/queue');
|
||||||
$redis->get();
|
$redis->get();
|
||||||
} catch (TransportException $e) {
|
} catch (TransportException $e) {
|
||||||
if (0 === strpos($e->getMessage(), 'ERR unknown command \'X')) {
|
if (0 === strpos($e->getMessage(), 'ERR unknown command \'X')) {
|
||||||
@ -32,6 +32,8 @@ class ConnectionTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
throw $e;
|
throw $e;
|
||||||
|
} catch (\RedisException $e) {
|
||||||
|
self::markTestSkipped($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ use Symfony\Component\Messenger\Transport\RedisExt\Connection;
|
|||||||
/**
|
/**
|
||||||
* @requires extension redis
|
* @requires extension redis
|
||||||
* @group time-sensitive
|
* @group time-sensitive
|
||||||
|
* @group integration
|
||||||
*/
|
*/
|
||||||
class RedisExtIntegrationTest extends TestCase
|
class RedisExtIntegrationTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -30,10 +31,14 @@ class RedisExtIntegrationTest extends TestCase
|
|||||||
$this->markTestSkipped('The "MESSENGER_REDIS_DSN" environment variable is required.');
|
$this->markTestSkipped('The "MESSENGER_REDIS_DSN" environment variable is required.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->redis = new \Redis();
|
try {
|
||||||
$this->connection = Connection::fromDsn(getenv('MESSENGER_REDIS_DSN'), [], $this->redis);
|
$this->redis = new \Redis();
|
||||||
$this->connection->cleanup();
|
$this->connection = Connection::fromDsn(getenv('MESSENGER_REDIS_DSN'), [], $this->redis);
|
||||||
$this->connection->setup();
|
$this->connection->cleanup();
|
||||||
|
$this->connection->setup();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
self::markTestSkipped($e->getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testConnectionSendAndGet()
|
public function testConnectionSendAndGet()
|
||||||
|
@ -31,12 +31,26 @@ class RedisTransportFactoryTest extends TestCase
|
|||||||
$this->assertFalse($factory->supports('invalid-dsn', []));
|
$this->assertFalse($factory->supports('invalid-dsn', []));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
*/
|
||||||
public function testCreateTransport()
|
public function testCreateTransport()
|
||||||
{
|
{
|
||||||
|
$this->skipIfRedisUnavailable();
|
||||||
|
|
||||||
$factory = new RedisTransportFactory();
|
$factory = new RedisTransportFactory();
|
||||||
$serializer = $this->getMockBuilder(SerializerInterface::class)->getMock();
|
$serializer = $this->getMockBuilder(SerializerInterface::class)->getMock();
|
||||||
$expectedTransport = new RedisTransport(Connection::fromDsn('redis://localhost', ['foo' => 'bar']), $serializer);
|
$expectedTransport = new RedisTransport(Connection::fromDsn('redis://'.getenv('REDIS_HOST'), ['foo' => 'bar']), $serializer);
|
||||||
|
|
||||||
$this->assertEquals($expectedTransport, $factory->createTransport('redis://localhost', ['foo' => 'bar'], $serializer));
|
$this->assertEquals($expectedTransport, $factory->createTransport('redis://'.getenv('REDIS_HOST'), ['foo' => 'bar'], $serializer));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function skipIfRedisUnavailable()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
(new \Redis())->connect(getenv('REDIS_HOST'));
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
self::markTestSkipped($e->getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
|
|||||||
/**
|
/**
|
||||||
* @author Nicolas Grekas <p@tchwork.com>
|
* @author Nicolas Grekas <p@tchwork.com>
|
||||||
* @requires extension redis
|
* @requires extension redis
|
||||||
|
* @group integration
|
||||||
*/
|
*/
|
||||||
class RedisCasterTest extends TestCase
|
class RedisCasterTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -37,16 +38,18 @@ EODUMP;
|
|||||||
|
|
||||||
public function testConnected()
|
public function testConnected()
|
||||||
{
|
{
|
||||||
|
$redisHost = getenv('REDIS_HOST');
|
||||||
$redis = new \Redis();
|
$redis = new \Redis();
|
||||||
if (!@$redis->connect('127.0.0.1')) {
|
try {
|
||||||
$e = error_get_last();
|
$redis->connect($redisHost);
|
||||||
self::markTestSkipped($e['message']);
|
} catch (\Exception $e) {
|
||||||
|
self::markTestSkipped($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
$xCast = <<<'EODUMP'
|
$xCast = <<<EODUMP
|
||||||
Redis {%A
|
Redis {%A
|
||||||
isConnected: true
|
isConnected: true
|
||||||
host: "127.0.0.1"
|
host: "$redisHost"
|
||||||
port: 6379
|
port: 6379
|
||||||
auth: null
|
auth: null
|
||||||
mode: ATOMIC
|
mode: ATOMIC
|
||||||
|
Reference in New Issue
Block a user