【发布时间】:2013-04-27 20:26:00
【问题描述】:
我正在使用 Rails 3.2.12、RSpec-rails 2.13.0 和 ThinkingSphinx 3.0.10
问题:
当我运行 bundle exec rpsec spec/controllers/ads_controller_spec.rb 时,我认为 sphinx 会产生 3 个被冻结的 searchd 进程,我的测试只是锁定,直到我手动终止 searchd 进程,之后测试继续运行。
设置:
这是我的 sphinx_env.rb 文件,我在其中设置 TS 进行测试:
require 'thinking_sphinx/test'
def sphinx_environment(*tables, &block)
obj = self
begin
before(:all) do
obj.use_transactional_fixtures = false
ThinkingSphinx::Test.init
ThinkingSphinx::Test.start
sleep(0.5)
end
yield
ensure
after(:all) do
ThinkingSphinx::Test.stop
sleep(0.5)
obj.use_transactional_fixtures = true
end
end
end
这是我的测试脚本:
describe "GET index" do
before(:each) do
@web_origin = FactoryGirl.create(:origin)
@api_origin = FactoryGirl.create(:api_origin)
@first_ad = FactoryGirl.create(:ad, :origin_id => @web_origin.id)
ThinkingSphinx::Test.index #index ads created above
sleep 0.5
end
sphinx_environment :ads do
it 'should return a collection of all live ads' do
get :index, {:format => 'json'}
response.code.should == '200'
end
end
...
更新
没有取得任何进展,但这里有一些额外的细节:
- 当我运行测试时,认为 sphinx 总是开始 3 searchd 过程。
- test.sphinx.pid 中的 pid 始终只有一个 searchd pid,它始终是第二个 searchd 进程 pid。
-
这是我的 test.searchd.log 文件的输出:
[568] binlog: 0.006 秒内完成回放总共 49 个
[568] 接受连接
[568] 捕捉到 SIGHUP(无缝=1,在队列中=1)
[568] 旋转索引“ad_core”:开始
[568] 捕捉到 SIGHUP(无缝=1,在队列中=2)
[568] 捕捉到 SIGTERM,正在关闭
感谢任何帮助,我已经尝试解决这个问题超过一天,有点迷茫。
谢谢。
【问题讨论】:
-
您能确认您使用的是什么版本的 Thinking Sphinx(最新的是 3.0.2,而不是 3.0.10)?另外,您使用的是什么版本的 Sphinx 和什么操作系统?
-
嗨,Pat,我正在使用 TS 3.0.2、Mountain Lion 和 Sphinx 2.0.2
标签: ruby-on-rails-3 sphinx thinking-sphinx