Ruby on rails 尝试将并行rspec与elasticsearch集成
我在spec_helper.rb中有以下配置Ruby on rails 尝试将并行rspec与elasticsearch集成,ruby-on-rails,
elasticsearch,rspec,Ruby On Rails,
elasticsearch,Rspec,我在spec_helper.rb中有以下配置 config.before(:suite) do DatabaseCleaner.clean_with(:truncation) # Create indexes for all elastic searchable models ApplicationRecord.descendants.each do |model| if model.respond_to?(:__elasticsearch__)
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
# Create indexes for all elastic searchable models
ApplicationRecord.descendants.each do |model|
if model.respond_to?(:__elasticsearch__)
elastic_error_wrapper("Creation of index", model.name) do
model.__elasticsearch__.create_index!(force: true)
model.__elasticsearch__.refresh_index!
end
end
end
load Rails.root + "db/seeds.rb"
end
config.after(:suite) do
# Delete indexes for all elastic searchable models to ensure clean state between tests
ApplicationRecord.descendants.each do |model|
if model.respond_to?(:__elasticsearch__)
elastic_error_wrapper("Removing the index", model.name) do
model.__elasticsearch__.delete_index!
end
end
end
end
当我运行rake parallel:spec时
这给了我一个错误:
An error occurred in a `before(:suite)` hook.
Failure/Error: load Rails.root + "db/seeds.rb"
Faraday::TimeoutError:
Net::ReadTimeout
及
但是当我使用http://localhost:9200/_cat/indices. 用户可以在其中找到测试
Elasticsearch::Transport::Transport::Errors::NotFound:
[404] {"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index [users_test]","index_uuid":"gexuxS9MQdS74RZwUVjpVg","index":"users_test"}],"type":"index_not_found_exception","reason":"no such index [users_test]","index_uuid":"gexuxS9MQdS74RZwUVjpVg","index":"users_test"},"status":404}