Skip to content

Add Localstack Docker container for SQS functional tests #473

New issue

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

By clicking “No 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? No Sign in to your account

Merged
merged 4 commits into from
Jul 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/run-fun-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 ./bin/test "$@"
docker-compose run --workdir="/mqdev" --rm dev ./bin/test "$@"
1 change: 1 addition & 0 deletions bin/test
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ waitForService beanstalkd 11300 50
waitForService gearmand 4730 50
waitForService kafka 9092 50
waitForService mongo 27017 50
waitForService localstack 4576 50

php pkg/job-queue/Tests/Functional/app/console doctrine:database:create --if-not-exists
php pkg/job-queue/Tests/Functional/app/console doctrine:schema:update --force
Expand Down
17 changes: 14 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ services:
- google-pubsub
- rabbitmqssl
- mongo
- localstack
volumes:
- './:/mqdev'
environment:
Expand All @@ -34,9 +35,11 @@ services:
- DOCTRINE_PASSWORD=rootpass
- REDIS_HOST=redis
- REDIS_PORT=6379
- AWS_SQS_KEY=$ENQUEUE_AWS__SQS__KEY
- AWS_SQS_SECRET=$ENQUEUE_AWS__SQS__SECRET
- AWS_SQS_REGION=$ENQUEUE_AWS__SQS__REGION
- AWS_SQS_KEY=key
- AWS_SQS_SECRET=secret
- AWS_SQS_REGION=us-east-1
- AWS_SQS_ENDPOINT=http://localstack:4576
- AWS_SQS_VERSION=latest
- BEANSTALKD_HOST=beanstalkd
- BEANSTALKD_PORT=11300
- BEANSTALKD_DSN=beanstalk://beanstalkd:11300
Expand Down Expand Up @@ -109,6 +112,14 @@ services:
ports:
- "27017:27017"

localstack:
image: 'localstack/localstack:latest'
ports:
- '4576:4576'
environment:
HOSTNAME_EXTERNAL: 'localstack'
SERVICES: 'sqs'

volumes:
mysql-data:
driver: local
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ parameters:
locale: 'en'
secret: 'ThisTokenIsNotSoSecretChangeIt'
env(AWS_SQS_REGION): 'us-east-1'
env(AWS_SQS_VERSION): 'latest'
env(AWS_SQS_KEY): 'key'
env(AWS_SQS_SECRET): 'secret'
env(AWS_SQS_ENDPOINT): 'http://localstack:4576'

framework:
#esi: ~
Expand Down Expand Up @@ -41,8 +43,9 @@ services:
class: Aws\Sqs\SqsClient
arguments:
-
endpoint: '%env(AWS_SQS_ENDPOINT)%'
region: '%env(AWS_SQS_REGION)%'
version: '2012-11-05'
version: '%env(AWS_SQS_VERSION)%'
credentials:
key: '%env(AWS_SQS_KEY)%'
secret: '%env(AWS_SQS_SECRET)%'
1 change: 1 addition & 0 deletions pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ public function provideEnqueueConfigs()
'key' => getenv('AWS_SQS_KEY'),
'secret' => getenv('AWS_SQS_SECRET'),
'region' => getenv('AWS_SQS_REGION'),
'endpoint' => getenv('AWS_SQS_ENDPOINT'),
],
],
]];
Expand Down
4 changes: 3 additions & 1 deletion pkg/test/SqsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ trait SqsExtension
*/
private function buildSqsContext()
{
if (false == getenv('AWS_SQS_KEY')) {
if (false == getenv('AWS_SQS_ENDPOINT') && false == getenv('AWS_SQS_KEY')) {
throw new \PHPUnit_Framework_SkippedTestError('Functional tests are not allowed in this environment');
}

$config = [
'key' => getenv('AWS_SQS_KEY'),
'secret' => getenv('AWS_SQS_SECRET'),
'region' => getenv('AWS_SQS_REGION'),
'version' => getenv('AWS_SQS_VERSION'),
'endpoint' => getenv('AWS_SQS_ENDPOINT'),
'lazy' => false,
];

Expand Down