Expand testing done via Travis CI to cover production pipeline.

With this change, we are now testing the production static asset
pipeline and installation process in a new testing job (and also run
the frontend/backend tests separately).

This means that changes that break the Zulip static asset pipeline or
production installation process are more likely to fail tests.  The
testing is imperfect in that it does not have proper isolation -- we
build a complete Zulip development environment and then install a
Zulip production environment on top of it, so e.g. any apt
dependencies installed for Zulip development will still be available
for the Zulip production environment.  But, it's better than nothing!

A good v2 of this would be to have the production setup process just
install the minimum stuff needed to run `build-release-tarball` and
then uninstall it / clean it up so that we can do a more clear
production installation, but that's more work.
This commit is contained in:
Tim Abbott 2015-10-14 19:47:42 -04:00
parent 421560af21
commit 6eb670097c
9 changed files with 82 additions and 4 deletions

View File

@ -1,14 +1,17 @@
install:
- pip install pbs
- python provision.py --travis
- tools/travis/setup-$TEST_SUITE
cache:
- apt: false
env:
- TEST_SUITE=frontend
- TEST_SUITE=backend
- TEST_SUITE=production
language: python
python:
- "2.7"
# command to run tests
script:
- source /srv/zulip-venv/bin/activate && env PATH=$PATH:/srv/zulip-venv/bin ./tools/test-all
- ./tools/travis/$TEST_SUITE
sudo: required
services:
- docker

View File

@ -11,7 +11,7 @@ deb-src http://ppa.launchpad.net/tabbott/zulip/ubuntu trusty main
EOF
apt-get update
apt-get -y dist-upgrade
apt-get -y dist-upgrade $APT_OPTIONS
apt-get install -y puppet git python
mkdir -p /etc/zulip

7
tools/travis/backend Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
set -e
set -x
source /srv/zulip-venv/bin/activate
export PATH=$PATH:/srv/zulip-venv/bin
./tools/lint-all
./tools/test-backend

7
tools/travis/frontend Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
set -e
set -x
source /srv/zulip-venv/bin/activate
export PATH=$PATH:/srv/zulip-venv/bin
./tools/test-js-with-node
./tools/test-js-with-casper

5
tools/travis/production Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
set -e
set -x
sudo ./tools/travis/production-helper

25
tools/travis/production-helper Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
set -e
set -x
apt-get install openssl ssl-cert
ln -s /etc/ssl/certs/ssl-cert-snakeoil.pem /etc/ssl/certs/zulip.combined-chain.crt
ln -s /etc/ssl/private/ssl-cert-snakeoil.key /etc/ssl/private/zulip.key
tar -xf zulip-server-travis.tar.gz
mv zulip-server-travis /root/zulip
export APT_OPTIONS="-o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold"
/root/zulip/scripts/setup/install
cat >>/etc/zulip/settings.py <<EOF
# Travis CI override settings above
EXTERNAL_HOST = 'zulip.travis.example.com'
ZULIP_ADMINISTRATOR = 'zulip-travis-admin@travis.example.com'
ADMIN_DOMAIN = 'travis.example.com'
AUTHENTICATION_BACKENDS = ( 'zproject.backends.EmailAuthBackend', )
NOREPLY_EMAIL_ADDRESS = 'noreply@travis.example.com'
DEFAULT_FROM_EMAIL = "Zulip <zulip@travis.example.com>"
EOF
su zulip -c /home/zulip/deployments/current/scripts/setup/initialize-database

5
tools/travis/setup-backend Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
set -e
set -x
pip install pbs
python provision.py --travis

1
tools/travis/setup-frontend Symbolic link
View File

@ -0,0 +1 @@
setup-backend

25
tools/travis/setup-production Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
set -e
set -x
pip install pbs
python provision.py --travis
source /srv/zulip-venv/bin/activate
./tools/build-release-tarball travis
mv /tmp/tmp.*/zulip-server-travis.tar.gz ./
# Shut down all services so that restarting postgres and rebuilding
# the postgres database to match the prod installation setup will work.
sudo supervisorctl stop all
# Clear memcached to avoid contamination between development and prod
# environments.
sudo /etc/init.d/memcached restart
# Drop any open connections to the development postgres installation.
sudo "$(dirname "$0")/../../scripts/setup/terminate-psql-sessions" postgres zulip zulip_base
# Remove and recreate the postgres database
sudo pg_ctlcluster 9.3 main stop
sudo pg_dropcluster 9.3 main
sudo rm -rf /etc/postgresql/9.3/main /var/lib/postgresql/9.3/main
sudo pg_createcluster 9.3 main