From 05526071cb5ce2f040514b7f50a4e32b16802ffd Mon Sep 17 00:00:00 2001 From: Mark Rada Date: Thu, 27 Aug 2009 22:07:07 -0400 Subject: gitweb: split test suite into library and tests To accommodate additions to the test cases for gitweb, the preamble from t9500 is now in its own library so that new sets of tests for gitweb can use the same setup without copying the code. Signed-off-by: Mark Rada Signed-off-by: Junio C Hamano --- t/gitweb-lib.sh | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 t/gitweb-lib.sh (limited to 't/gitweb-lib.sh') diff --git a/t/gitweb-lib.sh b/t/gitweb-lib.sh new file mode 100644 index 0000000000..845253274b --- /dev/null +++ b/t/gitweb-lib.sh @@ -0,0 +1,73 @@ +#!/bin/sh +# +# Copyright (c) 2007 Jakub Narebski +# + +gitweb_init () { + safe_pwd="$(perl -MPOSIX=getcwd -e 'print quotemeta(getcwd)')" + cat >gitweb_config.perl <.git/description <gitweb.output 2>gitweb.log && + if grep '^[[]' gitweb.log >/dev/null 2>&1; then false; else true; fi + + # gitweb.log is left for debugging + # gitweb.output is used to parse http output +} + +. ./test-lib.sh + +if ! test_have_prereq PERL; then + say 'skipping gitweb tests, perl not available' + test_done +fi + +perl -MEncode -e 'decode_utf8("", Encode::FB_CROAK)' >/dev/null 2>&1 || { + say 'skipping gitweb tests, perl version is too old' + test_done +} + +gitweb_init -- cgit v1.2.1 From 46e09f310567b680c03151e048bf2b7e847611e2 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Thu, 29 Oct 2009 23:07:41 +0100 Subject: t/gitweb-lib.sh: Split gitweb output into headers and body Save HTTP headers into gitweb.headers, and the body of message into gitweb.body in gitweb_run() Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- t/gitweb-lib.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 't/gitweb-lib.sh') diff --git a/t/gitweb-lib.sh b/t/gitweb-lib.sh index 845253274b..32b841dd2e 100644 --- a/t/gitweb-lib.sh +++ b/t/gitweb-lib.sh @@ -52,10 +52,14 @@ gitweb_run () { rm -f gitweb.log && perl -- "$SCRIPT_NAME" \ >gitweb.output 2>gitweb.log && + sed -e '/^\r$/q' gitweb.headers && + sed -e '1,/^\r$/d' gitweb.body && if grep '^[[]' gitweb.log >/dev/null 2>&1; then false; else true; fi # gitweb.log is left for debugging - # gitweb.output is used to parse http output + # gitweb.output is used to parse HTTP output + # gitweb.headers contains only HTTP headers + # gitweb.body contains body of message, without headers } . ./test-lib.sh -- cgit v1.2.1 From f74a83fcf04c50e8358c8fb493539af13f9b9aa5 Mon Sep 17 00:00:00 2001 From: Brian Gernhardt Date: Mon, 23 Nov 2009 12:33:42 -0500 Subject: t/gitweb-lib: Split HTTP response with non-GNU sed Recognizing \r in a regex is something GNU sed will do, but other sed implementation's won't (e.g. BSD sed on OS X). Instead of two sed invocations, use a single Perl script to split output into headers and body. Signed-off-by: Brian Gernhardt Signed-off-by: Junio C Hamano --- t/gitweb-lib.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 't/gitweb-lib.sh') diff --git a/t/gitweb-lib.sh b/t/gitweb-lib.sh index 32b841dd2e..76d8b7b803 100644 --- a/t/gitweb-lib.sh +++ b/t/gitweb-lib.sh @@ -52,8 +52,18 @@ gitweb_run () { rm -f gitweb.log && perl -- "$SCRIPT_NAME" \ >gitweb.output 2>gitweb.log && - sed -e '/^\r$/q' gitweb.headers && - sed -e '1,/^\r$/d' gitweb.body && + perl -w -e ' + open O, ">gitweb.headers"; + while (<>) { + print O; + last if (/^\r$/ || /^$/); + } + open O, ">gitweb.body"; + while (<>) { + print O; + } + close O; + ' gitweb.output && if grep '^[[]' gitweb.log >/dev/null 2>&1; then false; else true; fi # gitweb.log is left for debugging -- cgit v1.2.1 From b62a1a98bc65f52d972a3f403c5b29d6a84642fd Mon Sep 17 00:00:00 2001 From: John 'Warthog9' Hawley Date: Sat, 30 Jan 2010 23:30:39 +0100 Subject: gitweb: Load checking This changes slightly the behavior of gitweb, so that it verifies that the box isn't inundated with before attempting to serve gitweb. If the box is overloaded, it basically returns a 503 Server Unavailable until the load falls below the defined threshold. This helps dramatically if you have a box that's I/O bound, reaches a certain load and you don't want gitweb, the I/O hog that it is, increasing the pain the server is already undergoing. This behavior is controlled by $maxload configuration variable. Default is a load of 300, which for most cases should never be hit. Unset it (set it to undefined value, i.e. undef) to turn off checking. Currently it requires that '/proc/loadavg' file exists, otherwise the load check is bypassed (load is taken to be 0). So platforms that do not implement '/proc/loadavg' currently cannot use this feature (provisions are included for additional checks to be added by others). There is simple test in t/t9501-gitweb-standalone-http-status.sh to check that it correctly returns "503 Service Unavailable" if load is too high, and also if there are any Perl warnings or errors. Signed-off-by: John 'Warthog9' Hawley Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- t/gitweb-lib.sh | 1 + 1 file changed, 1 insertion(+) (limited to 't/gitweb-lib.sh') diff --git a/t/gitweb-lib.sh b/t/gitweb-lib.sh index 76d8b7b803..5a734b1b7b 100644 --- a/t/gitweb-lib.sh +++ b/t/gitweb-lib.sh @@ -25,6 +25,7 @@ our \$favicon = 'file:///$TEST_DIRECTORY/../gitweb/git-favicon.png'; our \$projects_list = ''; our \$export_ok = ''; our \$strict_export = ''; +our \$maxload = undef; EOF -- cgit v1.2.1