Annotation of parser3/tests/httpd/max-connections/run_tests.sh, revision 1.2

1.1       moko        1: #!/bin/sh
                      2: # $HTTPD.max-connections: the server rejects new connections above limit with 503, $status:connections
                      3: 
                      4: PARSER=`pwd`/../../../src/targets/cgi/parser3
                      5: PORT=8102
                      6: 
1.2     ! moko        7: if command -v curl >/dev/null 2>&1; then
        !             8:        get() { # GET /?name
        !             9:                curl -s -w ' [%{http_code}]' http://localhost:$PORT/?$1
        !            10:                echo
        !            11:        }
        !            12: else
        !            13:        get() { # GET /?name, no curl (FreeBSD): fetch does not return the body of 503
        !            14:                response=`printf 'GET /?%s HTTP/1.0\r\n\r\n' $1 | nc -w 6 localhost $PORT | tr -d '\r'`
        !            15:                status=`printf '%s\n' "$response" | sed -n '1s/^HTTP\/[0-9.]* \([0-9]*\).*/\1/p'`
        !            16:                body=`printf '%s\n' "$response" | sed '1,/^$/d'`
        !            17:                echo "$body [${status:-000}]"
        !            18:        }
        !            19: fi
1.1       moko       20: 
                     21: run() { # httpd mode, max connections
                     22:        echo "=== $1, max-connections $2"
                     23:        rm -f site/parser3.log
1.2     ! moko       24:        cd site
        !            25:        TEST_HTTPD_MODE=$1 TEST_MAX_CONNECTIONS=$2 CGI_PARSER_CONFIG=`pwd`/config.p $PARSER -p $PORT &
1.1       moko       26:        server=$!
1.2     ! moko       27:        cd ..
1.1       moko       28:        # wait for the server listens
                     29:        for i in 1 2 3 4 5; do nc -z localhost $PORT 2>/dev/null && break; sleep 0.2; done
                     30: 
                     31:        get slow >slow1.out & slow1=$!
                     32:        sleep 0.1
                     33:        get slow >slow2.out & slow2=$!
                     34:        sleep 0.1
                     35:        echo "two connections are being served:"; get quick; get quick
                     36:        wait $slow1 $slow2
                     37:        cat slow1.out slow2.out
                     38:        echo "they have finished:"; get quick
                     39: 
                     40:        kill $server; wait $server 2>/dev/null
                     41:        grep -o "max-connections .*" site/parser3.log 2>/dev/null | sort -u
                     42: }
                     43: 
                     44: {
                     45: run parallel 0
                     46: run parallel 2
                     47: run threaded 0
                     48: run threaded 2
                     49: } >tests.log 2>&1
                     50: 
                     51: rm -f slow1.out slow2.out site/parser3.log
                     52: diff -u ok.log tests.log

E-mail: