Skip to content

Commit c4761f1

Browse files
committed
Fix tests for MongoDB 7.0
Error message have changed Caused by :: Write conflict during plan execution and yielding is disabled. :: Please retry your operation or multi-document transaction.
1 parent af13eda commit c4761f1

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

.github/workflows/build-ci.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ jobs:
3636
os:
3737
- ubuntu-latest
3838
mongodb:
39-
- '4.0'
40-
- '4.2'
4139
- '4.4'
4240
- '5.0'
41+
- '6.0'
42+
- '7.0'
4343
php:
4444
- '8.1'
4545
- '8.2'
4646
services:
4747
mysql:
48-
image: mysql:5.7
48+
image: mysql:8.0
4949
ports:
5050
- 3307:3306
5151
env:
@@ -58,13 +58,16 @@ jobs:
5858
- name: Create MongoDB Replica Set
5959
run: |
6060
docker run --name mongodb -p 27017:27017 -e MONGO_INITDB_DATABASE=unittest --detach mongo:${{ matrix.mongodb }} mongod --replSet rs --setParameter transactionLifetimeLimitSeconds=5
61-
until docker exec --tty mongodb mongo 127.0.0.1:27017 --eval "db.runCommand({ ping: 1 })"; do
61+
62+
if [[ "6.0" -ge "5.0" ]] then MONGOSH_BIN="mongosh"; else MONGOSH_BIN="mongo"; fi
63+
until docker exec --tty mongodb $MONGOSH_BIN 127.0.0.1:27017 --eval "db.runCommand({ ping: 1 })"; do
6264
sleep 1
6365
done
64-
sudo docker exec --tty mongodb mongo 127.0.0.1:27017 --eval "rs.initiate({\"_id\":\"rs\",\"members\":[{\"_id\":0,\"host\":\"127.0.0.1:27017\" }]})"
66+
sudo docker exec --tty mongodb $MONGOSH_BIN 127.0.0.1:27017 --eval "rs.initiate({\"_id\":\"rs\",\"members\":[{\"_id\":0,\"host\":\"127.0.0.1:27017\" }]})"
6567
- name: Show MongoDB server status
6668
run: |
67-
docker exec --tty mongodb mongo 127.0.0.1:27017 --eval "db.runCommand({ serverStatus: 1 })"
69+
if [[ "6.0" -ge "5.0" ]] then MONGOSH_BIN="mongosh"; else MONGOSH_BIN="mongo"; fi
70+
docker exec --tty mongodb $MONGOSH_BIN 127.0.0.1:27017 --eval "db.runCommand({ serverStatus: 1 })"
6871
- name: "Installing php"
6972
uses: shivammathur/setup-php@v2
7073
with:

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ARG PHP_VERSION=8.1
2-
ARG COMPOSER_VERSION=2.5.4
2+
ARG COMPOSER_VERSION=2.5.8
33

44
FROM php:${PHP_VERSION}-cli
55

tests/TransactionTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,6 @@ public function testTransactionRespectsRepetitionLimit(): void
384384
$this->fail('Expected exception during transaction');
385385
} catch (BulkWriteException $e) {
386386
$this->assertInstanceOf(BulkWriteException::class, $e);
387-
$this->assertStringContainsString('WriteConflict', $e->getMessage());
388387
}
389388

390389
$this->assertSame(2, $timesRun);

0 commit comments

Comments
 (0)