Setting up database.yml for test environment
blindMoe opened this issue · comments
Is there a recommended method of setting up the test environment to not use read replicas at all? I figured that since Makara was not defined in the test environment DistributeReads would just fall back to the master but it seems as though it is not the case.
If I remove the distribute_reads
block surrounded the failing code the tests start passing again in CI. Note that locally the tests pass fine w/o having a read replica setup which makes me think that distribute_reads is actually failing to master but I figured I would ask just in case I am missing something simple.
Here is a snippet of my database.yml:
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV['DATABASE_POOL'] || 5 %>
development: &development
<<: *default
database: development
host: <%= ENV['DATABASE_HOST'] || 'localhost' %>
port: <%= ENV['DATABASE_PORT'] || '5432' %>
username: <%= ENV['DATABASE_USERNAME'] || 'postgres' %>
password: <%= ENV['DATABASE_PASSWORD'] || '' %>
test:
<<: *development
database: test<%= ENV['TEST_ENV_NUMBER'] %>
staging:
<<: *default
url: <%= ENV['DATABASE_URL'] %>
production:
<<: *default
<% if ENV["USE_MAKARA"] %>
url: postgresql-makara:///
makara:
sticky: true
connections:
- role: master
blacklist_duration: 0
disable_blacklist: true
name: primary
url: <%= ENV["DATABASE_URL"] %>
- name: replica
url: <%= ENV["DATABASE_READ_REPLICA_URL"] %>
<% else %>
url: <%= ENV['DATABASE_URL'] %>
<% end %>