From c22b57d37d23c18f232f73d69ed321b2a4286287 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 17 Aug 2008 19:30:03 +0200 Subject: [PATCH] [TESTS] test-fsm: 22 regression tests for state machines 22 regression tests for state machines are managed by the new file tests/test-fsm.cfg. Check it, they are all documented inside. Most of the bugs introduced during the FSM extraction have been found with these tests. --- tests/test-fsm.cfg | 293 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 293 insertions(+) create mode 100644 tests/test-fsm.cfg diff --git a/tests/test-fsm.cfg b/tests/test-fsm.cfg new file mode 100644 index 000000000..3b6dbdf0b --- /dev/null +++ b/tests/test-fsm.cfg @@ -0,0 +1,293 @@ +# This is a test configuration. +# It exercises some critical state machine transitions. Start it in debug +# mode with syslogd listening to UDP socket, facility local0. + +########### test#0001: process_cli(), read or write error +# setup : +# server = (printf "HTTP/1.0 200 OK\r\n\r\n";cat /dev/zero) | nc -lp4000 +# client = (printf "GET / HTTP/1.0\r\n\r\n";cat) | nc 127.1 8001 >/dev/null +# action : kill client during transfer (Ctrl-C) +# result : both sides must close, and logs must report "CD" flags with +# valid timers and counters. (note: high CPU usage expected) +# example: 0/0/3/0/5293 200 76420076 - - CD-- + +########### test#0002: process_cli(), read closed on client side first +# setup : +# server = (printf "HTTP/1.0 200 OK\r\n\r\n";cat /dev/zero) | nc -lp4000 +# client = (printf "GET / HTTP/1.0\r\n\r\n";cat) | nc 127.1 8001 +# action : end client output during transfer (Ctrl-D) +# result : client exits, log is emitted immediately, server must be terminated +# by hand. Logs indicate "----" with correct timers. +# example: 0/0/3/0/5293 200 76420076 - - ---- +# note : test#0003 is triggered immediately after this test + +########### test3: process_cli(), read closed on server side first +# setup : +# server = (printf "HTTP/1.0 200 OK\r\n\r\n";cat) | nc -lp4000 +# client = (printf "GET / HTTP/1.0\r\n\r\n";cat) | nc 127.1 8001 +# action : end server output during transfer (Ctrl-D) +# result : server exits, log is emitted immediately, client must be terminated +# by hand. Logs indicate "----" with correct timers. +# example: 0/0/3/0/5293 200 76420076 - - ---- +# note : test#0002 is triggered immediately after this test + +########### test4: process_cli(), read timeout on client side +# setup : +# server = (printf "HTTP/1.0 200 OK\r\n\r\n";cat) | nc -lp4000 +# client = (printf "GET / HTTP/1.0\r\n\r\n";cat) | nc 127.1 8001 +# action : wait at least 7 seconds and check the logs +# result : log is emitted immediately, client and server must be terminated +# by hand. Logs indicate "cD--" with correct timers. +# example: 0/0/1/0/7006 200 19 - - cD-- +# note : test#0003 is triggered immediately after this test + +########### test5: ability to restart read after a request buffer full +# setup : +# server = (printf "HTTP/1.0 200 OK\r\n\r\n"; cat) | nc -lp4000 +# client = (printf "GET / HTTP/1.0\r\n\r\n";cat 8k.txt;cat) | nc 127.1 8001 +# action : enter data on the client, press enter, then Ctrl-D +# result : data transferred to the server, client exits, log is emitted +# immediately, server must be terminated by hand. Logs indicate +# "----" with correct timers. +# example: 0/0/0/0/3772 200 19 - - ---- + +########### test6: ability to restart read after a request buffer partially full +# setup : +# server = (printf "HTTP/1.0 200 OK\r\n\r\n"; cat) | nc -lp4000 +# client = (printf "GET / HTTP/1.0\r\n\r\n";cat 7k.txt;cat) | nc 127.1 8001 +# action : enter data on the client, press enter, then Ctrl-D +# result : data transferred to the server, client exits, log is emitted +# immediately, server must be terminated by hand. Logs indicate +# "----" with correct timers. +# example: 0/0/0/0/3772 200 19 - - ---- + +########### test7: ability to restart read after a response buffer full +# setup : +# server = (printf "HTTP/1.0 200 OK\r\n\r\n";cat 8k.txt; cat) | nc -lp4000 +# client = (printf "GET / HTTP/1.0\r\n\r\n";cat) | nc 127.1 8001 +# action : enter data on the server, press enter, then Ctrl-D +# result : data transferred to the client, server exits, log is emitted +# immediately, client must be terminated by hand. Logs indicate +# "----" with correct timers. +# example: 0/0/0/0/3087 200 8242 - - ---- + +########### test8: ability to restart read after a response buffer partially full +# setup : +# server = (printf "HTTP/1.0 200 OK\r\n\r\n";cat 7k.txt; cat) | nc -lp4000 +# client = (printf "GET / HTTP/1.0\r\n\r\n";cat) | nc 127.1 8001 +# action : enter data on the server, press enter, then Ctrl-D +# result : data transferred to the client, server exits, log is emitted +# immediately, client must be terminated by hand. Logs indicate +# "----" with correct timers. +# example: 0/0/0/0/5412 200 7213 - - ---- + +########### test9: process_cli(), read timeout on empty request +# setup : +# server = (printf "HTTP/1.0 200 OK\r\n\r\n";cat) | nc -lp4000 +# client = nc 127.1 8001 +# action : wait at least 5 seconds and check the logs +# result : client returns 408, log is emitted immediately, server must be +# terminated by hand. Logs indicate "cR--" with correct timers +# and "" +# example: -1/-1/-1/-1/5000 408 212 - - cR-- + +########### test10: process_cli(), read timeout on client headers +# setup : +# server = (printf "HTTP/1.0 200 OK\r\n\r\n";cat) | nc -lp4000 +# client = (printf "GET / HTTP/1.0\r\nTest: test\r\n";cat) | nc 127.1 8001 +# action : wait at least 5 seconds and check the logs +# result : client returns 408, log is emitted immediately, both must be +# terminated by hand. Logs indicate "cR--" with correct timers +# and "" +# example: -1/-1/-1/-1/5004 408 212 - - cR-- + +########### test11: process_cli(), read abort on empty request +# setup : +# server = (printf "HTTP/1.0 200 OK\r\n\r\n";cat) | nc -lp4000 +# client = echo -n | nc 127.1 8001 +# action : just check the logs after the client immediately returns +# result : client returns 400, log is emitted immediately, server must be +# terminated by hand. Logs indicate "CR--" with correct timers +# and "" +# example: -1/-1/-1/-1/0 400 187 - - CR-- + +########### test12: process_cli(), read abort on client headers +# setup : +# server = (printf "HTTP/1.0 200 OK\r\n\r\n";cat) | nc -lp4000 +# client = (printf "GET / HTTP/1.0\r\nTest: test\r\n") | nc 127.1 8001 +# action : just check the logs after the client immediately returns +# result : client returns 400, log is emitted immediately, server must be +# terminated by hand. Logs indicate "CR--" with correct timers +# and "" +# example: -1/-1/-1/-1/0 400 187 - - CR-- + +########### test13: process_srv(), read timeout on empty response +# setup : +# server = nc -lp4000 +# client = (printf "GET / HTTP/1.0\r\n\r\n"; cat) | nc 127.1 8001 +# action : wait 9 seconds and check response +# result : client exits with 504, log is emitted immediately, client must be +# terminated by hand. Logs indicate "sH--" with correct timers. +# example: 0/0/0/-1/8002 504 194 - - sH-- + +########### test14: process_srv(), closed client during response timeout +# setup : +# server = nc6 --half-close -lp4000 +# client = (printf "GET / HTTP/1.0\r\n\r\n"; sleep 1) | nc 127.1 8001 +# action : wait 9 seconds and check response +# result : client exits with 504, log is emitted immediately, server must be +# terminated by hand. Logs indicate "sH--" with correct timers, which +# is 9s total (sleep 1 + 8 for server response). +# example: 0/0/0/-1/9002 504 194 - - sH-- + +########### test15: process_srv(), client close causing server close +# setup : +# server = nc6 -lp4000 +# client = (printf "GET / HTTP/1.0\r\n\r\n"; sleep 1) | nc 127.1 8001 +# action : wait 1 second and check response +# result : client exits with 502, log is emitted immediately, server closes. +# Logs indicate "SH--" with correct timers. +# example: 0/0/0/-1/1002 502 204 - - SH-- + +########### test16: process_srv(), read timeout on server headers +# setup : +# server = (printf "HTTP/1.0 200 OK\r\nTest: test\r\n";cat) | nc -lp4000 +# client = (printf "GET / HTTP/1.0\r\n\r\n"; cat) | nc 127.1 8001 +# action : wait 8 seconds and check response +# result : client exits with 504, log is emitted immediately, both must be +# terminated by hand. Logs indicate "sH--" with correct timers. +# example: 0/0/0/-1/8004 504 223 - - sH-- + +########### test17: process_srv(), connection time-out +# setup : +# config = retries 1 +# server = none +# client = (printf "GET / HTTP/1.0\r\n\r\n";cat) | nc 127.1 8002 +# action : wait at least 12 seconds and check the logs +# result : client returns 503 and must be terminated by hand. Log is emitted +# immediately. Logs indicate "sC--" with correct timers. +# example: 0/6001/-1/-1/12001 503 212 - - sC-- + +########### test18: process_srv(), client close during connection time-out +# setup : +# config = retries 1 +# server = none +# client = (printf "GET / HTTP/1.0\r\n\r\n";sleep 1) | nc 127.1 8002 +# action : wait at least 12 seconds and check the logs +# result : client returns 503 and automatically closes. Log is emitted +# immediately. Logs indicate "sC--" with correct timers. +# example: 0/6001/-1/-1/12001 503 212 - - sC-- + +########### test19: process_srv(), immediate server close after empty response +# setup : +# server = echo -n | nc -lp4000 +# client = (printf "GET / HTTP/1.0\r\n\r\n") | nc 127.1 8001 +# action : just check logs after immediate return. +# result : client and server exit with 502, log is emitted immediately. Logs +# indicate "SH--" with correct timers. +# example: 0/0/0/-1/0 502 204 - - SH-- + +########### test20: process_srv(), immediate server close after incomplete headers +# setup : +# server = (printf "HTTP/1.0 200 OK\r\nTest: test\r\n") | nc -lp4000 +# client = (printf "GET / HTTP/1.0\r\n\r\n") | nc 127.1 8001 +# action : just check logs after immediate return. +# result : client and server exit with 502, log is emitted immediately. Logs +# indicate "SH--" with correct timers. +# example: 0/0/0/-1/0 502 233 - - SH-- + +########### test21: process_srv(), immediate server close after complete headers +# setup : +# server = (printf "HTTP/1.0 200 OK\r\nTest: test\r\n\r\n") | nc -lp4000 +# client = (printf "GET / HTTP/1.0\r\n\r\n") | nc 127.1 8001 +# action : just check logs after immediate return. +# result : client and server exit with 200, log is emitted immediately. Logs +# indicate "----" with correct timers. +# example: 0/0/0/0/0 200 31 - - ---- + +########### test22: process_srv(), timeout on request body +# setup : +# server = (printf "HTTP/1.0 200 OK\r\nTest: test\r\n\r\n") | nc -lp4000 +# client = (printf "POST / HTTP/1.0\r\nContent-length: 20\r\n\r\n";cat) | nc 127.1 8001 +# action : wait 5s for the request body to timeout. +# result : The server receives the request and responds immediately with 200. +# Log is emitted immediately. Logs indicate "----" with correct timers. +# example: 5002/0/0/0/5002 200 31 - - ---- + + + +global + maxconn 100 + log 127.0.0.1 local0 + debug + +# connect to port 8000 to consult statistics +listen stats + timeout client 5s + mode http + bind :8000 + balance + stats uri /stat + +# connect port 8001 to localhost:4000 +listen frt8001 + log global + bind :8001 + mode http + option httplog + maxconn 100 + + timeout http-request 5s + timeout connect 6s + timeout client 7s + timeout server 8s + timeout queue 9s + + balance url_param foo check_post + server srv4000 127.0.0.1:4000 + +# connect port 8002 to nowhere +listen frt8002 + log global + bind :8002 + mode http + option httplog + maxconn 100 + + timeout http-request 5s + timeout connect 6s + timeout client 7s + timeout server 8s + timeout queue 9s + retries 1 + + balance url_param foo check_post + server srv4000 192.168.255.255:4000 + + +# listen frt8002 +# log global +# bind :8002 +# mode http +# option httplog +# maxconn 100 +# +# timeout http-request 5s +# timeout connect 6s +# timeout client 7s +# timeout server 8s +# timeout queue 9s +# +# #tcp-request inspect-delay 4s +# acl white_list src 127.0.0.2 +# +# tcp-request content accept if white_list +# tcp-request content reject if !REQ_CONTENT +# +# balance url_param foo check_post +# #balance url_param foo #check_post +# server srv4000 127.0.0.1:4000 +# +# # control activity this way +# stats uri /stat +#