Gitlab-ci How to Exec Mongo rs.initiate() after services running

i want integration test for my golang project, and using mongodb transaction. to make it work
i need make mongodb services running replica set
this my .gitlab-ci.yml

image: golang:1.13

  - name: mongo:4.2
    alias: mongo-svc
    command: ["mongod", "--logpath=/dev/null", "--bind_ip_all", "--replSet=rs0"]

  stage: test
    - mongo-svc exec mongo --eval "rs.initiate()"
    - make test

i get error

$ mongo-svc mongo --eval "rs.initiate()"
 /bin/bash: line 95: mongo-svc: command not found
 ERROR: Job failed: exit code 1

i already use another command but still cant find how to do it.
Please help me, stuck 5 hours only for this…

1 Like

Aliases don’t work in k8s runners, you need to use instead. And the command should be a little bit different. mongo "mongo-svc" --eval "rs.initiate()"
Any way, i suggest you to use this -
It’s bootup replica set with Environment variables.