1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
version: "3"
env:
VERSION: 4.2
tasks:
check:
preconditions:
- sh: command -v nc
msg: netcat (nc) was not found. Please install it and try again.
- sh: nc -vz 127.0.0.1 27017 || ! [ -z "$TEST_MONGO_URI" ]
msg: |
Mongo server not found, please start a server or start a cluster and set the
appropriate connection variables
standalone-docker:
desc: Start a standalone MongoDB instance using a docker container
cmds:
- echo "Starting odmantic-mongo-test mongo container"
- docker run --rm -p 27017:27017 --name mongodb-action-instance -d mongo:$VERSION
status:
- docker container inspect mongodb-action-instance
standalone-docker:up:
cmds:
- task: standalone-docker
standalone-docker:down:
desc: Stop the standalone instance
cmds:
- docker stop mongodb-action-instance
preconditions:
- sh: docker container inspect mongodb-action-instance
msg: The standalone mongo container is not running
replica-compose:
desc: Start a replica set MongoDB cluster using docker compose
cmds:
- echo "Starting replica mongo cluster"
- docker compose up -d
- ./replica/start.sh
- echo "To run the tests using this cluster export the following environment variables:"
- echo export TEST_MONGO_URI=mongodb://172.16.17.11:27017,172.16.17.12:27017,172.16.17.13:27017/?replicaSet=mongodb-action-replica-set
- echo export TEST_MONGO_MODE=replicaSet
status:
- test -n "$(docker compose ps --services --filter "status=running")"
env:
COMPOSE_FILE: ./replica/docker compose.yml
replica-compose:up:
cmds:
- task: replica-compose
replica-compose:down:
desc: Stop the replica set cluster
cmds:
- docker compose down
preconditions:
- sh: test -n "$(docker compose ps --services --filter "status=running")"
msg: The replica cluster is not running
env:
COMPOSE_FILE: ./replica/docker compose.yml
sharded-compose:
desc: Start a sharded MongoDB cluster using docker compose
cmds:
- echo "Starting sharded mongo cluster"
- docker compose up -d
- ./sharded/start.sh
- echo "To run the tests using this cluster export the following environment variables:"
- echo export TEST_MONGO_URI=mongodb://172.16.17.10:27017/?retryWrites=false
- echo export TEST_MONGO_MODE=sharded
status:
- test -n "$(docker compose ps --services --filter "status=running")"
env:
COMPOSE_FILE: ./sharded/docker compose.yml
sharded-compose:up:
cmds:
- task: sharded-compose
sharded-compose:down:
desc: Stop the sharded MongoDB cluster
cmds:
- docker compose down
preconditions:
- sh: test -n "$(docker compose ps --services --filter "status=running")"
msg: The sharded cluster is not running
env:
COMPOSE_FILE: ./sharded/docker compose.yml
|