File: 0003-Patch-out-tests-that-use-Spatie-Async.patch

package info (click to toggle)
php-malkusch-lock 2.2.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 412 kB
  • sloc: php: 2,193; makefile: 19
file content (106 lines) | stat: -rw-r--r-- 3,107 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
From: James Valleroy <jvalleroy@mailbox.org>
Date: Thu, 30 Dec 2021 10:29:20 -0500
Subject: Patch out tests that use Spatie\Async

Not currently packaged.

Forwarded: not-needed
---
 tests/mutex/MutexConcurrencyTest.php | 70 ------------------------------------
 1 file changed, 70 deletions(-)

diff --git a/tests/mutex/MutexConcurrencyTest.php b/tests/mutex/MutexConcurrencyTest.php
index 5ea7873..ec12b3b 100644
--- a/tests/mutex/MutexConcurrencyTest.php
+++ b/tests/mutex/MutexConcurrencyTest.php
@@ -6,7 +6,6 @@ use PHPUnit\Framework\Constraint\IsType;
 use PHPUnit\Framework\TestCase;
 use Predis\Client;
 use Redis;
-use Spatie\Async\Pool;
 
 /**
  * Concurrency Tests for Mutex.
@@ -63,52 +62,6 @@ class MutexConcurrencyTest extends TestCase
         return $this->pdo;
     }
 
-    /**
-     * Forks, runs code in the children and wait until all finished.
-     *
-     * @param int $concurrency The amount of forks.
-     * @param callable $code The code for the fork.
-     */
-    private function fork(int $concurrency, callable $code)
-    {
-        $pool = Pool::create();
-
-        for ($i = 0; $i < $concurrency; $i++) {
-            $pool[] = async($code);
-        }
-
-        await($pool);
-    }
-
-    /**
-     * Tests high contention empirically.
-     *
-     * @param callable $code         The counter code.
-     * @param callable $mutexFactory The mutex factory.
-     *
-     * @dataProvider provideTestHighContention
-     * @slowThreshold 1000
-     */
-    public function testHighContention(callable $code, callable $mutexFactory)
-    {
-        $concurrency = 10;
-        $iterations = 1000 / $concurrency;
-        $timeout = $concurrency * 20;
-
-        $this->fork($concurrency, function () use ($mutexFactory, $timeout, $iterations, $code): void {
-            /** @var Mutex $mutex */
-            $mutex = $mutexFactory($timeout);
-            for ($i = 0; $i < $iterations; $i++) {
-                $mutex->synchronized(function () use ($code): void {
-                    $code(1);
-                });
-            }
-        });
-
-        $counter = $code(0);
-        $this->assertEquals($concurrency * $iterations, $counter);
-    }
-
     /**
      * Returns test cases for testHighContention().
      */
@@ -193,29 +146,6 @@ class MutexConcurrencyTest extends TestCase
         return $cases;
     }
 
-    /**
-     * Tests that five processes run sequentially.
-     *
-     * @param callable $mutexFactory The Mutex factory.
-     * @dataProvider provideMutexFactories
-     * @slowThreshold 2000
-     */
-    public function testExecutionIsSerializedWhenLocked(callable $mutexFactory)
-    {
-        $timestamp = hrtime(true);
-
-        $this->fork(5, function () use ($mutexFactory): void {
-            /** @var Mutex $mutex */
-            $mutex = $mutexFactory();
-            $mutex->synchronized(function (): void {
-                \usleep(200000);
-            });
-        });
-
-        $delta = \hrtime(true) - $timestamp;
-        $this->assertGreaterThan(1e9, $delta);
-    }
-
     /**
      * Provides Mutex factories.
      *