Skip to content

Commit 80fb4da

Browse files
Add file locking integration tests for php-wasm/node (#2908)
## Motivation for the change, related issues We have automated tests for our file lock manager but no integration tests to demonstrate locking is working between `@php-wasm/node` instances. Let's fix that. ## Implementation details This PR: - Adds automated tests for file locking within `@php-wasm/node` - Fixes a bug discovered by the additional tests: releasing flock() locks when the associated file descriptor is closed. The tests coordinate between two or more concurrent `@php-wasm` instances using a simple text file to gate the stages. For example, for php instances php1 and php2 testing exclusive locking: - File initially contains "php1-locking" - php1 starts without waiting - php2 waits until file contains "php1-waiting-for-php2-to-try" - php1 obtains an exclusive lock on a SQLite DB and sets file contents to "php1-waiting-for-php2-to-try" - php1 waits until file contains "php2-ready-for-unlock" - php2 attempts to write to DB, records the outcome, and sets file contents to "php2-ready-for-unlock" - php2 waits until file contains "php1-unlocked" - php1 unlocks the DB, sets file contents to "php1-unlocked", and exits - php2 repeats its attempt to right the DB, records the outcome, echoes its results, and exits - the test case asserts expected outcome Maybe there is a better way to coordinate between instances, but so far, this seemed the most straightforward. Once these tests are fleshed out, we can probably add nearly identical tests for Playground CLI, but run the scripts via HTTP requests. ## Testing Instructions (or ideally a Blueprint) - CI
1 parent 8c80ae9 commit 80fb4da

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+6166
-2352
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,24 @@ jobs:
2929
fail-fast: false
3030
matrix:
3131
include:
32-
- name: test-unit-asyncify (1/8)
32+
- name: test-unit-asyncify (1/9)
3333
target: test
34-
- name: test-unit-asyncify (2/8)
34+
- name: test-unit-asyncify (2/9)
3535
target: test-asyncify
36-
- name: test-unit-asyncify (3/8)
36+
- name: test-unit-asyncify (3/9)
3737
target: test-php-file-get-contents-asyncify
38-
- name: test-unit-asyncify (4/8)
38+
- name: test-unit-asyncify (4/9)
3939
target: test-php-fopen-asyncify
40-
- name: test-unit-asyncify (5/8)
40+
- name: test-unit-asyncify (5/9)
4141
target: test-php-fsockopen-asyncify
42-
- name: test-unit-asyncify (6/8)
42+
- name: test-unit-asyncify (6/9)
4343
target: test-php-gethostbyname-asyncify
44-
- name: test-unit-asyncify (7/8)
44+
- name: test-unit-asyncify (7/9)
4545
target: test-php-mysqli-asyncify
46-
- name: test-unit-asyncify (8/8)
46+
- name: test-unit-asyncify (8/9)
4747
target: test-php-sqlite3-asyncify
48+
- name: test-unit-asyncify (9/9)
49+
target: test-php-file-locking-asyncify
4850
name: ${{ matrix.name }}
4951
services:
5052
mysql:
@@ -79,20 +81,22 @@ jobs:
7981
fail-fast: false
8082
matrix:
8183
include:
82-
- name: test-unit-jspi (1/7)
84+
- name: test-unit-jspi (1/8)
8385
target: test-jspi
84-
- name: test-unit-jspi (2/7)
86+
- name: test-unit-jspi (2/8)
8587
target: test-php-file-get-contents-jspi
86-
- name: test-unit-jspi (3/7)
88+
- name: test-unit-jspi (3/8)
8789
target: test-php-fopen-jspi
88-
- name: test-unit-jspi (4/7)
90+
- name: test-unit-jspi (4/8)
8991
target: test-php-fsockopen-jspi
90-
- name: test-unit-jspi (5/7)
92+
- name: test-unit-jspi (5/8)
9193
target: test-php-gethostbyname-jspi
92-
- name: test-unit-jspi (6/7)
94+
- name: test-unit-jspi (6/8)
9395
target: test-php-mysqli-jspi
94-
- name: test-unit-jspi (7/7)
96+
- name: test-unit-jspi (7/8)
9597
target: test-php-sqlite3-jspi
98+
- name: test-unit-jspi (8/8)
99+
target: test-php-file-locking-jspi
96100
name: ${{ matrix.name }}
97101
services:
98102
mysql:

0 commit comments

Comments
 (0)