8000 minor #59782 fix integration tests (DemigodCode) · symfony/symfony@6caa25d · GitHub
[go: up one dir, main page]

Skip to content

Commit 6caa25d

Browse files
minor #59782 fix integration tests (DemigodCode)
This PR was squashed before being merged into the 6.4 branch. Discussion ---------- fix integration tests | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT - Removed TagAwareAdapter´Test for Replication - Removed RedisReplicationTest because PhpRedis doesn't support Replication - Fixed Docker configuration for Replication - Fixed order of connection string for Replica - Changed image to bitnami to support Replica Commits ------- 07e6788 fix integration tests
2 parents 5c8c72b + 07e6788 commit 6caa25d

File tree

5 files changed

+33
-110
lines changed

5 files changed

+33
-110
lines changed

.github/workflows/integration-tests.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,25 @@ jobs:
8282
REDIS_MASTER_SET: redis_sentinel
8383
REDIS_SENTINEL_QUORUM: 1
8484
redis-primary:
85-
image: redis:latest
86-
hostname: redis-primary
85+
image: bitnami/redis:latest
8786
ports:
8887
- 16381:6379
89-
88+
env:
89+
ALLOW_EMPTY_PASSWORD: "yes"
90+
REDIS_REPLICATION_MODE: "master"
91+
options: >-
92+
--name=redis-primary
9093
redis-replica:
91-
image: redis:latest
94+
image: bitnami/redis:latest
9295
ports:
9396
- 16382:6379
94-
command: redis-server --slaveof redis-primary 6379
97+
env:
98+
ALLOW_EMPTY_PASSWORD: "yes"
99+
REDIS_REPLICATION_MODE: "slave"
100+
REDIS_MASTER_HOST: redis-primary
101+
REDIS_MASTER_PORT_NUMBER: "6379"
102+
options: >-
103+
--name=redis-replica
95104
memcached:
96105
image: memcached:1.6.5
97106
ports:
@@ -250,7 +259,7 @@ jobs:
250259
REDIS_CLUSTER_HOSTS: 'localhost:7000 localhost:7001 localhost:7002 localhost:7003 localhost:7004 localhost:7005'
251260
REDIS_SENTINEL_HOSTS: 'unreachable-host:26379 localhost:26379 localhost:26379'
252261
REDIS_SENTINEL_SERVICE: redis_sentinel
253-
REDIS_REPLICATION_HOSTS: 'localhost:16381 localhost:16382'
262+
REDIS_REPLICATION_HOSTS: 'localhost:16382 localhost:16381'
254263
MESSENGER_REDIS_DSN: redis://127.0.0.1:7006/messages
255264
MESSENGER_AMQP_DSN: amqp://localhost/%2f/messages
256265
MESSENGER_SQS_DSN: "sqs://localhost:4566/messages?sslmode=disable&poll_timeout=0.01"

src/Symfony/Component/Cache/Tests/Adapter/PredisRedisReplicationAdapterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ public static function setUpBeforeClass(): void
2424
self::markTestSkipped('REDIS_REPLICATION_HOSTS env var is not defined.');
2525
}
2626

27-
self::$redis = RedisAdapter::createConnection('redis:?host['.str_replace(' ', ']&host[', $hosts).'][alias]=master', ['class' => \Predis\Client::class, 'prefix' => 'prefix_']);
27+
self::$redis = RedisAdapter::createConnection('redis:?host['.str_replace(' ', ']&host[', $hosts).'][role]=master', ['replication' => 'predis', 'class' => \Predis\Client::class, 'prefix' => 'prefix_']);
2828
}
2929
}

src/Symfony/Component/Cache/Tests/Adapter/PredisReplicationAdapterTest.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,22 @@ class PredisReplicationAdapterTest extends AbstractRedisAdapterTestCase
1919
public static function setUpBeforeClass(): void
2020
{
2121
parent::setUpBeforeClass();
22-
self::$redis = new \Predis\Client(array_combine(['host', 'port'], explode(':', getenv('REDIS_HOST')) + [1 => 6379]), ['prefix' => 'prefix_']);
22+
23+
if (!$hosts = getenv('REDIS_REPLICATION_HOSTS')) {
24+
self::markTestSkipped('REDIS_REPLICATION_HOSTS env var is not defined.');
25+
}
26+
27+
$hosts = explode(' ', getenv('REDIS_REPLICATION_HOSTS'));
28+
$lastArrayKey = array_key_last($hosts);
29+
$hostTable = [];
30+
foreach($hosts as $key => $host) {
31+
$hostInformation = array_combine(['host', 'port'], explode(':', $host));
32+
if($lastArrayKey === $key) {
33+
$hostInformation['role'] = 'master';
34+
}
35+
$hostTable[] = $hostInformation;
36+
}
37+
38+
self::$redis = new \Predis\Client($hostTable, ['replication' => 'predis', 'prefix' => 'prefix_']);
2339
}
2440
}

src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareReplicationAdapterTest.php

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/Symfony/Component/Cache/Tests/Adapter/RedisReplicationAdapterTest.php

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0