@@ -64,10 +64,16 @@ private function closeMajorityConnections()
64
64
}
65
65
}
66
66
67
+ private function closeMinortyConnections ()
68
+ {
69
+ $ numberToClose = ceil (count ($ this ->connections ) / 2 ) - 1 ;
70
+
71
+ foreach ((array ) array_rand ($ this ->connections , $ numberToClose ) as $ keyToClose ) {
72
+ $ this ->connections [$ keyToClose ]->close ();
73
+ }
74
+ }
75
+
67
76
/**
68
- * Tests add() fails.
69
- *
70
- * @test
71
77
* @expectedException \malkusch\lock\exception\LockAcquireException
72
78
* @expectedExceptionCode \malkusch\lock\exception\MutexException::REDIS_NOT_ENOUGH_SERVERS
73
79
*/
@@ -97,15 +103,32 @@ public function testEvalScriptFails()
97
103
* @param $serialization
98
104
* @dataProvider dpSerializationModes
99
105
*/
100
- public function testSyncronizedWorks ($ serialization )
106
+ public function testSynchronizedWorks ($ serialization )
101
107
{
102
108
foreach ($ this ->connections as $ connection ) {
103
109
$ connection ->setOption (Redis::OPT_SERIALIZER , $ serialization );
104
110
}
105
111
106
- $ this ->mutex ->synchronized (function () {
107
- $ this ->assertTrue (true );
108
- });
112
+ $ this ->assertNull ($ this ->mutex ->synchronized (function () {
113
+ return null ;
114
+ }));
115
+ }
116
+
117
+ public function testResistantToPartialClusterFailuresForAcquiringLock ()
118
+ {
119
+ $ this ->closeMinortyConnections ();
120
+
121
+ $ this ->assertNull ($ this ->mutex ->synchronized (function () {
122
+ return null ;
123
+ }));
124
+ }
125
+
126
+ public function testResistantToPartialClusterFailuresForReleasingLock ()
127
+ {
128
+ $ this ->assertNull ($ this ->mutex ->synchronized (function () {
129
+ $ this ->closeMinortyConnections ();
130
+ return null ;
131
+ }));
109
132
}
110
133
111
134
public function dpSerializationModes ()
0 commit comments