You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by eh...@apache.org on 2007/01/04 02:00:31 UTC
svn commit: r492374 - in /incubator/solr/trunk/client/ruby/solrb: Rakefile
test/solr_server.rb
Author: ehatcher
Date: Wed Jan 3 17:00:30 2007
New Revision: 492374
URL: http://svn.apache.org/viewvc?view=rev&rev=492374
Log:
SOLR-94: start Solr before tests are run, shut it down afterwards (contributed by Ed Summers). Original patch modified slightly to set the Jetty port to 8888
Added:
incubator/solr/trunk/client/ruby/solrb/test/solr_server.rb
Modified:
incubator/solr/trunk/client/ruby/solrb/Rakefile
Modified: incubator/solr/trunk/client/ruby/solrb/Rakefile
URL: http://svn.apache.org/viewvc/incubator/solr/trunk/client/ruby/solrb/Rakefile?view=diff&rev=492374&r1=492373&r2=492374
==============================================================================
--- incubator/solr/trunk/client/ruby/solrb/Rakefile (original)
+++ incubator/solr/trunk/client/ruby/solrb/Rakefile Wed Jan 3 17:00:30 2007
@@ -6,16 +6,10 @@
require 'rake/rdoctask'
require 'rake/packagetask'
require 'rake/gempackagetask'
+require 'test/solr_server.rb'
task :default => [:test]
-Rake::TestTask.new('test') do |t|
- t.libs << 'lib'
- t.pattern = 'test/*_test.rb'
- t.verbose = true
- t.ruby_opts = ['-r solr', '-r test/unit']
-end
-
spec = Gem::Specification.new do |s|
s.name = 'solr'
s.version = SOLRB_VERSION
@@ -28,9 +22,6 @@
s.require_path = 'lib'
s.autorequire = 'solr'
s.has_rdoc = true
-
-# s.test_file = 'test/ts_solr.rb'
-# s.bindir = 'bin'
end
Rake::GemPackageTask.new(spec) do |pkg|
@@ -42,4 +33,21 @@
rd.rdoc_files.include("lib/**/*.rb")
rd.main = 'Solr::Connection'
rd.rdoc_dir = 'doc'
+end
+
+# append to the test task so that we can wrap
+# Rake::TestTask with a call to start/stop a solr server
+
+task :test do
+ start_solr
+end
+
+Rake::TestTask.new('test') do |t|
+ t.pattern = 'test/*_test.rb'
+ t.verbose = true
+ t.ruby_opts = ['-r solr', '-r test/unit']
+end
+
+task :test do
+ stop_solr
end
Added: incubator/solr/trunk/client/ruby/solrb/test/solr_server.rb
URL: http://svn.apache.org/viewvc/incubator/solr/trunk/client/ruby/solrb/test/solr_server.rb?view=auto&rev=492374
==============================================================================
--- incubator/solr/trunk/client/ruby/solrb/test/solr_server.rb (added)
+++ incubator/solr/trunk/client/ruby/solrb/test/solr_server.rb Wed Jan 3 17:00:30 2007
@@ -0,0 +1,41 @@
+#!/usr/bin/ruby
+
+# TODO: would be nice to be able to start up
+# solr on another port than the default one
+# so we don't interfere with one that's currently
+# running.
+
+def start_solr
+ Dir.chdir(File.dirname(__FILE__) + '/../solr') do
+ puts "starting solr server"
+
+ # subprocess to run our solr server
+ $SOLR_PID = fork do
+
+ # dissassociate from the process group for the unit tests
+ Process.setsid
+
+ # don't want to see the messages about solr starting up
+ STDERR.close
+
+ # start 'er up
+ system 'java -Djetty.port=8888 -jar start.jar'
+ end
+ end
+
+ # wait for the jvm and solr to start
+ sleep 5
+end
+
+def stop_solr
+ puts "stopping solr server"
+ # stop all the processes we can by terminating the group
+ process_group_id = Process.getpgid($SOLR_PID)
+ Process.kill(-15, process_group_id)
+end
+
+if __FILE__ == $0
+ start_solr
+ stop_solr
+end
+