forked from php-pm/php-pm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
integration_test.sh
executable file
·48 lines (47 loc) · 2.31 KB
/
integration_test.sh
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
#!/bin/bash
# exit when any command fails
set -e
# Integration test
mkdir web && echo "Hello" > web/index.html
bin/ppm start --workers=1 --bridge=StaticBridge --static-directory=web --max-requests=1 -v &
sleep 5
bin/ppm status
curl -v -f "http://127.0.0.1:8080"
bin/ppm status
curl -v -f "http://127.0.0.1:8080"
bin/ppm status
bin/ppm stop
# Test memory limit
bin/ppm start --workers=1 --bridge=PHPPM\\Tests\\TestBridge --static-directory=web --memory-limit=5 -v > /tmp/ppmout &
sleep 5
# Memory limit: Nothing should happen
curl -f --silent "http://127.0.0.1:8080/test?memory=0" &
sleep 5
bash -c 'grep -q "because it reached memory limit of 5" /tmp/ppmout || exit 0'
bin/ppm status
sleep 5
# Memory limit: Worker should restart
curl -f --silent "http://127.0.0.1:8080/test?memory=10" &
sleep 5
bash -c 'grep -q "because it reached memory limit of 5" /tmp/ppmout && exit 0'
bin/ppm status
bin/ppm stop
# Trigger 502 error by triggering an exit() in the worker
bin/ppm start --workers=1 --bridge=PHPPM\\Tests\\TestBridge --static-directory=web --max-requests=1 --max-execution-time=15 -v > /tmp/ppmout &
sleep 5
bash -c 'if [[ $(curl --write-out %{http_code} --silent --output /dev/null "http://127.0.0.1:8080/test?exit_prematurely=1") == "502" ]]; then exit 0; else exit 1; fi'
bin/ppm status
# Trigger 503 error by tying up the worker and making a second request
curl -f --silent "http://127.0.0.1:8080/test?sleep=10000" &
bash -c 'if [[ $(curl --write-out %{http_code} --silent --output /dev/null "http://127.0.0.1:8080") == "503" ]]; then exit 0; else exit 1; fi'
bin/ppm status
# Trigger 504 error by making a sleep request and waiting until the timeout
bash -c 'if [[ $(curl --write-out %{http_code} --silent --output /dev/null "http://127.0.0.1:8080/test?sleep=10000") == "504" ]]; then exit 0; else exit 1; fi'
bin/ppm status
# Trigger 502 error by making the bridge throw an exception
bash -c 'if [[ $(curl --write-out %{http_code} --silent --output /dev/null "http://127.0.0.1:8080/test?exception=1") == "502" ]]; then exit 0; else exit 1; fi'
bash -c 'grep -q "An exception was thrown by the bridge. Forcing restart of the worker. The exception was" /tmp/ppmout && exit 0'
bash -c 'grep -q "This is a very bad exception" /tmp/ppmout && exit 0'
bash -c 'grep -q "Shutdown function triggered" /tmp/ppmoutshutdownfunc && exit 0'
bin/ppm status
bin/ppm stop