-
-
Notifications
You must be signed in to change notification settings - Fork 77
/
small.txt
166 lines (122 loc) · 4.96 KB
/
small.txt
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
---------------------------------------
Test the "small" sample specification.
---------------------------------------
>>> sample = 'sample-small.yml'
>>> extras = r"""
... admin_email: test@example.com
... plone_initial_password: admin
... additional_packages:
... - curl
... - lsof
... muninnode_query_ips:
... - 127.0.0.1
... """
>>> import subprocess
>>> import sys
>>> import time
Set up local-configure.yml by copying our sample.
Append admin email and password.
>>> with open(sample, 'r') as f:
... with open('local-configure.yml', 'w') as g:
... g.write(f.read() + extras)
Vagrant up
>>> print >> sys.stderr, "Bringing up %s" % box
>>> run("vagrant up %s --no-provision" % box)
Vagrant provision -- unless contraindicated.
>>> if skip_provisioning:
... print >> sys.stderr, "Skipping provisioning"
... else:
... print >> sys.stderr, "Provisioning"
... o = run("vagrant provision %s" % box)
Reboot the box. We only care about what survives a restart.
>>> if skip_restart:
... print >> sys.stderr, "Skipping restart"
... else:
... print >> sys.stderr, "Poweroff %s" % box
... p = subprocess.call('vagrant ssh %s -c "sudo poweroff"' % box, shell=True)
... time.sleep(10)
... print >> sys.stderr, "Bringing %s back up" % box
... run("vagrant up %s --no-provision" % box)
... print >> sys.stderr, "Waiting for services to start..."
... time.sleep(90)
And, now run tests against the box.
>>> print >> sys.stderr, "Running tests against box"
Use lsof to make sure we are listening on all expected ports
in all expected ways.
>>> rez = ssh_run('sudo lsof -i4 -i6 -sTCP:LISTEN -Pn | tail -n +2')
>>> listeners = sorted(set(cut(rez, [0, 2, 8])))
>>> print "\n".join([s for s in listeners if 'plone_daemon' in s])
python2.7 plone_daemon 127.0.0.1:8081
python2.7 plone_daemon 127.0.0.1:8181
zeoserver plone_daemon 127.0.0.1:8100
>>> print "\n".join([s for s in listeners if 'haproxy' in s])
<BLANKLINE>
>>> print "\n".join([s for s in listeners if 'nginx' in s])
nginx ... *:80
nginx ... *:80
# smtpd
>>> print "\n".join([s for s in listeners if ':25' in s])
master root *:25...
>>> print "\n".join([s for s in listeners if 'munin' in s])
munin-nod root *:4949
>>> rez = ssh_run('sudo lsof -i4 -sTCP:LISTEN -Pn | tail -n +2 | grep varnishd')
>>> listeners = sorted(set(cut(rez, [0, 8])))
>>> print "\n".join(listeners)
varnishd *:6081
varnishd 127.0.0.1:6082
Check the process list for Plone.
>>> print ssh_run('ps -eo comm,euser:15,egroup | egrep "plone" | egrep -v "(egrep|systemd)" | sort')
python2.7 plone_daemon plone_group
zeoserver plone_daemon plone_group
Check the process list for our fail2ban, which isn't yet up on CentOS.
>>> print ssh_run('ps -eo comm | grep fail2ban')
fail2ban-server
Check the process list for our other daemons.
>>> print ssh_run('ps -eo comm | egrep "(varnishd|nginx|haproxy|supervisor|memmon|munin|pickup|qmgr)" | egrep -v "(egrep|systemd)" | sort | uniq')
memmon
munin-node
nginx
pickup
qmgr
supervisord
varnishd
Check supervisor's job list.
>>> print joined_cut(ssh_run('sudo supervisorctl status'), [0, 1], True)
zeoserver_memmon RUNNING
zeoserver_zeoclient1 RUNNING
zeoserver_zeoserver RUNNING
We should be able to get a page on port 80.
>>> print ssh_run('curl --ipv4 -I -s http://%s | egrep "^(HTTP|Content-Type|X-Varnish-Cache)"' % box)
HTTP/1.1 200 OK
Content-Type: text/html;charset=utf-8
X-Varnish-Cache: MISS
And, we should have gzip encoding available:
>>> print ssh_run('curl --ipv4 -H "Accept-Encoding:gzip" -I -s http://%s | egrep "^(HTTP|Content-Encoding)"' % box)
HTTP/1.1 200 OK
Content-Encoding: gzip...
Asking twice for a static resource should result in a cache hit.
>>> print ssh_run('curl --ipv4 -I -s http://%s/logo.png > /dev/null' % box)
>>> print ssh_run('curl --ipv4 -I -s http://%s/logo.png | egrep "^(HTTP|Content-Type|X-Varnish-Cache)"' % box)
HTTP/1.1 200 OK
Content-Type: image/png
X-Varnish-Cache: HIT
The restart script exercises our control of the supervisor
processes, haproxy and varnish.
>>> print ssh_run('sudo /usr/local/plone-5.1/zeoserver/scripts/restart_clients.sh')
Restarting client 1
zeoserver_zeoclient1: stopped
Waiting a bit...
zeoserver_zeoclient1: started
Waiting a bit...
Fetch site homepages to warm cache
/Plone
Purging varnish cache
/Plone
Done
<BLANKLINE>
The varnish cache for this host should now be empty.
>>> print ssh_run('curl --ipv4 -I -s http://%s/logo.png | egrep "^(HTTP|Content-Type|X-Varnish-Cache)"' % box)
HTTP/1.1 200 OK
Content-Type: image/png
X-Varnish-Cache: MISS
>>> print >> sys.stderr, "Tests done"