From 99719ddbfc2aa21d4e825b72da8e407325b4404f Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Thu, 26 Oct 2006 00:29:47 +1300 Subject: [PATCH] Real regression testing, using parts of the framework developed earlier. --- rscds.webprj | 40 +++-- testing/README.regression_tests | 24 +++ testing/dav_test | 2 +- testing/normalise_result | 16 ++ testing/run_regressions.sh | 36 +++++ testing/tests/mulberry/PROPFIND-initial.test | 6 +- testing/tests/regression-suite/.gitignore | 2 + .../regression-suite/001-Mulberry-1.result | 8 + .../regression-suite/001-Mulberry-1.test | 5 + .../regression-suite/002-Mulberry-1.data | 8 + .../regression-suite/002-Mulberry-1.result | 153 ++++++++++++++++++ .../regression-suite/002-Mulberry-1.test | 8 + .../regression-suite/003-Mulberry-1.data | 8 + .../regression-suite/003-Mulberry-1.result | 23 +++ .../regression-suite/003-Mulberry-1.test | 8 + .../regression-suite/004-Mulberry-1.result | 6 + .../regression-suite/004-Mulberry-1.test | 6 + .../regression-suite/005-Mulberry-1.result | 37 +++++ .../regression-suite/005-Mulberry-1.test | 10 ++ .../regression-suite/006-Mulberry-1.data | 9 ++ .../regression-suite/006-Mulberry-1.result | 25 +++ .../regression-suite/006-Mulberry-1.test | 7 + .../regression-suite/007-Mulberry-1.result | 6 + .../regression-suite/007-Mulberry-1.test | 6 + .../010-Mulberry-PUT-1.result | 7 + .../regression-suite/010-Mulberry-PUT-1.test | 7 + .../011-Mulberry-PUT-1b.result | 7 + .../regression-suite/011-Mulberry-PUT-1b.test | 7 + ...56B49B10FC923D20FE2DC92D6580340-0.ics.data | 32 ++++ 29 files changed, 502 insertions(+), 17 deletions(-) create mode 100644 testing/README.regression_tests create mode 100755 testing/normalise_result create mode 100755 testing/run_regressions.sh create mode 100644 testing/tests/regression-suite/.gitignore create mode 100644 testing/tests/regression-suite/001-Mulberry-1.result create mode 100644 testing/tests/regression-suite/001-Mulberry-1.test create mode 100644 testing/tests/regression-suite/002-Mulberry-1.data create mode 100644 testing/tests/regression-suite/002-Mulberry-1.result create mode 100644 testing/tests/regression-suite/002-Mulberry-1.test create mode 100644 testing/tests/regression-suite/003-Mulberry-1.data create mode 100644 testing/tests/regression-suite/003-Mulberry-1.result create mode 100644 testing/tests/regression-suite/003-Mulberry-1.test create mode 100644 testing/tests/regression-suite/004-Mulberry-1.result create mode 100644 testing/tests/regression-suite/004-Mulberry-1.test create mode 100644 testing/tests/regression-suite/005-Mulberry-1.result create mode 100644 testing/tests/regression-suite/005-Mulberry-1.test create mode 100644 testing/tests/regression-suite/006-Mulberry-1.data create mode 100644 testing/tests/regression-suite/006-Mulberry-1.result create mode 100644 testing/tests/regression-suite/006-Mulberry-1.test create mode 100644 testing/tests/regression-suite/007-Mulberry-1.result create mode 100644 testing/tests/regression-suite/007-Mulberry-1.test create mode 100644 testing/tests/regression-suite/010-Mulberry-PUT-1.result create mode 100644 testing/tests/regression-suite/010-Mulberry-PUT-1.test create mode 100644 testing/tests/regression-suite/011-Mulberry-PUT-1b.result create mode 100644 testing/tests/regression-suite/011-Mulberry-PUT-1b.test create mode 100644 testing/tests/regression-suite/F56B49B10FC923D20FE2DC92D6580340-0.ics.data diff --git a/rscds.webprj b/rscds.webprj index 8e4c6f0d..dddbd216 100644 --- a/rscds.webprj +++ b/rscds.webprj @@ -89,19 +89,31 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/testing/README.regression_tests b/testing/README.regression_tests new file mode 100644 index 00000000..1eb8752b --- /dev/null +++ b/testing/README.regression_tests @@ -0,0 +1,24 @@ +Regression Testing +================== + +At present these regression tests are basically written to work in my +own environment. While I am, of course, happy to see patches that make +them more generic they are still very much a work in progress. + +At present the most demanding client to support is Mulberry, so the first +regression tests imitate Mulberry taking RSCDS through it's paces: + + - Initial OPTIONS request at the root + - Initial PROPFIND request at the root with Depth 1 + - Second PROPFIND request at the second level + - MKCALENDAR request to create a calendar at /user1/home/ + - Third PROPFIND request duplicating the Second one (but finding a calendar now). + - Fourth PROPFIND request solely looking for the new calendar, requesting 'getetag' + - Not that Mulberry would let us do this, but we try to MKCALENDAR again at /user1/home/ to check for the error we expect. + - PUT our first event into the calendar. + - PUT the same event a second time, which should not give an error, but should respond with 'Replaced' rather than 'Created'. + +=====>>>> We are up to here... + + - PUT the same event a third time, but with an If-None-Match header, which /should/ give a 412 Precondition Failed error. + diff --git a/testing/dav_test b/testing/dav_test index c22acbd1..8e08ba85 100755 --- a/testing/dav_test +++ b/testing/dav_test @@ -8,7 +8,7 @@ my $test=$ARGV[1]; usage() unless ( defined($suite) && defined($test) ); -my @arguments = ( "--basic", "--user", "andrew:x", "--proxy", "", "--silent" ); +my @arguments = ( "--basic", "--user", "user1:user1", "--proxy", "", "--silent" ); push @arguments, "--verbose" if ( defined($ARGV[2]) ); my $url; diff --git a/testing/normalise_result b/testing/normalise_result new file mode 100755 index 00000000..4033fb08 --- /dev/null +++ b/testing/normalise_result @@ -0,0 +1,16 @@ +#!/usr/bin/perl -w +# +# Given a result on stdin, try and normalise some +# elements of it (such as HTTP Header dates) so that we can +# simply compare it with other results +# + +use strict; + +while( ) { + /^Date: [SMTWF][a-z]{2}, [0-9]{1,2} [JFMAJSOND][a-z]+ 20[0-9]{2} [012][0-9]:[0-5][0-9]:[0-5][0-9] GMT\r$/ && do { + $_ = "Date: Dow, 01 Jan 2000 00:00:00 GMT\r\n"; + }; + + print; +} diff --git a/testing/run_regressions.sh b/testing/run_regressions.sh new file mode 100755 index 00000000..b4a40633 --- /dev/null +++ b/testing/run_regressions.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# +# Run the regression tests and display differences +# + +# Restart PGPool to ensure we can drop and recreate the database +# FIXME: We should really drop everything *from* the database and create it +# from that, so we don't need to do this. +sudo /etc/init.d/pgpool restart +dropdb caldav +../dba/create-database.sh caldav + +for T in tests/regression-suite/*.test ; do + TEST="`basename ${T} .test`" + ./dav_test regression-suite "${TEST}" | ./normalise_result > "tests/regression-suite/results/${TEST}" + if [ ! -f "tests/regression-suite/${TEST}.result" ] ; then + touch "tests/regression-suite/${TEST}.result" + fi + diff -u "tests/regression-suite/${TEST}.result" "tests/regression-suite/results/${TEST}" >"tests/regression-suite/diffs/${TEST}" +done + +for T in tests/regression-suite/*.test ; do + TEST="`basename ${T} .test`" + if [ -s "tests/regression-suite/diffs/${TEST}" -o ! -f "tests/regression-suite/${TEST}.result" ] ; then + echo "=======================================" + echo "Displaying diff for test ${TEST}" + echo "=======================================" + cat "tests/regression-suite/diffs/${TEST}" + read -p "Accept this as new standard result [y/N]? " ACCEPT + if [ "${ACCEPT}" = "y" ] ; then + cp "tests/regression-suite/results/${TEST}" "tests/regression-suite/${TEST}.result" + fi + else + echo "Test ${TEST} passed OK!" + fi +done diff --git a/testing/tests/mulberry/PROPFIND-initial.test b/testing/tests/mulberry/PROPFIND-initial.test index 0d4e05bc..89d22748 100644 --- a/testing/tests/mulberry/PROPFIND-initial.test +++ b/testing/tests/mulberry/PROPFIND-initial.test @@ -2,6 +2,8 @@ # After creating a calendar in Mulberry, we should be able # to do a PROPFIND and discover it. TYPE=PROPFIND -URL=http://mycaldav/caldav.php/andrew/ +URL=http://mycaldav/caldav.php/ HEADER=Depth: 1 -HEADER=Content-Type: text/xml; charset=utf-8 \ No newline at end of file +HEADER=Content-Type: text/xml; charset=utf-8 +HEAD +VERBOSE \ No newline at end of file diff --git a/testing/tests/regression-suite/.gitignore b/testing/tests/regression-suite/.gitignore new file mode 100644 index 00000000..0017d1c0 --- /dev/null +++ b/testing/tests/regression-suite/.gitignore @@ -0,0 +1,2 @@ +diffs +results diff --git a/testing/tests/regression-suite/001-Mulberry-1.result b/testing/tests/regression-suite/001-Mulberry-1.result new file mode 100644 index 00000000..71204932 --- /dev/null +++ b/testing/tests/regression-suite/001-Mulberry-1.result @@ -0,0 +1,8 @@ +HTTP/1.1 200 OK +Date: Dow, 01 Jan 2000 00:00:00 GMT +Server: Apache/2.2.3 (Debian) DAV/2 +Content-length: 0 +Allow: OPTIONS, GET, PUT, DELETE, PROPFIND, REPORT, MKCALENDAR, MKCOL +DAV: 1, 2, access-control, calendar-access +Content-Type: text/plain; charset=UTF-8 + diff --git a/testing/tests/regression-suite/001-Mulberry-1.test b/testing/tests/regression-suite/001-Mulberry-1.test new file mode 100644 index 00000000..2bdbd73f --- /dev/null +++ b/testing/tests/regression-suite/001-Mulberry-1.test @@ -0,0 +1,5 @@ +# +# Do an initial OPTIONS request +TYPE=OPTIONS +URL=http://mycaldav/caldav.php/ +HEAD diff --git a/testing/tests/regression-suite/002-Mulberry-1.data b/testing/tests/regression-suite/002-Mulberry-1.data new file mode 100644 index 00000000..032be966 --- /dev/null +++ b/testing/tests/regression-suite/002-Mulberry-1.data @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/testing/tests/regression-suite/002-Mulberry-1.result b/testing/tests/regression-suite/002-Mulberry-1.result new file mode 100644 index 00000000..ef9f2051 --- /dev/null +++ b/testing/tests/regression-suite/002-Mulberry-1.result @@ -0,0 +1,153 @@ +HTTP/1.1 207 Multi-Status +Date: Dow, 01 Jan 2000 00:00:00 GMT +Server: Apache/2.2.3 (Debian) DAV/2 +ETag: "1e91289a2ef6640fadb7d5c9e6c5ebbb" +Content-Length: 3214 +Content-Type: text/xml;charset=UTF-8 + + + + + /caldav.php/ + + + + httpd/unix-directory + + + + + HTTP/1.1 200 OK + + + + /caldav.php/admin/ + + + + httpd/unix-directory + + + + + HTTP/1.1 200 OK + + + + /caldav.php/andrew/ + + + + httpd/unix-directory + + + + + HTTP/1.1 200 OK + + + + /caldav.php/user1/ + + + + httpd/unix-directory + + + + + HTTP/1.1 200 OK + + + + /caldav.php/user2/ + + + + httpd/unix-directory + + + + + HTTP/1.1 200 OK + + + + /caldav.php/manager1/ + + + + httpd/unix-directory + + + + + HTTP/1.1 200 OK + + + + /caldav.php/assistant1/ + + + + httpd/unix-directory + + + + + HTTP/1.1 200 OK + + + + /caldav.php/resource1/ + + + + httpd/unix-directory + + + + + HTTP/1.1 200 OK + + + + /caldav.php/resource2/ + + + + httpd/unix-directory + + + + + HTTP/1.1 200 OK + + + + /caldav.php/resmgr1/ + + + + httpd/unix-directory + + + + + HTTP/1.1 200 OK + + + + /caldav.php/teamclient1/ + + + + httpd/unix-directory + + + + + HTTP/1.1 200 OK + + + diff --git a/testing/tests/regression-suite/002-Mulberry-1.test b/testing/tests/regression-suite/002-Mulberry-1.test new file mode 100644 index 00000000..21443208 --- /dev/null +++ b/testing/tests/regression-suite/002-Mulberry-1.test @@ -0,0 +1,8 @@ +# +# After creating a calendar in Mulberry, we should be able +# to do a PROPFIND and discover it. +TYPE=PROPFIND +URL=http://mycaldav/caldav.php/ +HEADER=Depth: 1 +HEADER=Content-Type: text/xml; charset=utf-8 +HEAD diff --git a/testing/tests/regression-suite/003-Mulberry-1.data b/testing/tests/regression-suite/003-Mulberry-1.data new file mode 100644 index 00000000..032be966 --- /dev/null +++ b/testing/tests/regression-suite/003-Mulberry-1.data @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/testing/tests/regression-suite/003-Mulberry-1.result b/testing/tests/regression-suite/003-Mulberry-1.result new file mode 100644 index 00000000..43cf1b4a --- /dev/null +++ b/testing/tests/regression-suite/003-Mulberry-1.result @@ -0,0 +1,23 @@ +HTTP/1.1 207 Multi-Status +Date: Dow, 01 Jan 2000 00:00:00 GMT +Server: Apache/2.2.3 (Debian) DAV/2 +ETag: "137b55c4b6461331a0d3e7b89d5b71b0" +Content-Length: 365 +Content-Type: text/xml;charset=UTF-8 + + + + + /caldav.php/user1/ + + + + httpd/unix-directory + + + + + HTTP/1.1 200 OK + + + diff --git a/testing/tests/regression-suite/003-Mulberry-1.test b/testing/tests/regression-suite/003-Mulberry-1.test new file mode 100644 index 00000000..67ae486d --- /dev/null +++ b/testing/tests/regression-suite/003-Mulberry-1.test @@ -0,0 +1,8 @@ +# +# Before creating a calendar in Mulberry, we should be able +# to do a PROPFIND and it should not be there. +TYPE=PROPFIND +URL=http://mycaldav/caldav.php/user1/ +HEADER=Depth: 1 +HEADER=Content-Type: text/xml; charset=utf-8 +HEAD diff --git a/testing/tests/regression-suite/004-Mulberry-1.result b/testing/tests/regression-suite/004-Mulberry-1.result new file mode 100644 index 00000000..ae68b5a6 --- /dev/null +++ b/testing/tests/regression-suite/004-Mulberry-1.result @@ -0,0 +1,6 @@ +HTTP/1.1 200 Created +Date: Dow, 01 Jan 2000 00:00:00 GMT +Server: Apache/2.2.3 (Debian) DAV/2 +Content-Length: 0 +Content-Type: text/html; charset=UTF-8 + diff --git a/testing/tests/regression-suite/004-Mulberry-1.test b/testing/tests/regression-suite/004-Mulberry-1.test new file mode 100644 index 00000000..9f454079 --- /dev/null +++ b/testing/tests/regression-suite/004-Mulberry-1.test @@ -0,0 +1,6 @@ +# +# So we should now make a calendar that we will use for some +# testing. +TYPE=MKCALENDAR +URL=http://mycaldav/caldav.php/user1/home/ +HEAD diff --git a/testing/tests/regression-suite/005-Mulberry-1.result b/testing/tests/regression-suite/005-Mulberry-1.result new file mode 100644 index 00000000..6845e6cf --- /dev/null +++ b/testing/tests/regression-suite/005-Mulberry-1.result @@ -0,0 +1,37 @@ +HTTP/1.1 207 Multi-Status +Date: Dow, 01 Jan 2000 00:00:00 GMT +Server: Apache/2.2.3 (Debian) DAV/2 +ETag: "e898d6c4a9951794a9f7147f432570d0" +Content-Length: 708 +Content-Type: text/xml;charset=UTF-8 + + + + + /caldav.php/user1/ + + + + httpd/unix-directory + + + + + HTTP/1.1 200 OK + + + + /caldav.php/user1/home/ + + + + httpd/unix-directory + + + + + + HTTP/1.1 200 OK + + + diff --git a/testing/tests/regression-suite/005-Mulberry-1.test b/testing/tests/regression-suite/005-Mulberry-1.test new file mode 100644 index 00000000..3e223750 --- /dev/null +++ b/testing/tests/regression-suite/005-Mulberry-1.test @@ -0,0 +1,10 @@ +# +# Before creating a calendar in Mulberry, we should be able +# to do a PROPFIND and it should not be there. +TYPE=PROPFIND +URL=http://mycaldav/caldav.php/user1/ +HEADER=Depth: 1 +HEADER=Content-Type: text/xml; charset=utf-8 +HEAD +# We re-use the data from the PROPFIND request before we made the calendar +DATA=003-Mulberry-1 \ No newline at end of file diff --git a/testing/tests/regression-suite/006-Mulberry-1.data b/testing/tests/regression-suite/006-Mulberry-1.data new file mode 100644 index 00000000..20f99279 --- /dev/null +++ b/testing/tests/regression-suite/006-Mulberry-1.data @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/testing/tests/regression-suite/006-Mulberry-1.result b/testing/tests/regression-suite/006-Mulberry-1.result new file mode 100644 index 00000000..1ce73a70 --- /dev/null +++ b/testing/tests/regression-suite/006-Mulberry-1.result @@ -0,0 +1,25 @@ +HTTP/1.1 207 Multi-Status +Date: Dow, 01 Jan 2000 00:00:00 GMT +Server: Apache/2.2.3 (Debian) DAV/2 +ETag: "37e795bc0198358d27e006b91dc75aa7" +Content-Length: 483 +Content-Type: text/xml;charset=UTF-8 + + + + + /caldav.php/user1/home/ + + + + httpd/unix-directory + + + + + "faf25336de0e470a54075c14cbcf5272" + + HTTP/1.1 200 OK + + + diff --git a/testing/tests/regression-suite/006-Mulberry-1.test b/testing/tests/regression-suite/006-Mulberry-1.test new file mode 100644 index 00000000..17a27a46 --- /dev/null +++ b/testing/tests/regression-suite/006-Mulberry-1.test @@ -0,0 +1,7 @@ +# +# After creating the calendar we should be able to get any URLs +TYPE=PROPFIND +URL=http://mycaldav/caldav.php/user1/home/ +HEADER=Depth: 1 +HEADER=Content-Type: text/xml; charset=utf-8 +HEAD \ No newline at end of file diff --git a/testing/tests/regression-suite/007-Mulberry-1.result b/testing/tests/regression-suite/007-Mulberry-1.result new file mode 100644 index 00000000..785011e2 --- /dev/null +++ b/testing/tests/regression-suite/007-Mulberry-1.result @@ -0,0 +1,6 @@ +HTTP/1.1 412 Calendar Already Exists +Date: Dow, 01 Jan 2000 00:00:00 GMT +Server: Apache/2.2.3 (Debian) DAV/2 +Content-Length: 0 +Content-Type: text/html; charset=UTF-8 + diff --git a/testing/tests/regression-suite/007-Mulberry-1.test b/testing/tests/regression-suite/007-Mulberry-1.test new file mode 100644 index 00000000..9f454079 --- /dev/null +++ b/testing/tests/regression-suite/007-Mulberry-1.test @@ -0,0 +1,6 @@ +# +# So we should now make a calendar that we will use for some +# testing. +TYPE=MKCALENDAR +URL=http://mycaldav/caldav.php/user1/home/ +HEAD diff --git a/testing/tests/regression-suite/010-Mulberry-PUT-1.result b/testing/tests/regression-suite/010-Mulberry-PUT-1.result new file mode 100644 index 00000000..c96412a3 --- /dev/null +++ b/testing/tests/regression-suite/010-Mulberry-PUT-1.result @@ -0,0 +1,7 @@ +HTTP/1.1 201 Created +Date: Dow, 01 Jan 2000 00:00:00 GMT +Server: Apache/2.2.3 (Debian) DAV/2 +ETag: "b000d7defa19ccb7cd21e546b54155ee" +Content-length: 0 +Content-Type: text/html; charset=UTF-8 + diff --git a/testing/tests/regression-suite/010-Mulberry-PUT-1.test b/testing/tests/regression-suite/010-Mulberry-PUT-1.test new file mode 100644 index 00000000..4efeecde --- /dev/null +++ b/testing/tests/regression-suite/010-Mulberry-PUT-1.test @@ -0,0 +1,7 @@ +# +# We now have a calendar so we can PUT an event into it... +TYPE=PUT +URL=http://mycaldav/caldav.php/user1/home/F56B49B10FC923D20FE2DC92D6580340-0.ics +HEADER=Content-Type: text/calendar; charset=utf-8 +HEAD +DATA=F56B49B10FC923D20FE2DC92D6580340-0.ics \ No newline at end of file diff --git a/testing/tests/regression-suite/011-Mulberry-PUT-1b.result b/testing/tests/regression-suite/011-Mulberry-PUT-1b.result new file mode 100644 index 00000000..c30c2782 --- /dev/null +++ b/testing/tests/regression-suite/011-Mulberry-PUT-1b.result @@ -0,0 +1,7 @@ +HTTP/1.1 201 Replaced +Date: Dow, 01 Jan 2000 00:00:00 GMT +Server: Apache/2.2.3 (Debian) DAV/2 +ETag: "b000d7defa19ccb7cd21e546b54155ee" +Content-length: 0 +Content-Type: text/html; charset=UTF-8 + diff --git a/testing/tests/regression-suite/011-Mulberry-PUT-1b.test b/testing/tests/regression-suite/011-Mulberry-PUT-1b.test new file mode 100644 index 00000000..4efeecde --- /dev/null +++ b/testing/tests/regression-suite/011-Mulberry-PUT-1b.test @@ -0,0 +1,7 @@ +# +# We now have a calendar so we can PUT an event into it... +TYPE=PUT +URL=http://mycaldav/caldav.php/user1/home/F56B49B10FC923D20FE2DC92D6580340-0.ics +HEADER=Content-Type: text/calendar; charset=utf-8 +HEAD +DATA=F56B49B10FC923D20FE2DC92D6580340-0.ics \ No newline at end of file diff --git a/testing/tests/regression-suite/F56B49B10FC923D20FE2DC92D6580340-0.ics.data b/testing/tests/regression-suite/F56B49B10FC923D20FE2DC92D6580340-0.ics.data new file mode 100644 index 00000000..9a458727 --- /dev/null +++ b/testing/tests/regression-suite/F56B49B10FC923D20FE2DC92D6580340-0.ics.data @@ -0,0 +1,32 @@ +BEGIN:VCALENDAR +CALSCALE:GREGORIAN +PRODID:-//mulberrymail.com//Mulberry v4.0//EN +VERSION:2.0 +X-WR-CALNAME:home +BEGIN:VTIMEZONE +LAST-MODIFIED:20040110T032845Z +TZID:New Zealand Standard Time +X-LIC-LOCATION:Pacific/Auckland +BEGIN:DAYLIGHT +DTSTART:20000404T020000 +RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4 +TZNAME:NZDT +TZOFFSETFROM:+1200 +TZOFFSETTO:+1300 +END:DAYLIGHT +BEGIN:STANDARD +DTSTART:20001026T020000 +RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=10 +TZNAME:NZST +TZOFFSETFROM:+1300 +TZOFFSETTO:+1200 +END:STANDARD +END:VTIMEZONE +BEGIN:VEVENT +DTSTAMP:20061025T101327Z +DTSTART;TZID=New Zealand Standard Time:20061025T091500 +DURATION:PT1H +SUMMARY:A first event +UID:B18CBB57295D01D7661A6DD4@D76FAF7B10D9E8D2D41F779C +END:VEVENT +END:VCALENDAR