Permalink
Browse files

Update bootstrap docs and scripts to support unit testing.

  • Loading branch information...
1 parent 9733806 commit 9cc4525fe8c2e17781d65fc46f74bae6286bc0bb @onyxfish onyxfish committed Nov 2, 2011
Showing with 78 additions and 12 deletions.
  1. +31 −4 README.rst
  2. +36 −7 fabfile.py
  3. +10 −1 setup_panda.sh
  4. +1 −0 setup_panda/solr.xml
View
35 README.rst
@@ -10,13 +10,15 @@ Feature list and much more on `the PANDA Project Wiki <https://github.com/pandap
Local development & testing
---------------------------
-Requirements:
+**Install basic requirements**:
* pip
* virtualenv
* virtualenvwrapper
-Setup script::
+**Setup PANDA**
+
+This will setup the complete application, *except* for Solr::
git clone git://github.com/pandaproject/panda.git
cd panda
@@ -30,9 +32,34 @@ Setup script::
python manage.py celeryd
- # In a separate shell
+ # In a separate terminal
python manage.py runserver
+**Setup Solr**
+
+This part is tricky and will vary quite a bit depending on your operating system. The following instructions will get you up and running on OSX Lion, using `Homebrew <https://github.com/mxcl/homebrew>`_::
+
+ # Homebrew's recipe installs 3.3, but we need 3.4...
+ # When your text editor pops up find and replace "3.3.0" with "3.4.0", save, and close.
+ brew edit solr
+
+ # Install solr
+ brew install solr
+
+ # Ensure you are in the PANDA source directory and your virtualenv is active
+ # This command will install all panda configuration
+ fab local_reset_solr
+
+**Running unit tests**
+
+To run the unit tests ensure that runserver and celeryd are **not** running then start Solr and execute the test runner, like so::
+
+ # Ensure you are in the PANDA source directory and your virtualenv is active
+ fab local_solr
+
+ # In a separate terminal
+ python manage.py test redd
+
Production deployment
---------------------
@@ -41,7 +68,7 @@ Get hold of an Ubuntu 11.10 server--an EC2 small based off of ami-a7f539ce works
wget https://raw.github.com/pandaproject/panda/master/setup_panda.sh
sudo bash setup_panda.sh
-Your new panda server should now be serving on port 80. (Ensure port 80 is open in your security group.)
+Your new PANDA server should now be serving on port 80. (Ensure port 80 is open in your security group.)
AUTHORS
-------
View
43 fabfile.py
@@ -19,6 +19,9 @@
env.python = 'python2.7'
env.repository_url = 'git://github.com/pandaproject/panda.git'
env.hosts = ['panda.beta.tribapps.com']
+
+env.local_solr = '/usr/local/Cellar/solr/3.4.0/libexec/example'
+env.local_solr_home = '/var/solr'
"""
Branches
@@ -187,16 +190,42 @@ def local_reset():
"""
Reset the local database and Solr instance.
"""
- local('dropdb panda && createdb panda && python manage.py syncdb --noinput')
- local('rm -rf /var/solr/pandadata/data')
- local('cp setup_panda/solr.xml /var/solr/solr.xml')
- local('cp setup_panda/panda.jar /var/solr/pandadata/lib/panda.jar')
- local('cp setup_panda/solrconfig.xml /var/solr/pandadata/conf/solrconfig.xml')
- local('cp setup_panda/schema.xml /var/solr/pandadata/conf/schema.xml')
+ local_reset_database()
+ local_reset_solr()
+
+def local_reset_database():
+ """
+ Reset the local database.
+ """
+ local('dropdb %(project_name)s && createdb -O %(project_name)s %(project_name)s && python manage.py syncdb --noinput' % env)
+
+def local_reset_solr():
+ """
+ Reset the local solr configuration.
+ """
+ local('mkdir -p /var/solr')
+
+ local('cp setup_panda/solr.xml %(local_solr_home)s/solr.xml' % env)
+
+ local('mkdir -p %(local_solr_home)s/pandadata/conf' % env)
+ local('mkdir -p %(local_solr_home)s/pandadata/lib' % env)
+ local('rm -rf %(local_solr_home)s/pandadata/data' % env)
+
+ local('cp setup_panda/panda.jar %(local_solr_home)s/pandadata/lib/panda.jar' % env)
+ local('cp setup_panda/solrconfig.xml %(local_solr_home)s/pandadata/conf/solrconfig.xml' % env)
+ local('cp setup_panda/schema.xml %(local_solr_home)s/pandadata/conf/schema.xml' % env)
+
+ local('mkdir -p %(local_solr_home)s/pandadata_test/conf' % env)
+ local('mkdir -p %(local_solr_home)s/pandadata_test/lib' % env)
+ local('rm -rf %(local_solr_home)s/pandadata_test/data' % env)
+
+ local('cp setup_panda/panda.jar %(local_solr_home)s/pandadata_test/lib/panda.jar' % env)
+ local('cp setup_panda/solrconfig.xml %(local_solr_home)s/pandadata_test/conf/solrconfig.xml' % env)
+ local('cp setup_panda/schema.xml %(local_solr_home)s/pandadata_test/conf/schema.xml' % env)
def local_solr():
"""
Start the local Solr instance.
"""
- local('cd /usr/local/Cellar/solr/3.4.0/libexec/example/ && java -Xms256M -Xmx512G -Dsolr.solr.home=/var/solr/ -jar start.jar')
+ local('cd %(local_solr)s && java -Xms256M -Xmx512G -Dsolr.solr.home=%(local_solr_home)s -jar start.jar' % env)
View
11 setup_panda.sh
@@ -35,15 +35,24 @@ tar -xzf apache-solr-3.4.0.tgz
mv apache-solr-3.4.0 solr
cp -r solr/example solr/panda
+wget $CONFIG_URL/solr.xml -O /opt/solr/panda/solr/solr.xml
+
mkdir /opt/solr/panda/solr/pandadata
mkdir /opt/solr/panda/solr/pandadata/conf
mkdir /opt/solr/panda/solr/pandadata/lib
-wget $CONFIG_URL/solr.xml -O /opt/solr/panda/solr/solr.xml
wget $CONFIG_URL/schema.xml -O /opt/solr/panda/solr/pandadata/conf/schema.xml
wget $CONFIG_URL/solrconfig.xml -O /opt/solr/panda/solr/pandadata/conf/solrconfig.xml
wget $CONFIG_URL/panda.jar -O /opt/solr/panda/solr/pandadata/lib/panda.jar
+mkdir /opt/solr/panda/solr/pandadata_test
+mkdir /opt/solr/panda/solr/pandadata_test/conf
+mkdir /opt/solr/panda/solr/pandadata_test/lib
+
+wget $CONFIG_URL/schema.xml -O /opt/solr/panda/solr/pandadata_test/conf/schema.xml
+wget $CONFIG_URL/solrconfig.xml -O /opt/solr/panda/solr/pandadata_test/conf/solrconfig.xml
+wget $CONFIG_URL/panda.jar -O /opt/solr/panda/solr/pandadata_test/lib/panda.jar
+
adduser --system --no-create-home --disabled-login --disabled-password --group solr
chown -R solr:solr /opt/solr
View
1 setup_panda/solr.xml
@@ -4,6 +4,7 @@
<cores adminPath="/admin/cores" defaultCoreName="data">
<core name="data" instanceDir="pandadata" />
+ <core name="data_test" instanceDir="pandadata_test" />
</cores>
</solr>

0 comments on commit 9cc4525

Please sign in to comment.