From 266a21a116c7a273245777df7762c68b58333287 Mon Sep 17 00:00:00 2001 From: alexbusu-motork <149699605+alexbusu-motork@users.noreply.github.com> Date: Wed, 3 Apr 2024 16:36:16 +0100 Subject: [PATCH 01/12] Bugfix in `RdKafkaProducer:flush()` method Avoid TypeError in `RdKafkaProducer::flush()` --- pkg/rdkafka/RdKafkaProducer.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/rdkafka/RdKafkaProducer.php b/pkg/rdkafka/RdKafkaProducer.php index 64b9ea3a7..69411df02 100644 --- a/pkg/rdkafka/RdKafkaProducer.php +++ b/pkg/rdkafka/RdKafkaProducer.php @@ -121,5 +121,7 @@ public function flush(int $timeout): ?int if (method_exists($this->producer, 'flush')) { return $this->producer->flush($timeout); } + + return null; } } From 95bed4495e1e9220eedcb1f3953bdf131694ac84 Mon Sep 17 00:00:00 2001 From: alexbusu-motork <149699605+alexbusu-motork@users.noreply.github.com> Date: Wed, 3 Apr 2024 21:07:45 +0100 Subject: [PATCH 02/12] make php-cs-fixer happy --- pkg/rdkafka/RdKafkaProducer.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/rdkafka/RdKafkaProducer.php b/pkg/rdkafka/RdKafkaProducer.php index 69411df02..1824f14e9 100644 --- a/pkg/rdkafka/RdKafkaProducer.php +++ b/pkg/rdkafka/RdKafkaProducer.php @@ -70,7 +70,7 @@ public function send(Destination $destination, Message $message): void /** * @return RdKafkaProducer */ - public function setDeliveryDelay(int $deliveryDelay = null): Producer + public function setDeliveryDelay(?int $deliveryDelay = null): Producer { if (null === $deliveryDelay) { return $this; @@ -87,7 +87,7 @@ public function getDeliveryDelay(): ?int /** * @return RdKafkaProducer */ - public function setPriority(int $priority = null): Producer + public function setPriority(?int $priority = null): Producer { if (null === $priority) { return $this; @@ -101,7 +101,7 @@ public function getPriority(): ?int return null; } - public function setTimeToLive(int $timeToLive = null): Producer + public function setTimeToLive(?int $timeToLive = null): Producer { if (null === $timeToLive) { return $this; From a52cd38cd4b6dff7445274ac5c28e63c5ffb018d Mon Sep 17 00:00:00 2001 From: Alexandru Busuioc Date: Mon, 8 Apr 2024 15:11:40 +0100 Subject: [PATCH 03/12] Fix localstack env --- docker-compose.yml | 17 +++++++++-------- docker/bin/test.sh | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index c5fa5545b..4e30f52ad 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -38,16 +38,16 @@ services: - PREDIS_DSN=redis+predis://redis - PHPREDIS_DSN=redis+phpredis://redis - GPS_DSN=gps:?projectId=mqdev&emulatorHost=http://google-pubsub:8085 - - SQS_DSN=sqs:?key=key&secret=secret®ion=us-east-1&endpoint=http://localstack:4576&version=latest - - SNS_DSN=sns:?key=key&secret=secret®ion=us-east-1&endpoint=http://localstack:4575&version=latest - - SNSQS_DSN=snsqs:?key=key&secret=secret®ion=us-east-1&sns_endpoint=http://localstack:4575&sqs_endpoint=http://localstack:4576&version=latest + - SQS_DSN=sqs:?key=key&secret=secret®ion=us-east-1&endpoint=http://localstack:4566&version=latest + - SNS_DSN=sns:?key=key&secret=secret®ion=us-east-1&endpoint=http://localstack:4566&version=latest + - SNSQS_DSN=snsqs:?key=key&secret=secret®ion=us-east-1&sns_endpoint=http://localstack:4566&sqs_endpoint=http://localstack:4566&version=latest - WAMP_DSN=wamp://thruway:9090 - REDIS_HOST=redis - REDIS_PORT=6379 - AWS_SQS_KEY=key - AWS_SQS_SECRET=secret - AWS_SQS_REGION=us-east-1 - - AWS_SQS_ENDPOINT=http://localstack:4576 + - AWS_SQS_ENDPOINT=http://localstack:4566 - AWS_SQS_VERSION=latest - BEANSTALKD_DSN=beanstalk://beanstalkd:11300 - GEARMAN_DSN=gearman://gearmand:4730 @@ -127,13 +127,14 @@ services: - '9090:9090' localstack: - image: 'localstack/localstack:0.8.10' + image: 'localstack/localstack:3.3.0' ports: - - '4576:4576' - - '4575:4575' + - '4566:4566' environment: - HOSTNAME_EXTERNAL: 'localstack' + LOCALSTACK_HOST: 'localstack' SERVICES: 'sqs,sns' + EAGER_SERVICE_LOADING: '1' + DEFAULT_REGION: 'us-east-1' influxdb: image: 'influxdb:latest' diff --git a/docker/bin/test.sh b/docker/bin/test.sh index 2070584bb..cfc94aab5 100755 --- a/docker/bin/test.sh +++ b/docker/bin/test.sh @@ -39,7 +39,7 @@ waitForService gearmand 4730 50 waitForService kafka 9092 50 waitForService mongo 27017 50 waitForService thruway 9090 50 -waitForService localstack 4576 50 +waitForService localstack 4566 50 php docker/bin/refresh-mysql-database.php || exit 1 php docker/bin/refresh-postgres-database.php || exit 1 From d37ff6b05d7700d9fed6d46d9207fdec8351de14 Mon Sep 17 00:00:00 2001 From: Alexandru Busuioc Date: Tue, 18 Jun 2024 10:30:14 +0100 Subject: [PATCH 04/12] Fix localstack readiness check --- docker/bin/test.sh | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/docker/bin/test.sh b/docker/bin/test.sh index cfc94aab5..e7c05de21 100755 --- a/docker/bin/test.sh +++ b/docker/bin/test.sh @@ -27,6 +27,34 @@ function waitForService() printf "service is online %s:%s\n" $1 $2 } +function waitForServiceLocalStack() +{ + waitForService localstack 4566 $1 + + ATTEMPTS=0 + RESPONSE='' + READY=0 + until [ $READY = 1 ]; do + printf "check readiness for service localstack:4566\n" + RESPONSE=$(curl -s http://localstack:4566/_localstack/health) + if [[ $RESPONSE == *'"sns": "running"'* && $RESPONSE == *'"sqs": "running"'* ]]; then + READY=1 + fi + ((ATTEMPTS++)) + if [ $ATTEMPTS -ge $2 ]; then + printf "service is not ready localstack:4566\n" + exit 1 + fi + if [ "$FORCE_EXIT" = true ]; then + exit; + fi + + sleep 1 + done + + printf "service is ready localstack:4566\n" +} + trap "FORCE_EXIT=true" SIGTERM SIGINT waitForService rabbitmq 5672 50 @@ -39,7 +67,7 @@ waitForService gearmand 4730 50 waitForService kafka 9092 50 waitForService mongo 27017 50 waitForService thruway 9090 50 -waitForService localstack 4566 50 +waitForServiceLocalStack 50 50 php docker/bin/refresh-mysql-database.php || exit 1 php docker/bin/refresh-postgres-database.php || exit 1 From 628ee291518579d6117749be9c90c9eb5aecbc3e Mon Sep 17 00:00:00 2001 From: Alexandru Busuioc Date: Wed, 19 Jun 2024 11:54:21 +0100 Subject: [PATCH 05/12] Fix tests and test setup --- bin/dev | 2 +- docker-compose.yml | 5 +++++ .../Tests/Functional/AmqpCommonUseCasesTest.php | 12 ++++++------ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/bin/dev b/bin/dev index a50b7ad66..edbb37882 100755 --- a/bin/dev +++ b/bin/dev @@ -15,7 +15,7 @@ while getopts "bustefdp" OPTION; do docker-compose stop ;; e) - docker exec -it mqdev_dev_1 /bin/bash + docker exec -it enqueue-dev-dev-1 /bin/bash ;; f) ./bin/php-cs-fixer fix diff --git a/docker-compose.yml b/docker-compose.yml index 4e30f52ad..c67b1f8e9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -135,6 +135,11 @@ services: SERVICES: 'sqs,sns' EAGER_SERVICE_LOADING: '1' DEFAULT_REGION: 'us-east-1' + networks: + default: + aliases: + - 'localstack' + - 'sqs.us-east-1.localstack' influxdb: image: 'influxdb:latest' diff --git a/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php b/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php index a90b1d306..81c1cf819 100644 --- a/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php +++ b/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php @@ -158,7 +158,7 @@ public function testConsumerReceiveMessageFromTopicDirectly() $this->amqpContext->declareTopic($topic); $consumer = $this->amqpContext->createConsumer($topic); - //guard + // guard $this->assertNull($consumer->receive(1000)); $message = $this->amqpContext->createMessage(__METHOD__); @@ -168,9 +168,9 @@ public function testConsumerReceiveMessageFromTopicDirectly() $actualMessage = $consumer->receive(1000); $this->assertInstanceOf(AmqpMessage::class, $actualMessage); - $consumer->acknowledge($message); + $consumer->acknowledge($actualMessage); - $this->assertEquals(__METHOD__, $message->getBody()); + $this->assertEquals(__METHOD__, $actualMessage->getBody()); } public function testConsumerReceiveMessageWithZeroTimeout() @@ -181,7 +181,7 @@ public function testConsumerReceiveMessageWithZeroTimeout() $this->amqpContext->declareTopic($topic); $consumer = $this->amqpContext->createConsumer($topic); - //guard + // guard $this->assertNull($consumer->receive(1000)); $message = $this->amqpContext->createMessage(__METHOD__); @@ -192,9 +192,9 @@ public function testConsumerReceiveMessageWithZeroTimeout() $actualMessage = $consumer->receive(0); $this->assertInstanceOf(AmqpMessage::class, $actualMessage); - $consumer->acknowledge($message); + $consumer->acknowledge($actualMessage); - $this->assertEquals(__METHOD__, $message->getBody()); + $this->assertEquals(__METHOD__, $actualMessage->getBody()); } public function testPurgeMessagesFromQueue() From fe314c4bdfb1efa7fcce9f5ea4b933750baa3ca1 Mon Sep 17 00:00:00 2001 From: Alexandru Busuioc Date: Wed, 19 Jun 2024 12:07:04 +0100 Subject: [PATCH 06/12] Fix tests and test setup --- pkg/snsqs/Tests/SnsQsProducerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/snsqs/Tests/SnsQsProducerTest.php b/pkg/snsqs/Tests/SnsQsProducerTest.php index aa3e28971..f0558b522 100644 --- a/pkg/snsqs/Tests/SnsQsProducerTest.php +++ b/pkg/snsqs/Tests/SnsQsProducerTest.php @@ -40,7 +40,7 @@ public function testCouldBeConstructedWithRequiredArguments() public function testShouldThrowIfMessageIsInvalidType() { $this->expectException(InvalidMessageException::class); - $this->expectExceptionMessage('The message must be an instance of Enqueue\SnsQs\SnsQsMessage but it is Double\Message\P4'); + $this->expectExceptionMessageMatches('/The message must be an instance of Enqueue\\\\SnsQs\\\\SnsQsMessage but it is Double\\\\Message\\\\P\d+/'); $producer = new SnsQsProducer($this->createSnsContextMock(), $this->createSqsContextMock()); From 12d3738396a89260a6a0c6172e2b58b03f1490c8 Mon Sep 17 00:00:00 2001 From: Alexandru Busuioc Date: Mon, 5 Aug 2024 15:31:07 +0100 Subject: [PATCH 07/12] replace `docker-compose` (v1) with `docker compose` (v2) --- bin/changelog | 4 ++-- bin/dev | 8 ++++---- bin/test.sh | 2 +- docs/contribution.md | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bin/changelog b/bin/changelog index 8a9296175..b2dff8b4f 100755 --- a/bin/changelog +++ b/bin/changelog @@ -8,6 +8,6 @@ then exit 1 fi -docker-compose run -e CHANGELOG_GITHUB_TOKEN=${CHANGELOG_GITHUB_TOKEN:-""} --workdir="/mqdev" --rm generate-changelog github_changelog_generator --future-release "$1" --no-issues --unreleased-only --output "CHANGELOG_FUTURE.md" +docker compose run -e CHANGELOG_GITHUB_TOKEN=${CHANGELOG_GITHUB_TOKEN:-""} --workdir="/mqdev" --rm generate-changelog github_changelog_generator --future-release "$1" --no-issues --unreleased-only --output "CHANGELOG_FUTURE.md" -#git add CHANGELOG.md && git commit -m "Release $1" -S && git push origin "$CURRENT_BRANCH" \ No newline at end of file +#git add CHANGELOG.md && git commit -m "Release $1" -S && git push origin "$CURRENT_BRANCH" diff --git a/bin/dev b/bin/dev index edbb37882..cc77b58df 100755 --- a/bin/dev +++ b/bin/dev @@ -6,13 +6,13 @@ set -e while getopts "bustefdp" OPTION; do case $OPTION in b) - docker-compose pull -q && docker-compose build + docker compose pull -q && docker compose build ;; u) - docker-compose up + docker compose up ;; s) - docker-compose stop + docker compose stop ;; e) docker exec -it enqueue-dev-dev-1 /bin/bash @@ -21,7 +21,7 @@ while getopts "bustefdp" OPTION; do ./bin/php-cs-fixer fix ;; - d) docker-compose run --workdir="/mqdev" --rm dev php pkg/enqueue-bundle/Tests/Functional/app/console.php config:dump-reference enqueue -vvv + d) docker compose run --workdir="/mqdev" --rm dev php pkg/enqueue-bundle/Tests/Functional/app/console.php config:dump-reference enqueue -vvv ;; \?) echo "Invalid option: -$OPTARG" >&2 diff --git a/bin/test.sh b/bin/test.sh index f392e616b..5cb858ad6 100755 --- a/bin/test.sh +++ b/bin/test.sh @@ -3,4 +3,4 @@ set -x set -e -docker-compose run --workdir="/mqdev" --rm dev ./docker/bin/test.sh $@ +docker compose run --workdir="/mqdev" --rm dev ./docker/bin/test.sh $@ diff --git a/docs/contribution.md b/docs/contribution.md index 455f6950e..68d051fc5 100644 --- a/docs/contribution.md +++ b/docs/contribution.md @@ -49,6 +49,6 @@ Once everything is done open a pull request on official repository. ## WTF?! -* If you get `rabbitmqssl: forward host lookup failed: Unknown host, wait for service rabbitmqssl:5671` do `docker-compose down`. +* If you get `rabbitmqssl: forward host lookup failed: Unknown host, wait for service rabbitmqssl:5671` do `docker compose down`. [back to index](index.md) From 61fe6ca292e337745df51f44efb0618955ecb9ef Mon Sep 17 00:00:00 2001 From: Alexandru Busuioc Date: Mon, 5 Aug 2024 16:57:23 +0100 Subject: [PATCH 08/12] =?UTF-8?q?update=20localstack=20=F0=9F=99=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index c67b1f8e9..5fded0301 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -127,7 +127,7 @@ services: - '9090:9090' localstack: - image: 'localstack/localstack:3.3.0' + image: 'localstack/localstack:3.6.0' ports: - '4566:4566' environment: From 5fc6198bffd1eb1a4b8d9c99a9de80c727d742d6 Mon Sep 17 00:00:00 2001 From: Alexandru Busuioc Date: Mon, 5 Aug 2024 17:56:45 +0100 Subject: [PATCH 09/12] update localstack --- docker-compose.yml | 4 +--- docker/bin/test.sh | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 5fded0301..5a6761358 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: '2' - services: dev: # when image publishing gets sorted: @@ -134,12 +132,12 @@ services: LOCALSTACK_HOST: 'localstack' SERVICES: 'sqs,sns' EAGER_SERVICE_LOADING: '1' - DEFAULT_REGION: 'us-east-1' networks: default: aliases: - 'localstack' - 'sqs.us-east-1.localstack' + - 'snsqs.us-east-1.localstack' influxdb: image: 'influxdb:latest' diff --git a/docker/bin/test.sh b/docker/bin/test.sh index e7c05de21..736ccdb65 100755 --- a/docker/bin/test.sh +++ b/docker/bin/test.sh @@ -37,7 +37,7 @@ function waitForServiceLocalStack() until [ $READY = 1 ]; do printf "check readiness for service localstack:4566\n" RESPONSE=$(curl -s http://localstack:4566/_localstack/health) - if [[ $RESPONSE == *'"sns": "running"'* && $RESPONSE == *'"sqs": "running"'* ]]; then + if [[ $RESPONSE == *'"sns": "available"'* && $RESPONSE == *'"sqs": "available"'* ]]; then READY=1 fi ((ATTEMPTS++)) From 27c40433f63a5f9a3f4d7e577098f9f972285eca Mon Sep 17 00:00:00 2001 From: Alexandru Busuioc Date: Tue, 6 Aug 2024 08:45:39 +0100 Subject: [PATCH 10/12] update snsqs params --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 5a6761358..34d40486b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -38,7 +38,7 @@ services: - GPS_DSN=gps:?projectId=mqdev&emulatorHost=http://google-pubsub:8085 - SQS_DSN=sqs:?key=key&secret=secret®ion=us-east-1&endpoint=http://localstack:4566&version=latest - SNS_DSN=sns:?key=key&secret=secret®ion=us-east-1&endpoint=http://localstack:4566&version=latest - - SNSQS_DSN=snsqs:?key=key&secret=secret®ion=us-east-1&sns_endpoint=http://localstack:4566&sqs_endpoint=http://localstack:4566&version=latest + - SNSQS_DSN=snsqs:?key=key&secret=secret®ion=us-east-1&endpoint=http://localstack:4566&version=latest - WAMP_DSN=wamp://thruway:9090 - REDIS_HOST=redis - REDIS_PORT=6379 From c31ece159dc195a5d052a40390351516d257d6c8 Mon Sep 17 00:00:00 2001 From: Alexandru Busuioc Date: Wed, 7 Aug 2024 09:28:10 +0100 Subject: [PATCH 11/12] update the workflow --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c29d8430c..15c04a8fa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -177,7 +177,5 @@ jobs: # TODO: convert these two steps into one w/o excludes when Gearman extension gets a release for PHP 8.1 # See https://github.com/php/pecl-networking-gearman/issues/16 - run: bin/test.sh - if: ${{ matrix.php != '8.1' && matrix.php != '8.2' }} - run: bin/test.sh --exclude-group=gearman - if: ${{ matrix.php == '8.1' && matrix.php != '8.2' }} From ef878b3d6df1b1218bf4c7e6be164f31e4818b1b Mon Sep 17 00:00:00 2001 From: Alexandru Busuioc Date: Wed, 7 Aug 2024 10:04:47 +0100 Subject: [PATCH 12/12] Revert "update the workflow" This reverts commit c31ece159dc195a5d052a40390351516d257d6c8. --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 15c04a8fa..c29d8430c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -177,5 +177,7 @@ jobs: # TODO: convert these two steps into one w/o excludes when Gearman extension gets a release for PHP 8.1 # See https://github.com/php/pecl-networking-gearman/issues/16 - run: bin/test.sh + if: ${{ matrix.php != '8.1' && matrix.php != '8.2' }} - run: bin/test.sh --exclude-group=gearman + if: ${{ matrix.php == '8.1' && matrix.php != '8.2' }}