Skip to content

Commit

Permalink
Merge pull request #190 from Cadasta/bugfix/squid-for-testing
Browse files Browse the repository at this point in the history
Squid setup for functional testing
  • Loading branch information
oliverroick committed May 17, 2016
2 parents e49a0c2 + 3391cfc commit c1120c0
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 2 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ addons:
before_install:
- export DEBIAN_FRONTEND=noninteractive
- sudo -E apt-get -yq update &>> ~/apt-get-update.log
- sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install postgresql-9.4-postgis-2.2
- sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install postgresql-9.4-postgis-2.2 squid3
- export PATH=$(echo $PATH | tr ':' "\n" | sed '/\/opt\/python/d' | tr "\n" ":" | sed "s|::|:|g")

install:
- pip install tox==2.3.1

before_script:
- sudo cp provision/roles/testing/files/squid.conf /etc/squid3/squid.conf
- sudo service squid3 restart
- export http_proxy=http://localhost:3128/
- export https_proxy=https://localhost:3128/
- export DJANGO_SETTINGS_MODULE=config.settings.travis
- psql template1 postgres -c 'create extension hstore;'
- psql -c 'create database cadasta;' -U postgres
Expand Down
33 changes: 33 additions & 0 deletions provision/roles/testing/files/squid.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT

http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost manager
http_access deny manager
http_access allow localhost
http_access deny all

http_port 3128

coredump_dir /var/spool/squid3

refresh_pattern ^http://?.tile.openstreetmap.org 1440 20% 10080 ignore-reload
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern (Release|Packages(.gz)*)$ 0 20% 2880
refresh_pattern . 0 20% 4320

acl local dstdomain localhost
always_direct allow local
4 changes: 4 additions & 0 deletions provision/roles/testing/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- name: Restart Squid
become: yes
become_user: root
service: name=squid3 state=restarted enabled=yes
22 changes: 21 additions & 1 deletion provision/roles/testing/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,33 @@
- name: Install Firefox and Xvfb
- name: Install Firefox, Xvfb and Squid
become: yes
become_user: root
apt: pkg={{ item }} state=installed update_cache=yes
with_items:
- firefox
- xvfb
- squid3

- name: Install Python Selenium driver
become: yes
become_user: "{{ app_user }}"
pip: virtualenv="{{ virtualenv_path }}"
name=selenium

- name: Set up Squid configuration
become: yes
become_user: root
copy: src=squid.conf dest=/etc/squid3/squid.conf owner=root mode=644
notify:
- Restart Squid

- name: Set up HTTP proxy
become: yes
become_user: "{{ app_user }}"
lineinfile: dest=/home/vagrant/.bashrc
line="export http_proxy=http://localhost:3128/"

- name: Set up HTTPS proxy
become: yes
become_user: "{{ app_user }}"
lineinfile: dest=/home/vagrant/.bashrc
line="export https_proxy=https://localhost:3128/"

0 comments on commit c1120c0

Please sign in to comment.