Hi guys, I’m using Drone to run some E2E tests. My pipeline runs a mongodb cluster service for the E2E tests to access. Here is my yml file:
kind: pipeline
type: docker
name: test.repo
clone:
disable: true
steps:
- name: clone
image: alpine/git
commands:
- git clone http://gitea.test.com/TEST/test.code.git .
- git checkout $DRONE_COMMIT
when:
branch:
- develop
event:
- push
- name: initiate-mongo-clusters
image: mongo:latest
commands:
- sleep 15
- mongosh --host mongo1:27017 --eval "rs.initiate({ _id:\"e2e\", members:[{_id:0,host:\"mongo1\"},{_id:1, host:\"mongo2\"},{_id:2, host:\"mongo3\"}]})"
when:
branch:
- develop
event:
- push
- name: check-mongo-cluster-status
image: mongo:latest
commands:
- sleep 10
- mongosh --host mongo1:27017 --eval "rs.status()"
- mongosh --host mongo2:27017 --eval "rs.status()"
- mongosh --host mongo3:27017 --eval "rs.status()"
when:
branch:
- develop
event:
- push
- name: test
image: node:16.13.0-alpine
commands:
- npm install
- npm run test:e2e
environment:
DB_URL: mongodb://mongo1:27017/test
when:
branch:
- develop
event:
- push
services:
- name: mongo1
image: mongo:latest
command: ['--replSet', 'e2e']
when:
branch:
- develop
event:
- push
- name: mongo2
image: mongo:latest
command: ['--replSet', 'e2e']
when:
branch:
- develop
event:
- push
- name: mongo3
image: mongo:latest
command: ['--replSet', 'e2e']
when:
branch:
- develop
event:
- push
The initiate-mongo-clusters
initiates the mongo replica sets, and the check-mongo-clusters
stage just gives the replica sets time to start up as well as print the health of the replica sets. The reason I added the check stage was because my some of my tests would fail from a 500 Internal Server error, but this happens sometimes. All my tests would pass most of the time, but sometimes this internal server error occurs, so I thought the check stage would work.
Unfortunately, I found out in one of my builds that the 500 Internal Server error came again and had to restart my build a few times before the test stage passed. Does anyone have any thoughts or advice on why this error comes and how I can fix this inconsistency?