Commit 0e53952f243ef04383a6f056aa14f5aee880060a

Authored by Sergio Oliveira
2 parents 0cc7560f 45a99cb5

Merge branch 'travis_solr' into 'master'

Travis solr

Added script to run solr in travis_ci
.travis.yml
... ... @@ -5,11 +5,20 @@ cache: apt
5 5 python:
6 6 - "2.7"
7 7  
  8 +env:
  9 + global:
  10 + - DJANGO_SETTINGS_MODULE=tests.settings
  11 + - COLAB_SETTINGS=tests/settings.yaml
  12 +
8 13 install:
9 14 - pip install coveralls flake8
10 15 - pip install .
11 16 - psql -c "CREATE USER colab WITH PASSWORD 'colab' CREATEDB;" -U postgres
12 17  
  18 +before_script:
  19 + - colab-admin build_solr_schema > /tmp/schema.xml
  20 + - cat ci/install_solr.sh | SOLR_VERSION=4.10.3 SOLR_CONFS="/tmp/schema.xml" bash
  21 +
13 22 script:
14 23 - python setup.py test
15 24 - flake8 colab
... ...
ci/install_solr.sh 0 → 100755
... ... @@ -0,0 +1,222 @@
  1 +#!/usr/bin/env bash
  2 +
  3 +## Based on https://github.com/moliware/travis-solr/ (revision: 7975953)
  4 +
  5 +SOLR_PORT=${SOLR_PORT:-8983}
  6 +
  7 +download() {
  8 + FILE="$2.tgz"
  9 + if [ -f $FILE ];
  10 + then
  11 + echo "File $FILE exists."
  12 + tar -zxf $FILE
  13 + else
  14 + echo "Downloading solr from $1..."
  15 + curl -O $1
  16 + tar -zxf $FILE
  17 + fi
  18 + echo "Downloaded"
  19 +}
  20 +
  21 +is_solr_up(){
  22 + http_code=`echo $(curl -s -o /dev/null -w "%{http_code}" "http://localhost:$SOLR_PORT/solr/admin/ping")`
  23 + return `test $http_code = "200"`
  24 +}
  25 +
  26 +wait_for_solr(){
  27 + while ! is_solr_up; do
  28 + sleep 3
  29 + done
  30 +}
  31 +
  32 +run() {
  33 + echo "Starting solr on port ${SOLR_PORT}..."
  34 +
  35 + cd $1/example
  36 + if [ $DEBUG ]
  37 + then
  38 + java -Djetty.port=$SOLR_PORT -jar start.jar &
  39 + else
  40 + java -Djetty.port=$SOLR_PORT -jar start.jar > /dev/null 2>&1 &
  41 + fi
  42 + wait_for_solr
  43 + cd ../../
  44 + echo "Started"
  45 +}
  46 +
  47 +post_some_documents() {
  48 + java -Dtype=application/json -Durl=http://localhost:$SOLR_PORT/solr/update/json -jar $1/example/exampledocs/post.jar $2
  49 +}
  50 +
  51 +
  52 +download_and_run() {
  53 + case $1 in
  54 + 3.5.0)
  55 + url="http://archive.apache.org/dist/lucene/solr/3.5.0/apache-solr-3.5.0.tgz"
  56 + dir_name="apache-solr-3.5.0"
  57 + dir_conf="conf/"
  58 + ;;
  59 + 3.6.0)
  60 + url="http://archive.apache.org/dist/lucene/solr/3.6.0/apache-solr-3.6.0.tgz"
  61 + dir_name="apache-solr-3.6.0"
  62 + dir_conf="conf/"
  63 + ;;
  64 + 3.6.1)
  65 + url="http://archive.apache.org/dist/lucene/solr/3.6.1/apache-solr-3.6.1.tgz"
  66 + dir_name="apache-solr-3.6.1"
  67 + dir_conf="conf/"
  68 + ;;
  69 + 3.6.2)
  70 + url="http://archive.apache.org/dist/lucene/solr/3.6.2/apache-solr-3.6.2.tgz"
  71 + dir_name="apache-solr-3.6.2"
  72 + dir_conf="conf/"
  73 + ;;
  74 + 4.0.0)
  75 + url="http://archive.apache.org/dist/lucene/solr/4.0.0/apache-solr-4.0.0.tgz"
  76 + dir_name="apache-solr-4.0.0"
  77 + dir_conf="collection1/conf/"
  78 + ;;
  79 + 4.1.0)
  80 + url="http://archive.apache.org/dist/lucene/solr/4.1.0/solr-4.1.0.tgz"
  81 + dir_name="solr-4.1.0"
  82 + dir_conf="collection1/conf/"
  83 + ;;
  84 + 4.2.0)
  85 + url="http://archive.apache.org/dist/lucene/solr/4.2.0/solr-4.2.0.tgz"
  86 + dir_name="solr-4.2.0"
  87 + dir_conf="collection1/conf/"
  88 + ;;
  89 + 4.2.1)
  90 + url="http://archive.apache.org/dist/lucene/solr/4.2.1/solr-4.2.1.tgz"
  91 + dir_name="solr-4.2.1"
  92 + dir_conf="collection1/conf/"
  93 + ;;
  94 + 4.3.1)
  95 + url="http://archive.apache.org/dist/lucene/solr/4.3.1/solr-4.3.1.tgz"
  96 + dir_name="solr-4.3.1"
  97 + dir_conf="collection1/conf/"
  98 + ;;
  99 + 4.4.0)
  100 + url="http://archive.apache.org/dist/lucene/solr/4.4.0/solr-4.4.0.tgz"
  101 + dir_name="solr-4.4.0"
  102 + dir_conf="collection1/conf/"
  103 + ;;
  104 + 4.5.0)
  105 + url="http://archive.apache.org/dist/lucene/solr/4.5.0/solr-4.5.0.tgz"
  106 + dir_name="solr-4.5.0"
  107 + dir_conf="collection1/conf/"
  108 + ;;
  109 + 4.5.1)
  110 + url="http://archive.apache.org/dist/lucene/solr/4.5.1/solr-4.5.1.tgz"
  111 + dir_name="solr-4.5.1"
  112 + dir_conf="collection1/conf/"
  113 + ;;
  114 + 4.6.0)
  115 + url="http://archive.apache.org/dist/lucene/solr/4.6.0/solr-4.6.0.tgz"
  116 + dir_name="solr-4.6.0"
  117 + dir_conf="collection1/conf/"
  118 + ;;
  119 + 4.6.1)
  120 + url="http://archive.apache.org/dist/lucene/solr/4.6.1/solr-4.6.1.tgz"
  121 + dir_name="solr-4.6.1"
  122 + dir_conf="collection1/conf/"
  123 + ;;
  124 + 4.7.0)
  125 + url="http://archive.apache.org/dist/lucene/solr/4.7.0/solr-4.7.0.tgz"
  126 + dir_name="solr-4.7.0"
  127 + dir_conf="collection1/conf/"
  128 + ;;
  129 + 4.7.1)
  130 + url="http://archive.apache.org/dist/lucene/solr/4.7.1/solr-4.7.1.tgz"
  131 + dir_name="solr-4.7.1"
  132 + dir_conf="collection1/conf/"
  133 + ;;
  134 + 4.7.2)
  135 + url="http://archive.apache.org/dist/lucene/solr/4.7.2/solr-4.7.2.tgz"
  136 + dir_name="solr-4.7.2"
  137 + dir_conf="collection1/conf/"
  138 + ;;
  139 + 4.8.0)
  140 + url="http://archive.apache.org/dist/lucene/solr/4.8.0/solr-4.8.0.tgz"
  141 + dir_name="solr-4.8.0"
  142 + dir_conf="collection1/conf/"
  143 + ;;
  144 + 4.8.1)
  145 + url="http://archive.apache.org/dist/lucene/solr/4.8.1/solr-4.8.1.tgz"
  146 + dir_name="solr-4.8.1"
  147 + dir_conf="collection1/conf/"
  148 + ;;
  149 + 4.9.0)
  150 + url="http://archive.apache.org/dist/lucene/solr/4.9.0/solr-4.9.0.tgz"
  151 + dir_name="solr-4.9.0"
  152 + dir_conf="collection1/conf/"
  153 + ;;
  154 + 4.9.1)
  155 + url="http://archive.apache.org/dist/lucene/solr/4.9.1/solr-4.9.1.tgz"
  156 + dir_name="solr-4.9.1"
  157 + dir_conf="collection1/conf/"
  158 + ;;
  159 + 4.10.0)
  160 + url="http://archive.apache.org/dist/lucene/solr/4.10.0/solr-4.10.0.tgz"
  161 + dir_name="solr-4.10.0"
  162 + dir_conf="collection1/conf/"
  163 + ;;
  164 + 4.10.1)
  165 + url="http://archive.apache.org/dist/lucene/solr/4.10.1/solr-4.10.1.tgz"
  166 + dir_name="solr-4.10.1"
  167 + dir_conf="collection1/conf/"
  168 + ;;
  169 + 4.10.2)
  170 + url="http://archive.apache.org/dist/lucene/solr/4.10.2/solr-4.10.2.tgz"
  171 + dir_name="solr-4.10.2"
  172 + dir_conf="collection1/conf/"
  173 + ;;
  174 + 4.10.3)
  175 + url="http://archive.apache.org/dist/lucene/solr/4.10.3/solr-4.10.3.tgz"
  176 + dir_name="solr-4.10.3"
  177 + dir_conf="collection1/conf/"
  178 + ;;
  179 + esac
  180 +
  181 + download $url $dir_name
  182 +
  183 + # copies custom configurations
  184 + for file in $SOLR_CONFS
  185 + do
  186 + if [ -d $file ]
  187 + then
  188 + cp $file/* $dir_name/example/solr/$dir_conf
  189 + echo "Copied directory $file into solr conf directory."
  190 + elif [ -f $file ]
  191 + then
  192 + cp $file $dir_name/example/solr/$dir_conf
  193 + echo "Copied $file into solr conf directory."
  194 + fi
  195 + done
  196 +
  197 + # Run solr
  198 + run $dir_name $SOLR_PORT
  199 +
  200 + # Post documents
  201 + if [ -z "$SOLR_DOCS" ]
  202 + then
  203 + echo "$SOLR_DOCS not defined, skipping initial indexing"
  204 + else
  205 + echo "Indexing $SOLR_DOCS"
  206 + post_some_documents $dir_name $SOLR_DOCS
  207 + fi
  208 +}
  209 +
  210 +check_version() {
  211 + case $1 in
  212 + 3.5.0|3.6.0|3.6.1|3.6.2|4.0.0|4.1.0|4.2.0|4.2.1|4.3.1|4.4.0|4.5.0|4.5.1|4.6.0|4.6.1|4.7.0|4.7.1|4.7.2|4.8.0|4.8.1|4.9.0|4.9.1|4.10.0|4.10.1|4.10.2|4.10.3);;
  213 + *)
  214 + echo "Sorry, $1 is not supported or not valid version."
  215 + exit 1
  216 + ;;
  217 + esac
  218 +}
  219 +
  220 +
  221 +check_version $SOLR_VERSION
  222 +download_and_run $SOLR_VERSION
... ...
colab/accounts/tests/test_user.py
... ... @@ -5,6 +5,7 @@ Objective: Test parameters, and behavior.
5 5 from colab.accounts.models import User
6 6 from django.test import TestCase, Client
7 7  
  8 +
8 9 class UserTest(TestCase):
9 10  
10 11 def setUp(self):
... ...