You recently added MinIO to your back-end web API to store the invoices for your ground-breaking app. You write the the smoke test for it locally, executing it with no error, but when the time comes for the GitLab CI Job to execute the smoke test, it fails. You have forgotten to add the MinIO to your GitLab CI job, so the app can't connect to any bucket. Don't worry, I'll show you how to add MinIO server as a service to your GitLab CI smoke test job, so it can pass with flying colors.
MinIO Image
For our service, we will be using bitnami/minio
docker image, since it implements the MINIO_DEFAULT_BUCKETS
environment variable. This variable will allow us to create default buckets without having to execute any scripts, or download any clients to create those buckets. If your smoke tests / CI Job does not rely on buckets, then you can use another image.
Setting up Service
Beside the MINIO_DEFAULT_BUCKETS
, you will have to set the following environment variables within the service:
-
MINIO_ROOT_USER
- Previously known as
MINIO_ACCESS_KEY_ID
, but it was changed with the newest versions of MinIO. Do not useMINIO_ACCESS_KEY_ID
as a variable since it is deprecated.
- Previously known as
-
MINIO_ROOT_PASSWORD
- Previously known as
MINIO_SECRET_ACCESS_KEY
and it also has been deprecated
- Previously known as
-
MINIO_DOMAIN
- Domain where you MinIO is being hosted. In this case, it should be localhost, since we are accessing it within the job. Additionally, don't forget to add an alias to your service, so it can be accessible with the endpoint.
Final Result
Your .gitlab-ci.yml
file should look something like this:
smoke:
image: $YOUR_IMAGE
variables:
S3_ACCESS_KEY: admin
S3_SECRET_KEY: test-password
S3_ENDPOINT: "http://minio:9000"
services:
- name: bitnami/minio:latest
alias: minio
variables:
MINIO_ROOT_USER: $S3_ACCESS_KEY
MINIO_ROOT_PASSWORD: $S3_SECRET_KEY
MINIO_DOMAIN: localhost
MINIO_DEFAULT_BUCKETS: my-bucket
stage: test
timeout: 5m
interruptible: true
allow_failure: true
script:
- npm run test:smoke
Top comments (0)