[CalendarServer-changes] [3527] CalDAVTester/trunk

source_changes at macosforge.org source_changes at macosforge.org
Mon Dec 15 11:17:49 PST 2008


Revision: 3527
          http://trac.macosforge.org/projects/calendarserver/changeset/3527
Author:   cdaboo at apple.com
Date:     2008-12-15 11:17:48 -0800 (Mon, 15 Dec 2008)
Log Message:
-----------
Clean out some unused options. Update Read me. Add an option to randomize the test order.

Modified Paths:
--------------
    CalDAVTester/trunk/README.txt
    CalDAVTester/trunk/scripts/tests/caldavtest.dtd
    CalDAVTester/trunk/src/caldavtest.py
    CalDAVTester/trunk/src/manager.py
    CalDAVTester/trunk/src/serverinfo.py

Modified: CalDAVTester/trunk/README.txt
===================================================================
--- CalDAVTester/trunk/README.txt	2008-12-15 17:13:33 UTC (rev 3526)
+++ CalDAVTester/trunk/README.txt	2008-12-15 19:17:48 UTC (rev 3527)
@@ -12,7 +12,8 @@
 
 COMMAND LINE OPTIONS
 
-testcaldav.py [-s filename] [-p filename] [-d] [--all] file1 file2 ...
+testcaldav.py [-s filename] [-p filename] [-d] [--all] [--random] \
+	file1 file2 ...
 
 	-s : filename specifies the file to use for server information
 	(default is 'serverinfo.xml').
@@ -28,6 +29,8 @@
 	file in that directory is examined and those corresponding to the
 	caldavtest.dtd are executed.
 
+	--random : randomize the order in which the tests are run.
+
 	file1 file2 ...: a list of test files to execute tests from.
 
 QUICKSTART
@@ -58,26 +61,26 @@
 	ELEMENT <port>
 		port to use to connect to server.
 
+	ELEMENT <authtype>
+		HTTP authentication method to use.
+
 	ELEMENT <ssl>
 		if present, use SSL to connect to the server.
 
-	ELEMENT <calendarpath>
-		base path to a calendar on the server to run tests with.
+	ELEMENT <substitutions>
+		used to encapsulate all variable substitutions.
 
-	ELEMENT <user>
-		user id to use when authenticating with the server.
+		ELEMENT <substitution>
+			a variable substitution - the repeat attribute can
+			be used to repeat the substitution a set number of
+			times whilst generating different substitutions.
 
-	ELEMENT <pswd>
-		password to use when authenticating with the server.
+			ELEMENT <key>
+				the substitution key (usually '$xxx:').
 
-	ELEMENT <hostsubs>
-		a string that can be substituted into test scripts and data
-		using '$host:' as the substitution key string.
+			ELEMENT <value>
+				the substitution value.
 
-	ELEMENT <pathsubs>
-		a string that can be substituted into test scripts and data
-		using '$pathprefix1:' as the substitution key string.
-
 caldavtest.dtd:
 
 	Defines the XML DTD for test script files:
@@ -142,13 +145,14 @@
 
 	ELEMENT <method>
 		the HTTP method for this request. There are some 'special' methods that do some useful 'compound' operations:
-			1) DELETEALL - deletes all resources within the collection specified by the <ruri> element.
-			2) ACCESS-DISABLE - removes the access-disabled xattr on the file specified by the <ruri> element.
-			3) ACCESS-ENABLE - adds the access-disabled xattr on the file specified by the <ruri> element.
-			4) DELAY - pause for the number of seconds specified by the <ruri> element.
-			5) GETNEW - get the data from the newest resource in the collection specified by the <ruri> element and put its URI
+			1) DELETEALL - deletes all resources within the collections specified by the <ruri> elements.
+			2) DELAY - pause for the number of seconds specified by the <ruri> element.
+			3) GETNEW - get the data from the newest resource in the collection specified by the <ruri> element and put its URI
 					    into the $ variable for later use in an <ruri> element.
 
+	ELEMENT <ruri>
+		the URI of the request. Multiple <ruri>'s are allowed with DELETEALL only.
+
 	ELEMENT <header>
 		can be used to specify additional headers in the request.
 		
@@ -158,13 +162,6 @@
 		ELEMENT <value>
 			the header value.
 
-	ELEMENT <ruri>
-		if the text in this element does not start with a '/', then it
-		is appended to the text from the serverinfo <calendarpath>
-		element (with '/' in between) and used as the URI for the
-		request. If the text in this element starts with '/' then it is
-		used as-is for the URI of the request.
-
 	ELEMENT <data>
 		used to specify the source and nature of data used in the
 		request body, if there is one.
@@ -274,6 +271,23 @@
 		</arg>
 	</verify>
 	
+calandarDataMatch:
+	Similar to data match but tries to "normalize" the calendar data so that e.g., different
+	ordering of properties is not significant.
+
+	Argument: 'filepath'
+		The file path to a file containing data to match the response body to.
+	
+	Example:
+	
+	<verify>
+		<callback>dataMatch</callback>
+		<arg>
+			<name>filepath</name>
+			<value>resources/put.ics</value>
+		</arg>
+	</verify>
+	
 dataString:
 	Performs a check of response body tries to find occurrences of the specified strings or the
 	absence of specified strings.
@@ -398,6 +412,27 @@
 		</arg>
 	</verify>
 	
+propfindValues:
+	Performs a regular expression match against property values. The overall
+	response status must be 207.
+
+	Argument: 'props'
+		A set of properties for which a 2xx response status is required. Two forms can be used:
+		
+		'propname$value' - will test for property value match
+		'propname!value' - will test for property value non-match
+	
+	Example:
+	
+	<verify>
+		<callback>propfindValues</callback>
+		<arg>
+			<name>props</name>
+			<value>DAV:getcontenttype$text/.*</value>
+			<value>DAV:getcontenttype!text/calendar</value>
+		</arg>
+	</verify>
+	
 acltems:
 	Performs a check of multi-status response body and checks to see
 	whether the specified privileges are granted or denied on each

Modified: CalDAVTester/trunk/scripts/tests/caldavtest.dtd
===================================================================
--- CalDAVTester/trunk/scripts/tests/caldavtest.dtd	2008-12-15 17:13:33 UTC (rev 3526)
+++ CalDAVTester/trunk/scripts/tests/caldavtest.dtd	2008-12-15 19:17:48 UTC (rev 3527)
@@ -30,10 +30,10 @@
 						 print-response (yes|no) "no">
 		
 		<!ELEMENT method (#PCDATA)>
+		<!ELEMENT ruri (#PCDATA)>
 		<!ELEMENT header (name, value)>
 			<!ELEMENT name (#PCDATA)>
 			<!ELEMENT value (#PCDATA)>
-		<!ELEMENT ruri (#PCDATA)>
 		<!ELEMENT data (content-type, filepath)>
 			<!ATTLIST data substitutions (yes|no) "no">
 			<!ELEMENT content-type (#PCDATA)>

Modified: CalDAVTester/trunk/src/caldavtest.py
===================================================================
--- CalDAVTester/trunk/src/caldavtest.py	2008-12-15 17:13:33 UTC (rev 3526)
+++ CalDAVTester/trunk/src/caldavtest.py	2008-12-15 19:17:48 UTC (rev 3527)
@@ -313,62 +313,6 @@
             self.dorequest( req, False, False )
         self.manager.log(manager.LOG_HIGH, "[DONE]")
     
-    def doaccess(self, ruri, enable):
-        """
-        We have to set the xattr WebDAV:{http:%2F%2Ftwistedmatrix.com%2Fxml_namespace%2Fdav%2Fprivate%2F}access-disabled 
-        on the resource pointed to by the ruri. Strictly speaking only the server know how to map from a uri to a file
-        path, so we have to cheat!
-        """
-        if self.manager.server_info.serverfilepath:
-            # __uids__ URI path is actually hashed on disk
-            segments = ruri[1:].split('/')
-            for ctr, segment in enumerate(segments):
-                if segment == "__uids__":
-                    uid = segments[ctr + 1]
-                    segments.insert(ctr + 1, uid[0:2])
-                    segments.insert(ctr + 2, uid[2:4])
-                    break
-            filepath = "/".join(segments)
-            filename = os.path.join(self.manager.server_info.serverfilepath, filepath)
-            if os.path.exists(filename):
-                attrs = xattr.xattr(filename)
-                if enable:
-                    del attrs["WebDAV:{http:%2F%2Ftwistedmatrix.com%2Fxml_namespace%2Fdav%2Fprivate%2F}caldav-access-disabled"]
-                else:
-                    attrs["WebDAV:{http:%2F%2Ftwistedmatrix.com%2Fxml_namespace%2Fdav%2Fprivate%2F}caldav-access-disabled"] = "yes"
-                return True
-        return False
-
-    def doquota(self, ruri, size):
-        """
-        We have to set the xattr WebDAV:{http:%2F%2Ftwistedmatrix.com%2Fxml_namespace%2Fdav%2Fprivate%2F}access-disabled 
-        on the resource pointed to by the ruri. Strictly speaking only the server know how to map from a uri to a file
-        path, so we have to cheat!
-        """
-        if self.manager.server_info.serverfilepath:
-            # __uids__ URI path is actually hashed on disk
-            segments = ruri[1:].split('/')
-            for ctr, segment in enumerate(segments):
-                if segment == "__uids__":
-                    uid = segments[ctr + 1]
-                    segments.insert(ctr + 1, uid[0:2])
-                    segments.insert(ctr + 2, uid[2:4])
-                    break
-            filepath = "/".join(segments)
-            filename = os.path.join(self.manager.server_info.serverfilepath, filepath)
-            if os.path.exists(filename):
-                attrs = xattr.xattr(filename)
-                if size is None:
-                    del attrs["WebDAV:{http:%2F%2Ftwistedmatrix.com%2Fxml_namespace%2Fdav%2Fprivate%2F}quota-root"]
-                else:
-                    attrs["WebDAV:{http:%2F%2Ftwistedmatrix.com%2Fxml_namespace%2Fdav%2Fprivate%2F}quota-root"] = \
-                            "<?xml version='1.0' encoding='UTF-8'?>\n" + \
-                            "<quota-root xmlns='http://twistedmatrix.com/xml_namespace/dav/private/'>" + \
-                            str(size) + \
-                            "</quota-root>"
-                return True
-        return False
-
     def dorequest( self, req, details=False, doverify = True, forceverify = False, stats = None ):
         
         # Special check for DELETEALL
@@ -379,30 +323,6 @@
                 self.dodeleteall(hrefs)
             return True, "", None, None
         
-        # Special check for ACCESS-DISABLE
-        elif req.method == "ACCESS-DISABLE":
-            if self.doaccess(req.ruri, False):
-                return True, "", None, None
-            else:
-                return False, "Could not set caldav-access-disabled xattr on file", None, None
-        elif req.method == "ACCESS-ENABLE":
-            if self.doaccess(req.ruri, True):
-                return True, "", None, None
-            else:
-                return False, "Could not remove caldav-access-disabled xattr on file", None, None
-
-        # Special check for QUOTA
-        elif req.method == "QUOTA-DISABLE":
-            if self.doquota(req.ruri, None):
-                return True, "", None, None
-            else:
-                return False, "Could remove quota-root xattr on file", None, None
-        elif req.method.startswith("QUOTA-ENABLE-"):
-            if self.doquota(req.ruri, req.method[len("QUOTA-ENABLE-"):]):
-                return True, "", None, None
-            else:
-                return False, "Could not set quota-root xattr on file", None, None
-
         # Special for delay
         elif req.method == "DELAY":
             # self.ruri contains a numeric delay in seconds

Modified: CalDAVTester/trunk/src/manager.py
===================================================================
--- CalDAVTester/trunk/src/manager.py	2008-12-15 17:13:33 UTC (rev 3526)
+++ CalDAVTester/trunk/src/manager.py	2008-12-15 19:17:48 UTC (rev 3527)
@@ -23,6 +23,7 @@
 import getopt
 import httplib
 import os
+import random
 import src.xmlDefs
 import sys
 import time
@@ -139,10 +140,10 @@
         pname = None
         dname = "scripts/tests"
         fnames = []
-        docroot = None
         all = False
         pidfile = "../CalendarServer/logs/caldavd.pid"
-        options, args = getopt.getopt(sys.argv[1:], "s:p:dmx:r:", ["all", "pid=",])
+        random_order = False
+        options, args = getopt.getopt(sys.argv[1:], "s:p:dmx:", ["all", "pid=", "random"])
         
         # Process single options
         for option, value in options:
@@ -154,14 +155,14 @@
                 self.depopulate = True
             elif option == "-x":
                 dname = value
-            elif option == "-r":
-                docroot = value
             elif option == "--all":
                 all = True
             elif option == "-m":
                 self.memUsage = True
             elif option == "--pid":
                 pidfile = value
+            elif option == "--random":
+                random_order = True
                 
         if all:
             files = os.listdir(dname)
@@ -176,9 +177,16 @@
         for f in args:
             fnames.append(dname + "/" + f)
         
+        # Randomize file list
+        if random_order:
+            new_fnames = []
+            while fnames:
+                element = random.choice(fnames)
+                new_fnames.append(element)
+                fnames.remove(element)
+            fnames = new_fnames
+
         self.readXML(sname, pname, fnames, all)
-        if docroot:
-            self.server_info.serverfilepath = docroot
             
         if self.memUsage:
             fd = open(pidfile, "r")

Modified: CalDAVTester/trunk/src/serverinfo.py
===================================================================
--- CalDAVTester/trunk/src/serverinfo.py	2008-12-15 17:13:33 UTC (rev 3526)
+++ CalDAVTester/trunk/src/serverinfo.py	2008-12-15 19:17:48 UTC (rev 3527)
@@ -24,7 +24,7 @@
     """
     Maintains information about the server being targetted.
     """
-    __slots__  = ['host', 'port', 'authtype', 'ssl', 'calendarpath', 'user', 'pswd', 'serverfilepath', 'subsdict', 'extrasubsdict',]
+    __slots__  = ['host', 'port', 'authtype', 'ssl', 'calendarpath', 'user', 'pswd', 'subsdict', 'extrasubsdict',]
 
 
     def __init__( self ):
@@ -34,7 +34,6 @@
         self.ssl = False
         self.user = ""
         self.pswd = ""
-        self.serverfilepath = ""
         self.subsdict = {}
         self.extrasubsdict = {}
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20081215/edd2382e/attachment-0001.html>


More information about the calendarserver-changes mailing list