How to create databases? #8
Unanswered
bmulholland
asked this question in
Q&A
Replies: 1 comment 3 replies
-
There are many ways to do this, so it depends on your circumstance and how your tests work. Here is an example: ENV['RAILS_ENV'] = 'test'
worker do |index|
ENV['TEST_ENV_NUMBER'] = index.to_s
system("bin/rails", "db:drop", "db:create", "db:migrate")
# Parallel spec system
port = 10000 + index
Console.logger.info "Setting up parallel test mode - starting Redis #{n} on port #{port}"
system("rm -rf tmp/test_data_#{n} && mkdir -p tmp/test_data_#{n}/redis")
pid = Process.spawn("redis-server --dir tmp/test_data_#{n}/redis --port #{port}", out: "/dev/null")
ENV["REDIS_PORT"] = port.to_s
ENV["RAILS_DB"] = "discourse_test_#{n}"
at_exit do
Process.kill("SIGTERM", pid)
Process.wait
end
require_relative 'spec/rails_helper'
end |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I tried installing and running with the steps in #6, but all the parallel databases do not exist, so the run fails.
rake parallel:create
does not exist, and the source doesn't seem to mention another way of creating the dbs. Once created, they'll need to be updated with migrations etc too - but that doesn't seem to be discussed anywhere?Beta Was this translation helpful? Give feedback.
All reactions