File tree 2 files changed +23
-5
lines changed
tests/Test/Prometheus/Storage
2 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -32,10 +32,14 @@ jobs:
32
32
env :
33
33
# The hostname used to communicate with the Redis/Sentinel service containers
34
34
REDIS_HOST : redis
35
+ # The hostname for redis sentinel
35
36
REDIS_SENTINEL_HOST : redis-sentinel
36
37
# The default Redis port
37
38
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
39
43
# MySQL
40
44
DB_DATABASE : test
41
45
DB_USER : root
71
75
with :
72
76
redis-version : ${{ matrix.redis-version }}
73
77
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
+
74
89
- name : Start Redis Sentinel
75
- run : docker run -d --name $REDIS_SENTINEL_HOST -- link redis:redis -v $PWD/sentinel .conf:/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
76
91
77
92
- name : Execute tests (PDO with Sqlite)
78
93
run : vendor/bin/phpunit
Original file line number Diff line number Diff line change @@ -60,7 +60,10 @@ public function itShouldThrowExceptionWhenInjectedRedisIsNotConnected(): void
60
60
{
61
61
$ connection = new \Redis ();
62
62
// @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 ' );
64
67
65
68
self ::expectException (StorageException::class);
66
69
self ::expectExceptionMessageMatches ("/Can't connect to RedisSentinel server \\..*/ " );
@@ -86,8 +89,8 @@ public function itShouldThrowAnExceptionOnPrimaryFailure(): void
86
89
* @test
87
90
*/
88
91
public function itShouldGetMaster (): void
89
- {
90
- $ redis = new Redis (['host ' => ' /dev/null ' ,
92
+ {
93
+ $ redis = new Redis (['host ' => REDIS_HOST ,
91
94
'sentinel ' => ['host ' => REDIS_SENTINEL_HOST , 'enable ' => true , 'service ' => 'myprimary ' ]
92
95
]);
93
96
You can’t perform that action at this time.
0 commit comments