Skip to content

Commit b724a96

Browse files
committed
Add script to test a Mapit database upgrade
We replay Mapit data to ensure that the upgrade works as we expect.
1 parent bd24cbd commit b724a96

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

mapit.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from fabric.api import task, settings, sudo, env
1+
from fabric.api import task, settings, sudo, env, run
22
from fabric.tasks import execute
33

44
import app
@@ -22,3 +22,18 @@ def update_database():
2222
sudo("psql -c 'DROP DATABASE mapit;'")
2323

2424
execute(puppet.agent, '--test')
25+
26+
27+
@task
28+
def check_database_upgrade():
29+
"""Replay yesterday's Mapit requests to ensure that a database upgrade works"""
30+
31+
sudo("awk '$9==200 {print \"http://localhost\" $7}' /var/log/nginx/mapit.access.log.1 > mapit-200s")
32+
sudo("awk '$9==404 {print \"http://localhost\" $7}' /var/log/nginx/mapit.access.log.1 > mapit-404s")
33+
34+
print "Replaying Mapit 200s. Ensure that they are all still 200s."
35+
run('while read line; do curl -sI $line | grep HTTP/1.1 ; done < mapit-200s | sort | uniq -c')
36+
print "Replaying Mapit 404s. Ensure that they are all either 200s or 404s."
37+
run('while read line; do curl -sI $line | grep HTTP/1.1 ; done < mapit-404s | sort | uniq -c')
38+
39+
sudo('rm ~/mapit-200s ~/mapit-404s')

0 commit comments

Comments
 (0)