Add fake GCS server, and fix health checks

This commit is contained in:
Simon Detheridge 2020-02-12 10:38:32 +00:00
parent 0610b74cc9
commit 7292d93dab
5 changed files with 60 additions and 16 deletions

View file

@ -22,10 +22,6 @@ services:
REDIS_HOST: redis REDIS_HOST: redis
MONGO_HOST: mongo MONGO_HOST: mongo
POSTGRES_HOST: postgres POSTGRES_HOST: postgres
AWS_S3_ENDPOINT: http://s3:9090
AWS_S3_PATH_STYLE: 'true'
AWS_ACCESS_KEY_ID: fake
AWS_SECRET_ACCESS_KEY: fake
MOCHA_GREP: ${MOCHA_GREP} MOCHA_GREP: ${MOCHA_GREP}
NODE_ENV: test NODE_ENV: test
ENABLE_CONVERSIONS: "true" ENABLE_CONVERSIONS: "true"
@ -33,9 +29,21 @@ services:
AWS_S3_USER_FILES_BUCKET_NAME: fake_user_files AWS_S3_USER_FILES_BUCKET_NAME: fake_user_files
AWS_S3_TEMPLATE_FILES_BUCKET_NAME: fake_template_files AWS_S3_TEMPLATE_FILES_BUCKET_NAME: fake_template_files
AWS_S3_PUBLIC_FILES_BUCKET_NAME: fake_public_files AWS_S3_PUBLIC_FILES_BUCKET_NAME: fake_public_files
AWS_S3_ENDPOINT: http://s3:9090
AWS_ACCESS_KEY_ID: fake
AWS_SECRET_ACCESS_KEY: fake
AWS_S3_PATH_STYLE: 'true'
GCS_API_ENDPOINT: gcs:9090
GCS_USER_FILES_BUCKET_NAME: fake_userfiles
GCS_TEMPLATE_FILES_BUCKET_NAME: fake_templatefiles
GCS_PUBLIC_FILES_BUCKET_NAME: fake_publicfiles
NODE_TLS_REJECT_UNAUTHORIZED: 0
STORAGE_EMULATOR_HOST: https://gcs:9090/storage/v1
depends_on: depends_on:
s3: s3:
condition: service_healthy condition: service_healthy
gcs:
condition: service_healthy
user: node user: node
command: npm run test:acceptance:_run command: npm run test:acceptance:_run
@ -48,8 +56,13 @@ services:
command: tar -czf /tmp/build/build.tar.gz --exclude=build.tar.gz --exclude-vcs . command: tar -czf /tmp/build/build.tar.gz --exclude=build.tar.gz --exclude-vcs .
user: root user: root
s3: s3:
image: adobe/s3mock build:
context: test/acceptance/deps
dockerfile: Dockerfile.s3mock
environment: environment:
- initialBuckets=fake_user_files,fake_template_files,fake_public_files,bucket - initialBuckets=fake_user_files,fake_template_files,fake_public_files
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9090"] gcs:
build:
context: test/acceptance/deps
dockerfile: Dockerfile.fake-gcs

View file

@ -31,10 +31,6 @@ services:
REDIS_HOST: redis REDIS_HOST: redis
MONGO_HOST: mongo MONGO_HOST: mongo
POSTGRES_HOST: postgres POSTGRES_HOST: postgres
AWS_S3_ENDPOINT: http://s3:9090
AWS_S3_PATH_STYLE: 'true'
AWS_ACCESS_KEY_ID: fake
AWS_SECRET_ACCESS_KEY: fake
MOCHA_GREP: ${MOCHA_GREP} MOCHA_GREP: ${MOCHA_GREP}
LOG_LEVEL: ERROR LOG_LEVEL: ERROR
NODE_ENV: test NODE_ENV: test
@ -43,15 +39,32 @@ services:
AWS_S3_USER_FILES_BUCKET_NAME: fake_user_files AWS_S3_USER_FILES_BUCKET_NAME: fake_user_files
AWS_S3_TEMPLATE_FILES_BUCKET_NAME: fake_template_files AWS_S3_TEMPLATE_FILES_BUCKET_NAME: fake_template_files
AWS_S3_PUBLIC_FILES_BUCKET_NAME: fake_public_files AWS_S3_PUBLIC_FILES_BUCKET_NAME: fake_public_files
AWS_S3_ENDPOINT: http://s3:9090
AWS_S3_PATH_STYLE: 'true'
AWS_ACCESS_KEY_ID: fake
AWS_SECRET_ACCESS_KEY: fake
GCS_API_ENDPOINT: gcs:9090
GCS_USER_FILES_BUCKET_NAME: fake_userfiles
GCS_TEMPLATE_FILES_BUCKET_NAME: fake_templatefiles
GCS_PUBLIC_FILES_BUCKET_NAME: fake_publicfiles
NODE_TLS_REJECT_UNAUTHORIZED: 0
STORAGE_EMULATOR_HOST: https://gcs:9090/storage/v1
user: node user: node
depends_on: depends_on:
s3: s3:
condition: service_healthy condition: service_healthy
gcs:
condition: service_healthy
command: npm run test:acceptance command: npm run test:acceptance
s3: s3:
image: adobe/s3mock build:
context: test/acceptance/deps
dockerfile: Dockerfile.s3mock
environment: environment:
- initialBuckets=fake_user_files,fake_template_files,fake_public_files,bucket - initialBuckets=fake_user_files,fake_template_files,fake_public_files
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9090"] gcs:
build:
context: test/acceptance/deps
dockerfile: Dockerfile.fake-gcs

View file

@ -0,0 +1,5 @@
FROM gh2k/fake-gcs-server
RUN apk add --update --no-cache curl
COPY healthcheck.sh /healthcheck.sh
HEALTHCHECK --interval=1s --timeout=1s --retries=30 CMD /healthcheck.sh http://localhost:9090
CMD ["--port=9090"]

View file

@ -0,0 +1,4 @@
FROM adobe/s3mock
RUN apk add --update --no-cache curl
COPY healthcheck.sh /healthcheck.sh
HEALTHCHECK --interval=1s --timeout=1s --retries=30 CMD /healthcheck.sh http://localhost:9090

View file

@ -0,0 +1,9 @@
#!/bin/sh
# health check to allow 404 status code as valid
STATUSCODE=$(curl --silent --output /dev/null --write-out "%{http_code}" $1)
# will be 000 on non-http error (e.g. connection failure)
if test $STATUSCODE -ge 500 || test $STATUSCODE -lt 200; then
exit 1
fi
exit 0