Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix in RdKafkaProducer:flush() method #1347

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions bin/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -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"
#git add CHANGELOG.md && git commit -m "Release $1" -S && git push origin "$CURRENT_BRANCH"
10 changes: 5 additions & 5 deletions bin/dev
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ 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 mqdev_dev_1 /bin/bash
docker exec -it enqueue-dev-dev-1 /bin/bash
;;
f)
./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
Expand Down
2 changes: 1 addition & 1 deletion bin/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 $@
24 changes: 14 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '2'

services:
dev:
# when image publishing gets sorted:
Expand Down Expand Up @@ -38,16 +36,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&region=us-east-1&endpoint=http://localstack:4576&version=latest
- SNS_DSN=sns:?key=key&secret=secret&region=us-east-1&endpoint=http://localstack:4575&version=latest
- SNSQS_DSN=snsqs:?key=key&secret=secret&region=us-east-1&sns_endpoint=http://localstack:4575&sqs_endpoint=http://localstack:4576&version=latest
- SQS_DSN=sqs:?key=key&secret=secret&region=us-east-1&endpoint=http://localstack:4566&version=latest
- SNS_DSN=sns:?key=key&secret=secret&region=us-east-1&endpoint=http://localstack:4566&version=latest
- SNSQS_DSN=snsqs:?key=key&secret=secret&region=us-east-1&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
Expand Down Expand Up @@ -127,13 +125,19 @@ services:
- '9090:9090'

localstack:
image: 'localstack/localstack:0.8.10'
image: 'localstack/localstack:3.6.0'
ports:
- '4576:4576'
- '4575:4575'
- '4566:4566'
environment:
HOSTNAME_EXTERNAL: 'localstack'
LOCALSTACK_HOST: 'localstack'
SERVICES: 'sqs,sns'
EAGER_SERVICE_LOADING: '1'
networks:
default:
aliases:
- 'localstack'
- 'sqs.us-east-1.localstack'
- 'snsqs.us-east-1.localstack'

influxdb:
image: 'influxdb:latest'
Expand Down
30 changes: 29 additions & 1 deletion docker/bin/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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": "available"'* && $RESPONSE == *'"sqs": "available"'* ]]; 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
Expand All @@ -39,7 +67,7 @@ waitForService gearmand 4730 50
waitForService kafka 9092 50
waitForService mongo 27017 50
waitForService thruway 9090 50
waitForService localstack 4576 50
waitForServiceLocalStack 50 50

php docker/bin/refresh-mysql-database.php || exit 1
php docker/bin/refresh-postgres-database.php || exit 1
Expand Down
2 changes: 1 addition & 1 deletion docs/contribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
12 changes: 6 additions & 6 deletions pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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__);
Expand All @@ -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()
Expand All @@ -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__);
Expand All @@ -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()
Expand Down
8 changes: 5 additions & 3 deletions pkg/rdkafka/RdKafkaProducer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -121,5 +121,7 @@ public function flush(int $timeout): ?int
if (method_exists($this->producer, 'flush')) {
return $this->producer->flush($timeout);
}

return null;
}
}
2 changes: 1 addition & 1 deletion pkg/snsqs/Tests/SnsQsProducerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
Loading