mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 03:06:53 +08:00
DEV: Introduce parallel rspec testing
Adds the parallel_tests gem, and redis/postgres configuration for running rspec tests in parallel. To use: ``` rake parallel:rake[db:create] rake parallel:rake[db:migrate] rake parallel:spec ``` This brings the test suite from 12m20s to 3m11s on my macOS machine
This commit is contained in:
@ -28,3 +28,19 @@ if ENV['RAILS_ENV'] != 'production' && ENV['RAILS_ENV'] != 'profile'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
# Parallel spec system
|
||||
if ENV['RAILS_ENV'] == "test" && ENV['TEST_ENV_NUMBER']
|
||||
n = ENV['TEST_ENV_NUMBER'].to_i
|
||||
port = 10000 + n
|
||||
|
||||
puts "Setting up parallel test mode - starting Redis #{n} on port #{port}"
|
||||
|
||||
`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["DISCOURSE_REDIS_PORT"] = port.to_s
|
||||
ENV["RAILS_DB"] = "discourse_test_#{ENV['TEST_ENV_NUMBER']}"
|
||||
|
||||
at_exit { puts "Terminating redis #{n}"; Process.kill("SIGTERM", pid); Process.wait }
|
||||
end
|
||||
|
Reference in New Issue
Block a user