Browse files

Move test Solr instructions into a script

These will just rot horribly if they're not actually executed on a
regular basis…
  • Loading branch information...
1 parent e591aab commit c18af0263757e651c591ab634faecd9d14594969 @acdha acdha committed Dec 18, 2013
Showing with 40 additions and 8 deletions.
  1. +4 −8 docs/running_tests.rst
  2. +36 −0 tests/
@@ -78,11 +78,7 @@ Configuring Solr
Haystack assumes that you have a Solr server running on port ``9001`` which uses the schema and
-configuration provided in the ``tests/`` directory. Currently, these steps will result in a working
-test server:
-#. Download the current Solr release from
-#. Copy ``tests/solrconfig.xml`` to ``example/solr/conf/solrconfig.xml``
-#. Copy ``tests/solr_test_schema.xml`` to ``example/solr/conf/schema.xml``
-#. Change into the ``example`` directory
-#. Start Solr: ``java -Djetty.port=9001 -jar start.jar``
+configuration provided in the ``tests/`` directory. For convenience, a script is provided which
+will download, configure and start a test Solr server::
+ tests/
@@ -0,0 +1,36 @@
+set -e
+export TEST_ROOT=$(realpath $( dirname $0 ) )
+if [ ! -f solr-4.6.0.tgz ]; then
+ curl -O
+echo "Extracting Solr 4.6.0 to `pwd`/solr4/"
+rm -rf solr4
+mkdir solr4
+tar -C solr4 -xf solr-4.6.0.tgz --strip-components 2 solr-4.6.0/example
+tar -C solr4 -xf solr-4.6.0.tgz --strip-components 1 solr-4.6.0/dist solr-4.6.0/contrib
+echo "Changing into solr4"
+cd solr4
+echo "Configuring Solr"
+cp ${TEST_ROOT}/solrconfig.xml solr/collection1/conf/solrconfig.xml
+cp ${TEST_ROOT}/schema.xml solr/collection1/conf/schema.xml
+# Fix paths for the content extraction handler:
+perl -p -i -e 's|<lib dir="../../../contrib/|<lib dir="../../contrib/|'g solr/*/conf/solrconfig.xml
+perl -p -i -e 's|<lib dir="../../../dist/|<lib dir="../../dist/|'g solr/*/conf/solrconfig.xml
+# Add MoreLikeThis handler
+perl -p -i -e 's|<!-- A Robust Example|<!-- More like this request handler -->\n <requestHandler name="/mlt" class="solr.MoreLikeThisHandler" />\n\n\n <!-- A Robust Example|'g solr/*/conf/solrconfig.xml
+echo 'Starting server'
+# We use exec to allow process monitors to correctly kill the
+# actual Java process rather than this launcher script:
+exec java -D9001 -Djava.awt.headless=true -Dapple.awt.UIElement=true -jar start.jar

0 comments on commit c18af02

Please sign in to comment.