Skip to content

Commit e1a542d

Browse files
committed
tests
tests tests tests tests tests tests tests tests cleaning
1 parent a7915ff commit e1a542d

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

.github/workflows/tests.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,14 @@ jobs:
3232
env:
3333
# The hostname used to communicate with the Redis/Sentinel service containers
3434
REDIS_HOST: redis
35+
# The hostname for redis sentinel
3536
REDIS_SENTINEL_HOST: redis-sentinel
3637
# The default Redis port
3738
REDIS_PORT: 6379
38-
REDIS_SENTINEL_PORT: 6379
39+
# The default Redis Sentinel port
40+
REDIS_SENTINEL_PORT: 26379
41+
# The default Redis Sentinel primary
42+
REDIS_SENTINEL_SERVICE: myprimary
3943
# MySQL
4044
DB_DATABASE: test
4145
DB_USER: root
@@ -71,8 +75,19 @@ jobs:
7175
with:
7276
redis-version: ${{ matrix.redis-version }}
7377

78+
- name: Generate Redis Sentinel conf compatible with redis 5 assuming 127.0.0.1 (no resolve hostname)
79+
run: |
80+
REDIS_SENTINEL_IP=127.0.0.1
81+
cat <<EOF > sentinel5.conf
82+
port ${{ env.REDIS_SENTINEL_PORT }}
83+
sentinel monitor ${{ env.REDIS_SENTINEL_SERVICE }} $REDIS_SENTINEL_IP ${{ env.REDIS_PORT }} 2
84+
sentinel down-after-milliseconds ${{ env.REDIS_SENTINEL_SERVICE }} 10000
85+
sentinel failover-timeout ${{ env.REDIS_SENTINEL_SERVICE }} 180000
86+
sentinel parallel-syncs ${{ env.REDIS_SENTINEL_SERVICE }} 2
87+
EOF
88+
7489
- name: Start Redis Sentinel
75-
run: docker run -d --name ${{env.REDIS_SENTINEL_HOST}} -p 26379:26379 --link redis:redis -v $PWD:/sentinel.conf:/data/sentinel.conf redis:${{ matrix.redis-version }} redis-server sentinel.conf --sentinel
90+
run: docker run -d --name ${{env.REDIS_SENTINEL_HOST}} -p 26379:26379 --link redis:redis -v $PWD/sentinel5.conf:/data/sentinel.conf redis:${{ matrix.redis-version }} redis-server sentinel.conf --sentinel
7691

7792
- name: Execute tests (PDO with Sqlite)
7893
run: vendor/bin/phpunit

src/Prometheus/Storage/RedisSentinel.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ private function initSentinel(): \RedisSentinel
140140
$options['ssl'] = $ssl;
141141
}
142142
// @phpstan-ignore arguments.count, argument.type
143-
echo(var_export($options,true));
144143
return new \RedisSentinel($options);
145144
}
146145

tests/Test/Prometheus/Storage/RedisSentinelTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ public function itShouldThrowExceptionWhenInjectedRedisIsNotConnected(): void
6060
{
6161
$connection = new \Redis();
6262
// @phpstan-ignore arguments.count
63-
$sentinel = new \RedisSentinel();
63+
64+
$sentinel = version_compare((string)phpversion('redis'), '6.0', '>=') ?
65+
new \RedisSentinel(['host' => '/dev/null']) :
66+
new \RedisSentinel('/dev/null');
6467

6568
self::expectException(StorageException::class);
6669
self::expectExceptionMessageMatches("/Can't connect to RedisSentinel server\\..*/");
@@ -87,7 +90,6 @@ public function itShouldThrowAnExceptionOnPrimaryFailure(): void
8790
*/
8891
public function itShouldGetMaster(): void
8992
{
90-
echo(REDIS_SENTINEL_HOST);
9193
$redis = new Redis(['host' => REDIS_HOST,
9294
'sentinel' => ['host' => REDIS_SENTINEL_HOST, 'enable' => true, 'service' => 'myprimary']
9395
]);

0 commit comments

Comments
 (0)