AutoCI Rails with Mongo fails in Pipeline

Hey there,

I’m having issues getting my specs to pass in CI in a fresh Rails app using Mongo as the database. Locally, I’m able to run
docker-compose run --rm web rspec
and everything passes with no issues.

My mongoid.yml is pretty basic at this point:

development:
  clients:
    default:
      database: member_service_development
      hosts:
        - db:27017
test:
  clients:
    default:
      database: member_service_test
      hosts:
        - db:27017
      options:
        read:
          mode: :primary
        max_pool_size: 1

My docker-compose.yml looks like the following:

version: '3'
services:
  web:
    build: .
    command: bundle exec rails s -p 3000 -b '0.0.0.0'
    volumes:
      - .:/app
    ports:
      - "3000:3000"
    depends_on:
      - db
  db:
    image: mongo:latest
    container_name: "mongodb"
    environment:
      - MONGO_DATA_DIR=/data/db
      - MONGO_LOG_DIR=/dev/null
    volumes:
      - ./data/db:/data/db
    ports:
        - 27017:27017
    command: mongod --smallfiles --logpath=/dev/null # --quiet

In the pipeline, my failures look like this:

Failures:
       
         1) MembersController POST #create with valid params creates a new Member
            Failure/Error:
              expect {
                post :create, params: {member: valid_attributes}, session: valid_session
              }.to change(Member, :count).by(1)
       
            Mongo::Error::NoServerAvailable:
              No server is available matching preference: #<Mongo::ServerSelector::Primary:0x48368400 tag_sets=[] max_staleness=nil> using server_selection_timeout=30 and local_threshold=0.015
            # ./spec/controllers/members_controller_spec.rb:63:in `block (4 levels) in <top (required)>'
       
         2) Members GET /members works! (now write some real specs)
            Failure/Error: render json: @members
       
            Mongo::Error::NoServerAvailable:
              No server is available matching preference: #<Mongo::ServerSelector::Primary:0x47027580 tag_sets=[] max_staleness=nil> using server_selection_timeout=30 and local_threshold=0.015
            # ./app/controllers/members_controller.rb:8:in `index'
            # ./spec/requests/members_spec.rb:6:in `block (3 levels) in <main>'

I’m new to GitLab and to Google Cloud Platform. I don’t know if there is a way I could look at the automatic config that GitLab is using for my CI Pipeline, or if I can get a template to download. I also don’t know if there is a way to keep the container running so I may inspect it over SSH or something similar (CircleCI offers something that does this). Any help would be very much appreciated!

Thanks!

Did you fixed this issue?