-
Notifications
You must be signed in to change notification settings - Fork 2k
/
travis-build
executable file
·65 lines (51 loc) · 2.43 KB
/
travis-build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh
# Drop Travis' postgres cluster if we're building using a different pg version
TRAVIS_PGVERSION='9.1'
if [ $PGVERSION != $TRAVIS_PGVERSION ]
then
sudo -u postgres pg_dropcluster --stop $TRAVIS_PGVERSION main
# Make psql use $PGVERSION
export PGCLUSTER=$PGVERSION/main
fi
# Install postgres and solr
# We need this ppa so we can install postgres-8.4
sudo add-apt-repository -yy ppa:pitti/postgresql
sudo apt-get update -qq
sudo apt-get install -qq solr-jetty postgresql-$PGVERSION
# Don't require a password to access DB
#sudo sed -i -e 's/ident/trust/g' /etc/postgresql/$PGVERSION/main/pg_hba.conf
sudo service postgresql reload
pip install -r pip-requirements.txt --use-mirrors
pip install -r pip-requirements-test.txt --use-mirrors
# make users
sudo -u postgres psql -c "CREATE USER ckanuser WITH PASSWORD 'pass';"
sudo -u postgres psql -c "CREATE USER readonlyuser WITH PASSWORD 'pass';"
# make databases psql
sudo -u postgres psql -c 'CREATE DATABASE ckan_test WITH OWNER ckanuser;'
sudo -u postgres psql -c 'CREATE DATABASE ckan_test_datastore WITH OWNER ckanuser;'
# Check postgres version
psql -U ckanuser ckan_test -c 'SELECT version();'
python setup.py develop
### Configure CKAN's configuration file
##sed -i -e 's/.*solr_url.*/solr_url = http:\/\/127.0.0.1:8983\/solr/' test-core.ini
##sed -i -e 's/.*ckan\.site_id.*/ckan.site_id = travis_ci/' test-core.ini
##sed -i -e 's/^sqlalchemy.url.*/sqlalchemy.url = postgresql:\/\/postgres@\/ckan_test/' test-core.ini
##sed -i -e 's/.*datastore.write_url.*/ckan.datastore.write_url = postgresql:\/\/postgres@\/ckan_test_datastore/' test-core.ini
# Configure Solr
echo "NO_START=0\nJETTY_HOST=127.0.0.1\nJETTY_PORT=8983\nJAVA_HOME=$JAVA_HOME" | sudo tee /etc/default/jetty
# FIXME the solr schema cannot be hardcoded as it is dependent on the ckan version
sudo cp ckan/config/solr/schema-2.0.xml /etc/solr/conf/schema.xml
sudo service jetty restart
paster db init -c test-core.ini
# If Postgres >= 9.0, we don't need to use datastore's legacy mode.
if [ $PGVERSION != '8.4' ]
then
psql -c 'CREATE USER readonlyuser;' -U postgres
sed -i -e 's/.*datastore.read_url.*/ckan.datastore.read_url = postgresql:\/\/readonlyuser@\/ckan_test_datastore/' test-core.ini
paster datastore set-permissions postgres -c test-core.ini
else
sed -i -e 's/.*datastore.read_url.*//' test-core.ini
fi
cat test-core.ini
# And finally, run the tests
nosetests --ckan --with-pylons=test-core.ini --nologcapture ckan ckanext