From: Clemens Buchacher <drizzd@aon.at>
To: Mike Hommey <mh@glandium.org>
Cc: Eric Wong <normalperson@yhbt.net>,
Johannes Schindelin <Johannes.Schindelin@gmx.de>,
git@vger.kernel.org
Subject: [PATCH] http-push: add regression tests
Date: Tue, 26 Feb 2008 00:28:20 +0100 [thread overview]
Message-ID: <20080225232820.GA18254@localhost> (raw)
In-Reply-To: <20080224184832.GA24240@glandium.org>
http-push tests require a web server with WebDAV support.
This commit introduces a HTTPD test library, which can be configured using
the following environment variables.
LIB_HTTPD_PATH web server path
LIB_HTTPD_MODULE_PATH web server modules path
LIB_HTTPD_PORT listening port
LIB_HTTPD_DAV enable DAV
LIB_HTTPD_SVN enable SVN
LIB_HTTPD_SSL enable SSL
Signed-off-by: Clemens Buchacher <drizzd@aon.at>
---
On Sun, Feb 24, 2008 at 07:48:32PM +0100, Mike Hommey wrote:
> I took a quick but deeper look to your script, and I think it would be
> better to have a httpd.conf with proper <IfDefine> directives, and
> toggle the proper defines on the httpd command line.
Alright, here we go.
t/lib-httpd.sh | 88 +++++++++++++++++++++++++++++++++++++++++++++++
t/lib-httpd/apache.conf | 34 ++++++++++++++++++
t/lib-httpd/ssl.cnf | 8 ++++
t/t5540-http-push.sh | 73 +++++++++++++++++++++++++++++++++++++++
4 files changed, 203 insertions(+), 0 deletions(-)
create mode 100644 t/lib-httpd.sh
create mode 100644 t/lib-httpd/apache.conf
create mode 100644 t/lib-httpd/ssl.cnf
create mode 100644 t/t5540-http-push.sh
diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh
new file mode 100644
index 0000000..2c621c4
--- /dev/null
+++ b/t/lib-httpd.sh
@@ -0,0 +1,88 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at>
+#
+
+LIB_HTTPD_PATH=${LIB_HTTPD_PATH-'/usr/sbin/apache2'}
+LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'8111'}
+
+TEST_PATH="$PWD"/../lib-httpd
+HTTPD_ROOT_PATH="$PWD"/httpd
+HTTPD_DOCUMENT_ROOT_PATH="$PWD"/httpd/www
+
+if ! test -x "$LIB_HTTPD_PATH"
+then
+ say_color "" "skipping test, no web server found at $LIB_HTTPD_PATH"
+ test_done
+ exit
+fi
+
+HTTPD_VERSION=`$LIB_HTTPD_PATH -v | \
+ sed -n 's/^Server version: Apache\/\([0-9]*\)\..*$/\1/p; q'`
+
+if test -n "$HTTPD_VERSION"
+then
+ if test -z "$LIB_HTTPD_MODULE_PATH"
+ then
+ if ! test $HTTPD_VERSION -ge 2
+ then
+ say_color "" "skipping test, at least Apache version 2 is required"
+ test_done
+ exit
+ fi
+
+ LIB_HTTPD_MODULE_PATH='/usr/lib/apache2/modules'
+ fi
+else
+ error "Could not identify web server '$LIB_HTTPD_PATH'"
+fi
+
+HTTPD_PARA="-d $HTTPD_ROOT_PATH -f $TEST_PATH/apache.conf"
+
+prepare_httpd() {
+ mkdir $HTTPD_ROOT_PATH
+ mkdir $HTTPD_DOCUMENT_ROOT_PATH
+
+ ln -s $LIB_HTTPD_MODULE_PATH $HTTPD_ROOT_PATH/modules
+
+ if test -n "$LIB_HTTPD_SSL"
+ then
+ HTTPD_URL=https://127.0.0.1:$LIB_HTTPD_PORT
+ else
+ HTTPD_URL=http://127.0.0.1:$LIB_HTTPD_PORT
+ fi
+
+ if test "$LIB_HTTPD_SSL" != ""
+ then
+ openssl req \
+ -config $TEST_PATH/ssl.cnf \
+ -new -x509 -nodes \
+ -out $HTTPD_ROOT_PATH/httpd.pem \
+ -keyout $HTTPD_ROOT_PATH/httpd.pem
+ export GIT_SSL_NO_VERIFY=t
+ HTTPD_PARA="$HTTPD_PARA -DSSL"
+ fi
+
+ if test "$LIB_HTTPD_DAV" != "" -o "$LIB_HTTPD_SVN" != ""
+ then
+ HTTPD_PARA="$HTTPD_PARA -DDAV"
+
+ if test "$LIB_HTTPD_SVN" != ""
+ then
+ HTTPD_PARA="$HTTPD_PARA -DSVN"
+ rawsvnrepo="$HTTPD_ROOT_PATH/svnrepo"
+ svnrepo="http://127.0.0.1:$LIB_HTTPD_PORT/svn"
+ fi
+ fi
+}
+
+start_httpd() {
+ prepare_httpd
+
+ "$LIB_HTTPD_PATH" $HTTPD_PARA \
+ -c "Listen 127.0.0.1:$LIB_HTTPD_PORT" -k start
+}
+
+stop_httpd() {
+ "$LIB_HTTPD_PATH" $HTTPD_PARA -k stop
+}
diff --git a/t/lib-httpd/apache.conf b/t/lib-httpd/apache.conf
new file mode 100644
index 0000000..a447346
--- /dev/null
+++ b/t/lib-httpd/apache.conf
@@ -0,0 +1,34 @@
+PidFile httpd.pid
+DocumentRoot www
+ErrorLog error.log
+
+<IfDefine SSL>
+LoadModule ssl_module modules/mod_ssl.so
+
+SSLCertificateFile httpd.pem
+SSLCertificateKeyFile httpd.pem
+SSLRandomSeed startup file:/dev/urandom 512
+SSLRandomSeed connect file:/dev/urandom 512
+SSLSessionCache none
+SSLMutex file:ssl_mutex
+SSLEngine On
+</IfDefine>
+
+<IfDefine DAV>
+ LoadModule dav_module modules/mod_dav.so
+ LoadModule dav_fs_module modules/mod_dav_fs.so
+
+ DAVLockDB DAVLock
+ <Location />
+ Dav on
+ </Location>
+</IfDefine>
+
+<IfDefine SVN>
+ LoadModule dav_svn_module modules/mod_dav_svn.so
+
+ <Location /svn>
+ DAV svn
+ SVNPath svnrepo
+ </Location>
+</IfDefine>
diff --git a/t/lib-httpd/ssl.cnf b/t/lib-httpd/ssl.cnf
new file mode 100644
index 0000000..8d89a05
--- /dev/null
+++ b/t/lib-httpd/ssl.cnf
@@ -0,0 +1,8 @@
+RANDFILE = $ENV::HOME/.rnd
+
+[ req ]
+default_bits = 1024
+distinguished_name = req_distinguished_name
+prompt = no
+[ req_distinguished_name ]
+commonName = 127.0.0.1
diff --git a/t/t5540-http-push.sh b/t/t5540-http-push.sh
new file mode 100644
index 0000000..c12e2ad
--- /dev/null
+++ b/t/t5540-http-push.sh
@@ -0,0 +1,73 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at>
+#
+
+test_description='test http-push
+
+This test runs various sanity checks on http-push.'
+
+. ./test-lib.sh
+
+ROOT_PATH="$PWD"
+LIB_HTTPD_DAV=t
+
+. ../lib-httpd.sh
+
+if ! start_httpd >&3 2>&4
+then
+ say_color "" "skipping test, web server setup failed"
+ test_done
+ exit
+fi
+
+test_expect_success 'setup remote repository' '
+ cd "$ROOT_PATH" &&
+ mkdir test_repo &&
+ cd test_repo &&
+ git init &&
+ : >path1 &&
+ git add path1 &&
+ test_tick &&
+ git commit -m initial &&
+ cd - &&
+ git clone --bare test_repo test_repo.git &&
+ cd test_repo.git &&
+ git --bare update-server-info &&
+ chmod +x hooks/post-update &&
+ cd - &&
+ mv test_repo.git $HTTPD_DOCUMENT_ROOT_PATH
+'
+
+test_expect_success 'clone remote repository' '
+ cd "$ROOT_PATH" &&
+ git clone $HTTPD_URL/test_repo.git test_repo_clone
+'
+
+test_expect_success 'push to remote repository' '
+ cd "$ROOT_PATH"/test_repo_clone &&
+ : >path2 &&
+ git add path2 &&
+ test_tick &&
+ git commit -m path2 &&
+ git push
+'
+
+test_expect_success 'create and delete remote branch' '
+ cd "$ROOT_PATH"/test_repo_clone &&
+ git checkout -b dev &&
+ : >path3 &&
+ git add path3 &&
+ test_tick &&
+ git commit -m dev &&
+ git push origin dev &&
+ git fetch &&
+ git push origin :dev &&
+ git branch -d -r origin/dev &&
+ git fetch &&
+ ! git show-ref --verify refs/remotes/origin/dev
+'
+
+stop_httpd
+
+test_done
--
1.5.4.2.156.ge3c5
next prev parent reply other threads:[~2008-02-25 23:29 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-18 13:07 [PATCH] http-push: Fix error message for push <remote> :<branch> Clemens Buchacher
2008-02-18 13:45 ` Johannes Schindelin
2008-02-18 15:55 ` [PATCH] http-push: push <remote> :<branch> deletes remote branch Clemens Buchacher
2008-02-18 16:44 ` Clemens Buchacher
2008-02-18 17:35 ` Johannes Schindelin
2008-02-18 17:34 ` Johannes Schindelin
2008-02-19 12:58 ` Clemens Buchacher
2008-02-19 13:17 ` Johannes Schindelin
2008-02-19 13:24 ` Mike Hommey
2008-02-19 13:31 ` Johannes Schindelin
2008-02-19 21:35 ` Junio C Hamano
2008-02-19 22:25 ` Johannes Schindelin
2008-02-23 21:28 ` [PATCH] http-push: add regression tests Clemens Buchacher
2008-02-24 8:58 ` Mike Hommey
2008-02-24 18:03 ` Clemens Buchacher
2008-02-24 18:48 ` Mike Hommey
2008-02-24 19:14 ` Clemens Buchacher
2008-02-25 23:28 ` Clemens Buchacher [this message]
2008-02-26 0:24 ` Junio C Hamano
2008-02-27 8:54 ` Clemens Buchacher
2008-02-27 9:16 ` Mike Hommey
2008-02-27 9:51 ` Johannes Schindelin
2008-02-27 19:23 ` Clemens Buchacher
2008-02-27 19:27 ` [PATCH 1/2] http-push: push <remote> :<branch> deletes remote branch Clemens Buchacher
2008-02-27 19:28 ` [PATCH 2/2] http-push: add regression tests Clemens Buchacher
2008-02-27 22:24 ` [PATCH] " Johannes Schindelin
2008-02-26 19:32 ` Mike Hommey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080225232820.GA18254@localhost \
--to=drizzd@aon.at \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=mh@glandium.org \
--cc=normalperson@yhbt.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).