简体   繁体   中英

Gitlab-ci.yml rspec tests error after migarting to pg

I got an error on gitlab during execution.gitlab-ci.yml

$ bundle exec rspec

in.gitlab-ci.yml

Locally I have postgresql for dev and test environment. All rspec tests are passing.

But after upload project on gitlab it raises error:

An error occurred while loading ./spec/requests/api/packages_spec.rb.
Failure/Error: ActiveRecord::Migration.maintain_test_schema!
PG::ConnectionBad:
  could not connect to server: No such file or directory
      Is the server running locally and accepting
      connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"

Before I had sqlite3 db. But than I migrated to pg.

database.yml:

default: &default
  adapter: postgresql
  encoding: unicode
  # For details on connection pooling, see Rails configuration guide
  # https://guides.rubyonrails.org/configuring.html#database-pooling
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

development:
  <<: *default
  database: pg_app_development

test:
  <<: *default
  database: pg_app_test

Add in database.yml port and host var:

test:
  <<: *default
  database: pg_app_test
  user: postgres
  host: <%= ENV.fetch("DATABASE_HOST") { 'localhost' } %>
  port: 5432

And db variables to.gitlab-ci.yml

variables:
    RAILS_ENV: test
    POSTGRES_DB: pg_app_test
    POSTGRES_USER: postgres
    POSTGRES_HOST_AUTH_METHOD: trust
    DATABASE_HOST: postgres

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM