@@ -77,8 +77,6 @@ final class UnifiedTestRunner
77
77
/** @var callable(EntityMap):void */
78
78
private $ entityMapObserver ;
79
79
80
- private ?FailPointObserver $ failPointObserver = null ;
81
-
82
80
private ServerParameterHelper $ serverParameterHelper ;
83
81
84
82
public function __construct (string $ internalClientUri )
@@ -150,9 +148,6 @@ private function doSetUp(): void
150
148
* after transient error within a transaction" pinning test causes the
151
149
* subsequent transaction test to block. */
152
150
$ this ->killAllSessions ();
153
-
154
- $ this ->failPointObserver = new FailPointObserver ();
155
- $ this ->failPointObserver ->start ();
156
151
}
157
152
158
153
private function doTearDown (bool $ hasFailed ): void
@@ -163,9 +158,6 @@ private function doTearDown(bool $hasFailed): void
163
158
$ this ->killAllSessions ();
164
159
}
165
160
166
- $ this ->failPointObserver ->stop ();
167
- $ this ->failPointObserver ->disableFailPoints ();
168
-
169
161
/* Manually invoking garbage collection since each test is prone to
170
162
* create cycles (perhaps due to EntityMap), which can leak and prevent
171
163
* sessions from being released back into the pool. */
@@ -216,13 +208,17 @@ private function doTestCase(stdClass $test, string $schemaVersion, ?array $runOn
216
208
$ context ->startEventObservers ();
217
209
$ context ->startEventCollectors ();
218
210
219
- foreach ($ test ->operations as $ o ) {
220
- $ operation = new Operation ($ o , $ context );
221
- $ operation ->assert ();
222
- }
211
+ try {
212
+ foreach ($ test ->operations as $ o ) {
213
+ $ operation = new Operation ($ o , $ context );
214
+ $ operation ->assert ();
215
+ }
223
216
224
- $ context ->stopEventObservers ();
225
- $ context ->stopEventCollectors ();
217
+ $ context ->stopEventObservers ();
218
+ $ context ->stopEventCollectors ();
219
+ } finally {
220
+ $ this ->disableFailPoints ($ context ->getFailPoints ());
221
+ }
226
222
227
223
if (isset ($ test ->expectEvents )) {
228
224
assertIsArray ($ test ->expectEvents );
@@ -235,6 +231,15 @@ private function doTestCase(stdClass $test, string $schemaVersion, ?array $runOn
235
231
}
236
232
}
237
233
234
+ /** @param list<array{failPoint: stdClass, server: Server}> $failPoints */
235
+ private function disableFailPoints (array $ failPoints ): void
236
+ {
237
+ foreach ($ failPoints as ['failPoint ' => $ failPoint , 'server ' => $ server ]) {
238
+ $ operation = new DatabaseCommand ('admin ' , ['configureFailPoint ' => $ failPoint , 'mode ' => 'off ' ]);
239
+ $ operation ->execute ($ server );
240
+ }
241
+ }
242
+
238
243
/**
239
244
* Checks server version and topology requirements.
240
245
*
0 commit comments