Skip to content

fix integration tests #59782

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,25 @@ jobs:
REDIS_MASTER_SET: redis_sentinel
REDIS_SENTINEL_QUORUM: 1
redis-primary:
image: redis:latest
hostname: redis-primary
image: bitnami/redis:latest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this image required instead of the official Redis docker image?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't got it working with the original image and this one supports it by environment variables.

ports:
- 16381:6379

env:
ALLOW_EMPTY_PASSWORD: "yes"
REDIS_REPLICATION_MODE: "master"
options: >-
--name=redis-primary
redis-replica:
image: redis:latest
image: bitnami/redis:latest
ports:
- 16382:6379
command: redis-server --slaveof redis-primary 6379
env:
ALLOW_EMPTY_PASSWORD: "yes"
REDIS_REPLICATION_MODE: "slave"
REDIS_MASTER_HOST: redis-primary
REDIS_MASTER_PORT_NUMBER: "6379"
options: >-
--name=redis-replica
memcached:
image: memcached:1.6.5
ports:
Expand Down Expand Up @@ -250,7 +259,7 @@ jobs:
REDIS_CLUSTER_HOSTS: 'localhost:7000 localhost:7001 localhost:7002 localhost:7003 localhost:7004 localhost:7005'
REDIS_SENTINEL_HOSTS: 'unreachable-host:26379 localhost:26379 localhost:26379'
REDIS_SENTINEL_SERVICE: redis_sentinel
REDIS_REPLICATION_HOSTS: 'localhost:16381 localhost:16382'
REDIS_REPLICATION_HOSTS: 'localhost:16382 localhost:16381'
MESSENGER_REDIS_DSN: redis://127.0.0.1:7006/messages
MESSENGER_AMQP_DSN: amqp://localhost/%2f/messages
MESSENGER_SQS_DSN: "sqs://localhost:4566/messages?sslmode=disable&poll_timeout=0.01"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public static function setUpBeforeClass(): void
self::markTestSkipped('REDIS_REPLICATION_HOSTS env var is not defined.');
}

self::$redis = RedisAdapter::createConnection('redis:?host['.str_replace(' ', ']&host[', $hosts).'][alias]=master', ['class' => \Predis\Client::class, 'prefix' => 'prefix_']);
self::$redis = RedisAdapter::createConnection('redis:?host['.str_replace(' ', ']&host[', $hosts).'][role]=master', ['replication' => 'predis', 'class' => \Predis\Client::class, 'prefix' => 'prefix_']);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ class PredisReplicationAdapterTest extends AbstractRedisAdapterTestCase
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::$redis = new \Predis\Client(array_combine(['host', 'port'], explode(':', getenv('REDIS_HOST')) + [1 => 6379]), ['prefix' => 'prefix_']);

if (!$hosts = getenv('REDIS_REPLICATION_HOSTS')) {
self::markTestSkipped('REDIS_REPLICATION_HOSTS env var is not defined.');
}

$hosts = explode(' ', getenv('REDIS_REPLICATION_HOSTS'));
$lastArrayKey = array_key_last($hosts);
$hostTable = [];
foreach($hosts as $key => $host) {
$hostInformation = array_combine(['host', 'port'], explode(':', $host));
if($lastArrayKey === $key) {
$hostInformation['role'] = 'master';
}
$hostTable[] = $hostInformation;
}

self::$redis = new \Predis\Client($hostTable, ['replication' => 'predis', 'prefix' => 'prefix_']);
}
}

This file was deleted.

This file was deleted.

Loading