@@ -34,7 +34,7 @@ protected function setUp(): void
34
34
35
35
try {
36
36
$ this ->redis = new \Redis ();
37
- $ this ->connection = Connection::fromDsn (getenv ('MESSENGER_REDIS_DSN ' ), ['delete_after_ack ' => true ], $ this ->redis );
37
+ $ this ->connection = Connection::fromDsn (getenv ('MESSENGER_REDIS_DSN ' ), ['delete_after_ack ' => true , ' sentinel_master ' => getenv ( ' MESSENGER_REDIS_SENTINEL_MASTER ' ) ], $ this ->redis );
38
38
$ this ->connection ->cleanup ();
39
39
$ this ->connection ->setup ();
40
40
} catch (\Exception $ e ) {
@@ -110,8 +110,7 @@ public function testConnectionSendDelayedMessagesWithSameContent()
110
110
public function testConnectionBelowRedeliverTimeout ()
111
111
{
112
112
// lower redeliver timeout and claim interval
113
- $ connection = Connection::fromDsn (getenv ('MESSENGER_REDIS_DSN ' ), ['delete_after_ack ' => true ], $ this ->redis );
114
-
113
+ $ connection = Connection::fromDsn (getenv ('MESSENGER_REDIS_DSN ' ), ['delete_after_ack ' => true , 'sentinel_master ' => getenv ('MESSENGER_REDIS_SENTINEL_MASTER ' )], $ this ->redis );
115
114
$ connection ->cleanup ();
116
115
$ connection ->setup ();
117
116
@@ -138,7 +137,7 @@ public function testConnectionClaimAndRedeliver()
138
137
// lower redeliver timeout and claim interval
139
138
$ connection = Connection::fromDsn (
140
139
getenv ('MESSENGER_REDIS_DSN ' ),
141
- ['redeliver_timeout ' => 0 , 'claim_interval ' => 500 , 'delete_after_ack ' => true ],
140
+ ['redeliver_timeout ' => 0 , 'claim_interval ' => 500 , 'delete_after_ack ' => true , ' sentinel_master ' => getenv ( ' MESSENGER_REDIS_SENTINEL_MASTER ' ) ],
142
141
$ this ->redis
143
142
);
144
143
@@ -194,7 +193,7 @@ public function testLazyCluster()
194
193
public function testLazy ()
195
194
{
196
195
$ redis = new \Redis ();
197
- $ connection = Connection::fromDsn ('redis://localhost/messenger-lazy?lazy=1 ' , ['delete_after_ack ' => true ], $ redis );
196
+ $ connection = Connection::fromDsn ('redis://localhost/messenger-lazy?lazy=1 ' , ['delete_after_ack ' => true , ' sentinel_master ' => getenv ( ' MESSENGER_REDIS_SENTINEL_MASTER ' ) ], $ redis );
198
197
199
198
$ connection ->add ('1 ' , []);
200
199
$ this ->assertNotEmpty ($ message = $ connection ->get ());
@@ -207,7 +206,7 @@ public function testDbIndex()
207
206
{
208
207
$ redis = new \Redis ();
209
208
210
- Connection::fromDsn ('redis://localhost/queue?dbindex=2 ' , ['delete_after_ack ' => true ], $ redis );
209
+ Connection::fromDsn ('redis://localhost/queue?dbindex=2 ' , ['delete_after_ack ' => true , ' sentinel_master ' => getenv ( ' MESSENGER_REDIS_SENTINEL_MASTER ' ) ], $ redis );
211
210
212
211
$ this ->assertSame (2 , $ redis ->getDbNum ());
213
212
}
@@ -223,13 +222,13 @@ public function testFromDsnWithMultipleHosts()
223
222
}, $ hosts );
224
223
$ dsn = implode (', ' , $ dsn );
225
224
226
- $ this ->assertInstanceOf (Connection::class, Connection::fromDsn ($ dsn , ['delete_after_ack ' => true ]));
225
+ $ this ->assertInstanceOf (Connection::class, Connection::fromDsn ($ dsn , ['delete_after_ack ' => true , ' sentinel_master ' => getenv ( ' MESSENGER_REDIS_SENTINEL_MASTER ' ) ]));
227
226
}
228
227
229
228
public function testJsonError ()
230
229
{
231
230
$ redis = new \Redis ();
232
- $ connection = Connection::fromDsn ('redis://localhost/json-error ' , ['delete_after_ack ' => true ], $ redis );
231
+ $ connection = Connection::fromDsn ('redis://localhost/json-error ' , ['delete_after_ack ' => true , ' sentinel_master ' => getenv ( ' MESSENGER_REDIS_SENTINEL_MASTER ' ) ], $ redis );
233
232
try {
234
233
$ connection ->add ("\xB1\x31" , []);
235
234
} catch (TransportException $ e ) {
@@ -242,7 +241,7 @@ public function testGetNonBlocking()
242
241
{
243
242
$ redis = new \Redis ();
244
243
245
- $ connection = Connection::fromDsn ('redis://localhost/messenger-getnonblocking ' , ['delete_after_ack ' => true ], $ redis );
244
+ $ connection = Connection::fromDsn ('redis://localhost/messenger-getnonblocking ' , ['delete_after_ack ' => true , ' sentinel_master ' => getenv ( ' MESSENGER_REDIS_SENTINEL_MASTER ' ) ], $ redis );
246
245
247
246
$ this ->assertNull ($ connection ->get ()); // no message, should return null immediately
248
247
$ connection ->add ('1 ' , []);
@@ -254,15 +253,15 @@ public function testGetNonBlocking()
254
253
public function testGetAfterReject ()
255
254
{
256
255
$ redis = new \Redis ();
257
- $ connection = Connection::fromDsn ('redis://localhost/messenger-rejectthenget ' , ['delete_after_ack ' => true ], $ redis );
256
+ $ connection = Connection::fromDsn ('redis://localhost/messenger-rejectthenget ' , ['delete_after_ack ' => true , ' sentinel_master ' => getenv ( ' MESSENGER_REDIS_SENTINEL_MASTER ' ) ], $ redis );
258
257
259
258
$ connection ->add ('1 ' , []);
260
259
$ connection ->add ('2 ' , []);
261
260
262
261
$ failing = $ connection ->get ();
263
262
$ connection ->reject ($ failing ['id ' ]);
264
263
265
- $ connection = Connection::fromDsn ('redis://localhost/messenger-rejectthenget ' , ['delete_after_ack ' => true ]);
264
+ $ connection = Connection::fromDsn ('redis://localhost/messenger-rejectthenget ' , ['delete_after_ack ' => true , ' sentinel_master ' => getenv ( ' MESSENGER_REDIS_SENTINEL_MASTER ' ) ]);
266
265
$ this ->assertNotNull ($ connection ->get ());
267
266
268
267
$ redis ->del ('messenger-rejectthenget ' );
0 commit comments