diff --git a/services/docker-compose.tests.yml b/services/docker-compose.tests.yml new file mode 100644 --- /dev/null +++ b/services/docker-compose.tests.yml @@ -0,0 +1,83 @@ +version: '3.9' +volumes: + localstack: + commtest_build_artifacts: + +services: + commtest: + depends_on: + - tunnelbroker-server + - backup-server + - blob-server + - identity-server + # There are no tests for these services: + # - feature-flags-server + # - reports-server + build: + dockerfile: services/commtest/Dockerfile + context: ../ + platform: '${PLATFORM:-linux/amd64}' + volumes: + # This one caches build directory and allows to run tests multiple times without rebuilding + - commtest_build_artifacts:/home/root/app/commtest/target + env_file: test-commons.env + environment: + # tested services endpoints + TUNNELBROKER_WS_ENDPOINT: 'ws://tunnelbroker-server:51001' + TUNNELBROKER_GRPC_ENDPOINT: 'http://tunnelbroker-server:${COMM_SERVICES_PORT_TUNNELBROKER}' + BACKUP_SERVICE_URL: 'http://backup-server:${COMM_SERVICES_PORT_BACKUP}' + BLOB_SERVICE_URL: 'http://blob-server:${COMM_SERVICES_PORT_BLOB}' + IDENTITY_GRPC_ENDPOINT: 'http://identity-server:${COMM_SERVICES_PORT_IDENTITY}' + # override localstack endpoint in terraform setup + TF_VAR_localstack_endpoint: 'http://localstack:4566' + # others + COMM_NUMBER_OF_THREADS: '4' + BLOB_SERVICE_EXECUTABLE: /shared/bin/blob + RUST_LOG: blob=trace,comm_services_lib=debug + + tunnelbroker-server: + image: tunnelbroker + pull_policy: build + platform: '${PLATFORM:-linux/amd64}' + restart: on-failure + env_file: test-commons.env + environment: + COMM_TUNNELBROKER_IDENTITY_ENDPOINT: 'http://identity-server:50054' + AMQP_URI: 'amqp://comm:comm@rabbitmq:5672' + RUST_LOG: tunnelbroker=trace + + backup-server: + image: backup + pull_policy: build + platform: '${PLATFORM:-linux/amd64}' + env_file: test-commons.env + environment: + BLOB_SERVICE_URL: 'http://blob-server:50053' + + blob-server: + image: blob + pull_policy: build + # Until blob cleanup is supported in tests, enable auto-deletion + command: ['blob', 'server', '--instant-delete'] + platform: '${PLATFORM:-linux/amd64}' + env_file: test-commons.env + environment: + RUST_LOG: blob=trace,comm_services_lib=debug + + identity-server: + image: identity + pull_policy: build + platform: '${PLATFORM:-linux/amd64}' + env_file: test-commons.env + environment: + TUNNELBROKER_GRPC_ENDPOINT: 'http://tunnelbroker-server:50051' + build: + args: + - generate_keypair=true + + rabbitmq: + healthcheck: + test: rabbitmq-diagnostics -q ping + interval: 15s + timeout: 10s + retries: 5 diff --git a/services/package.json b/services/package.json --- a/services/package.json +++ b/services/package.json @@ -14,6 +14,7 @@ "run-performance-tests": "./scripts/run_performance_tests.sh", "init-local-cloud": "./scripts/init_local_cloud.sh", "delete-local-cloud": "docker-compose down -v", - "reset-local-cloud": "yarn delete-local-cloud && yarn init-local-cloud" + "reset-local-cloud": "yarn delete-local-cloud && yarn init-local-cloud", + "run-commtest-in-docker": "PLATFORM=$(docker system info --format '{{.OSType}}/{{.Architecture}}') docker compose -f docker-compose.yml -f docker-compose.tests.yml up commtest --build" } } diff --git a/services/test-commons.env b/services/test-commons.env new file mode 100644 --- /dev/null +++ b/services/test-commons.env @@ -0,0 +1,6 @@ +LOCALSTACK_ENDPOINT='http://localstack:4566' +AWS_REGION=us-east-2 +AWS_ACCESS_KEY_ID=test +AWS_SECRET_ACCESS_KEY=test + +RUST_LOG=info,comm_services_lib=debug,blob=debug,backup=debug,identity=debug,tunnelbroker=debug,grpc_clients=debug,commtest=debug