[CalendarServer-changes] [970] CalDAVTester/trunk

source_changes at macosforge.org source_changes at macosforge.org
Mon Jan 8 12:30:54 PST 2007


Revision: 970
          http://trac.macosforge.org/projects/calendarserver/changeset/970
Author:   cdaboo at apple.com
Date:     2007-01-08 12:30:53 -0800 (Mon, 08 Jan 2007)

Log Message:
-----------
Basic server monitoring capability.

Modified Paths:
--------------
    CalDAVTester/trunk/src/xmlDefs.py

Added Paths:
-----------
    CalDAVTester/trunk/Resource/monitor/
    CalDAVTester/trunk/monitor/
    CalDAVTester/trunk/monitor/get/
    CalDAVTester/trunk/monitor/get/get-end.xml
    CalDAVTester/trunk/monitor/get/get-small.xml
    CalDAVTester/trunk/monitor/get/get-start.xml
    CalDAVTester/trunk/monitor.py
    CalDAVTester/trunk/scripts/monitoring/
    CalDAVTester/trunk/scripts/monitoring/get.xml
    CalDAVTester/trunk/scripts/monitoring/monitorinfo.dtd
    CalDAVTester/trunk/scripts/monitoring/monitorinfo.xml
    CalDAVTester/trunk/scripts/server/serverinfo-monitor.xml
    CalDAVTester/trunk/src/monitorinfo.py

Added: CalDAVTester/trunk/monitor/get/get-end.xml
===================================================================
--- CalDAVTester/trunk/monitor/get/get-end.xml	                        (rev 0)
+++ CalDAVTester/trunk/monitor/get/get-end.xml	2007-01-08 20:30:53 UTC (rev 970)
@@ -0,0 +1,37 @@
+<?xml version="1.0"?>
+
+<!DOCTYPE caldavtest SYSTEM "caldavtest.dtd">
+
+<!--
+ Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ DRI: Cyrus Daboo, cdaboo at apple.com
+ -->
+
+<caldavtest ignore-all='yes'>
+	<description>Performance check GET</description>
+
+	<start>
+		<request>
+			<method>DELETE</method>
+			<ruri>1.ics</ruri>
+		</request>
+	</start>
+	
+	<test-suite/>
+	
+	<end/>
+	
+</caldavtest>

Added: CalDAVTester/trunk/monitor/get/get-small.xml
===================================================================
--- CalDAVTester/trunk/monitor/get/get-small.xml	                        (rev 0)
+++ CalDAVTester/trunk/monitor/get/get-small.xml	2007-01-08 20:30:53 UTC (rev 970)
@@ -0,0 +1,43 @@
+<?xml version="1.0"?>
+
+<!DOCTYPE caldavtest SYSTEM "caldavtest.dtd">
+
+<!--
+ Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ DRI: Cyrus Daboo, cdaboo at apple.com
+ -->
+
+<caldavtest ignore-all='yes'>
+	<description>Performance check GET</description>
+
+	<start/>
+	
+	<test-suite name='Plain GET - calendar collection' ignore='no'>
+		<test name='1' count='1' stats='yes'>
+			<description>GET on calendar collection</description>
+			<request>
+				<method>GET</method>
+				<ruri>1.ics</ruri>
+				<verify>
+					<callback>statusCode</callback>
+				</verify>
+			</request>
+		</test>
+	</test-suite>
+	
+	<end/>
+	
+</caldavtest>

Added: CalDAVTester/trunk/monitor/get/get-start.xml
===================================================================
--- CalDAVTester/trunk/monitor/get/get-start.xml	                        (rev 0)
+++ CalDAVTester/trunk/monitor/get/get-start.xml	2007-01-08 20:30:53 UTC (rev 970)
@@ -0,0 +1,41 @@
+<?xml version="1.0"?>
+
+<!DOCTYPE caldavtest SYSTEM "caldavtest.dtd">
+
+<!--
+ Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ DRI: Cyrus Daboo, cdaboo at apple.com
+ -->
+
+<caldavtest ignore-all='yes'>
+	<description>Performance check GET</description>
+
+	<start>
+		<request end-delete='no'>
+			<method>PUT</method>
+			<ruri>1.ics</ruri>
+			<data>
+				<content-type>text/calendar; charset=utf-8</content-type>
+				<filepath>Resource/monitor/get/1.ics</filepath>
+			</data>
+		</request>
+	</start>
+	
+	<test-suite/>
+	
+	<end/>
+	
+</caldavtest>

Added: CalDAVTester/trunk/monitor.py
===================================================================
--- CalDAVTester/trunk/monitor.py	                        (rev 0)
+++ CalDAVTester/trunk/monitor.py	2007-01-08 20:30:53 UTC (rev 970)
@@ -0,0 +1,97 @@
+#!/usr/bin/env python
+#
+##
+# Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# DRI: Cyrus Daboo, cdaboo at apple.com
+##
+#
+# Runs a series of test suites inb parallel using a thread pool
+#
+import signal
+import time
+import datetime
+import sys
+
+import xml.dom.minidom
+import src.xmlDefs
+
+from src.manager import manager
+from src.monitorinfo import monitorinfo
+
+EX_INVALID_CONFIG_FILE = "Invalid Config File"
+
+if __name__ == "__main__":
+    
+    def readXML():
+
+        monitorinfoname = "scripts/monitoring/monitorinfo.xml"
+        if len(sys.argv) > 1:
+            monitorinfoname = sys.argv[1]
+            
+        # Open and parse the server config file
+        fd = open(monitorinfoname, "r")
+        doc = xml.dom.minidom.parse( fd )
+        fd.close()
+
+        # Verify that top-level element is correct
+        monitorinfoname_node = doc._get_documentElement()
+        if monitorinfoname_node._get_localName() != src.xmlDefs.ELEMENT_MONITORINFO:
+            raise EX_INVALID_CONFIG_FILE
+        if not monitorinfoname_node.hasChildNodes():
+            raise EX_INVALID_CONFIG_FILE
+        minfo = monitorinfo()
+        minfo.parseXML(monitorinfoname_node)
+        return minfo
+    
+    minfo = readXML()
+
+    def doScript(script, dict={}):
+        mgr = manager(level=manager.LOG_NONE)
+        return mgr.runWithOptions(minfo.serverinfo, "", [script,], dict)
+
+    def doStart():
+        if minfo.startscript:
+            print "Runnning start script %s" % (minfo.startscript,)
+            doScript(minfo.startscript)
+
+    def doEnd(sig, frame):
+        if minfo.endscript:
+            print "Runnning end script %s" % (minfo.endscript,)
+            doScript(minfo.endscript)
+        sys.exit()
+
+    signal.signal(signal.SIGINT, doEnd)
+
+    doStart()
+
+    if minfo.logging:
+        print "Start:"
+    try:
+        while(True):
+            time.sleep(minfo.period)
+            result, timing = doScript(minfo.testinfo, minfo.subsdict)
+            if minfo.logging:
+                print "Result: %d, Timing: %.3f" % (result, timing,)
+            if timing >= minfo.warningtime:
+                print "[%s] WARNING: request time (%.3f) exceeds limit (%.3f)" % (str(datetime.datetime.now()), timing, minfo.warningtime,)
+            if result != 0:
+                print "[%s] WARNING: request failed" % (str(datetime.datetime.now()),)
+        if minfo.logging:
+            print "Done"
+    except SystemExit:
+        pass
+    except Exception, e:
+        print "Run exception: %s" % (str(e),)

Added: CalDAVTester/trunk/scripts/monitoring/get.xml
===================================================================
--- CalDAVTester/trunk/scripts/monitoring/get.xml	                        (rev 0)
+++ CalDAVTester/trunk/scripts/monitoring/get.xml	2007-01-08 20:30:53 UTC (rev 970)
@@ -0,0 +1,58 @@
+<?xml version="1.0" standalone="no"?>
+
+<!DOCTYPE perfinfo SYSTEM "monitorinfo.dtd">
+
+<!--
+ Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ DRI: Cyrus Daboo, cdaboo at apple.com
+ -->
+
+<monitorinfo>
+	<logging enable="yes"/>
+	<period>1.0</period>
+	<serverinfo>scripts/server/serverinfo-monitor.xml</serverinfo>
+	<start>monitor/get/get-start.xml</start>
+	<testinfo>monitor/get/get-small.xml</testinfo>
+	<end>monitor/get/get-end.xml</end>
+	<warningtime>1.0</warningtime>
+	<substitutions>
+		<!-- first user id -->
+		<substitution>
+			<key>$userid1:</key>
+			<value>cdaboo</value>
+		</substitution>
+		<!-- password for first user -->
+		<substitution>
+			<key>$pswd1:</key>
+			<value>appledav6585</value>
+		</substitution>
+		<!-- relative path to first user principal resource-->
+		<substitution>
+			<key>$principal:</key>
+			<value>/principals/user/cdaboo</value>
+		</substitution>
+		<!-- relative path to first user calendar home-->
+		<substitution>
+			<key>$pathprefix:</key>
+			<value>/calendars/user/cdaboo</value>
+		</substitution>
+		<!-- relative path to first user calendar home-->
+		<substitution>
+			<key>$calendarpath1:</key>
+			<value>/calendars/user/cdaboo/calendar</value>
+		</substitution>
+	</substitutions>
+</monitorinfo>

Added: CalDAVTester/trunk/scripts/monitoring/monitorinfo.dtd
===================================================================
--- CalDAVTester/trunk/scripts/monitoring/monitorinfo.dtd	                        (rev 0)
+++ CalDAVTester/trunk/scripts/monitoring/monitorinfo.dtd	2007-01-08 20:30:53 UTC (rev 970)
@@ -0,0 +1,40 @@
+<!--
+ Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ DRI: Cyrus Daboo, cdaboo at apple.com
+ -->
+
+<!ELEMENT monitorinfo (logging, period, serverinfo, start, testinfo, end, warningtime, substitutions)? >
+
+	<!ELEMENT logging		EMPTY>
+		<!ATTLIST logging	enable (yes|no) "no">
+
+	<!ELEMENT period    	(#PCDATA)>
+
+	<!ELEMENT serverinfo	(#PCDATA)>
+
+	<!ELEMENT start	        (#PCDATA)>
+
+	<!ELEMENT testinfo	    (#PCDATA)>
+
+	<!ELEMENT end    	    (#PCDATA)>
+
+	<!ELEMENT warningtime  	(#PCDATA)>
+
+	<!ELEMENT substitutions	(substitution*)>
+		<!ELEMENT substitution	(key, value)>
+			<!ELEMENT key			(#PCDATA)>
+			<!ELEMENT value			(#PCDATA)>
+	

Added: CalDAVTester/trunk/scripts/monitoring/monitorinfo.xml
===================================================================
--- CalDAVTester/trunk/scripts/monitoring/monitorinfo.xml	                        (rev 0)
+++ CalDAVTester/trunk/scripts/monitoring/monitorinfo.xml	2007-01-08 20:30:53 UTC (rev 970)
@@ -0,0 +1,58 @@
+<?xml version="1.0" standalone="no"?>
+
+<!DOCTYPE monitorinfo SYSTEM "monitorinfo.dtd">
+
+<!--
+ Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ DRI: Cyrus Daboo, cdaboo at apple.com
+ -->
+
+<monitorinfo>
+	<logging enable="no"/>
+	<period>1</period>
+	<serverinfo>scripts/server/serverinfo-monitor.xml</serverinfo>
+	<start/>
+	<testinfo>monitor/get/get.xml</testinfo>
+	<end/>
+	<warningtime>1.0</warningtime>
+	<substitutions>
+		<!-- first user id -->
+		<substitution>
+			<key>$userid1:</key>
+			<value>admin</value>
+		</substitution>
+		<!-- password for first user -->
+		<substitution>
+			<key>$pswd1:</key>
+			<value>admin</value>
+		</substitution>
+		<!-- relative path to first user principal resource-->
+		<substitution>
+			<key>$principal:</key>
+			<value>/principals/user/admin/</value>
+		</substitution>
+		<!-- relative path to first user calendar home-->
+		<substitution>
+			<key>$pathprefix:</key>
+			<value>/calendars/user/admin</value>
+		</substitution>
+		<!-- relative path to first user calendar home-->
+		<substitution>
+			<key>$calendarpath1:</key>
+			<value>/calendars/user/admin/calendar</value>
+		</substitution>
+	</substitutions>
+</monitorinfo>

Added: CalDAVTester/trunk/scripts/server/serverinfo-monitor.xml
===================================================================
--- CalDAVTester/trunk/scripts/server/serverinfo-monitor.xml	                        (rev 0)
+++ CalDAVTester/trunk/scripts/server/serverinfo-monitor.xml	2007-01-08 20:30:53 UTC (rev 970)
@@ -0,0 +1,98 @@
+<?xml version="1.0" standalone="no"?>
+
+<!DOCTYPE serverinfo SYSTEM "serverinfo.dtd">
+
+<!--
+ Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ DRI: Cyrus Daboo, cdaboo at apple.com
+ -->
+
+<serverinfo>
+	<host>localhost</host>
+	<port>8008</port>
+	<substitutions>
+		<substitution>
+			<key>$host:</key>
+			<value>http://localhost:8008</value>
+		</substitution>
+
+		<!-- relative path to principal collection-->
+		<substitution>
+			<key>$principals:</key>
+			<value>/principals/user/</value>
+		</substitution>
+
+		<!-- relative path to resource principal collection-->
+		<substitution>
+			<key>$resources:</key>
+			<value>/principals/resource/</value>
+		</substitution>
+
+		<!-- user id for admin user -->
+		<substitution>
+			<key>$useradmin:</key>
+			<value>admin</value>
+		</substitution>
+		<!-- password for admin user -->
+		<substitution>
+			<key>$pswdadmin:</key>
+			<value>admin</value>
+		</substitution>
+		<!-- relative path to admin principal resource-->
+		<substitution>
+			<key>$principaladmin:</key>
+			<value>/principals/user/admin/</value>
+		</substitution>
+
+		<!-- relative path to principal collection-->
+		<substitution>
+			<key>$principals:</key>
+			<value>/principals/user/</value>
+		</substitution>
+
+		<!-- relative path to first user principal resource-->
+		<substitution>
+			<key>$userid1:</key>
+			<value>user01</value>
+		</substitution>
+		<!-- password for first user -->
+		<substitution>
+			<key>$pswd1:</key>
+			<value>user01</value>
+		</substitution>
+		<!-- relative path to first user principal resource-->
+		<substitution>
+			<key>$principal:</key>
+			<value>/principals/user/user01/</value>
+		</substitution>
+		<!-- relative path to first user calendar home-->
+		<substitution>
+			<key>$pathprefix:</key>
+			<value>/calendars/user/user01</value>
+		</substitution>
+		<!-- relative path to first user calendar home-->
+		<substitution>
+			<key>$calendarpath1:</key>
+			<value>/calendars/user/user01/calendar</value>
+		</substitution>
+		<!-- calendar user address of first user-->
+		<substitution>
+			<key>$cuaddr1:</key>
+			<value>mailto:user01 at example.com</value>
+		</substitution>
+	</substitutions>
+	<serverfilepath>/Users/cyrusdaboo/Documents/Development/Apple/eclipse/CalendarServer/twistedcaldav/test/data/</serverfilepath>
+</serverinfo>

Added: CalDAVTester/trunk/src/monitorinfo.py
===================================================================
--- CalDAVTester/trunk/src/monitorinfo.py	                        (rev 0)
+++ CalDAVTester/trunk/src/monitorinfo.py	2007-01-08 20:30:53 UTC (rev 970)
@@ -0,0 +1,73 @@
+##
+# Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# DRI: Cyrus Daboo, cdaboo at apple.com
+##
+
+"""
+Class that encapsulates the server information for CalDAV monitoring.
+"""
+
+import src.xmlDefs
+
+class monitorinfo( object ):
+    """
+    Maintains information about the monitoring test scenario.
+    """
+    __slots__  = ['logging', 'period', 'serverinfo', 'startscript', 'testinfo', 'endscript', 'warningtime', 'subsdict']
+
+    def __init__( self ):
+        self.logging = False
+        self.period = 1.0
+        self.serverinfo = ""
+        self.startscript = ""
+        self.testinfo = ""
+        self.endscript = ""
+        self.warningtime = 1.0
+        self.subsdict = {}
+
+    def parseXML( self, node ):
+        for child in node._get_childNodes():
+            if child._get_localName() == src.xmlDefs.ELEMENT_LOGGING:
+                self.logging = child.getAttribute( src.xmlDefs.ATTR_ENABLE ) != src.xmlDefs.ATTR_VALUE_NO
+            elif child._get_localName() == src.xmlDefs.ELEMENT_PERIOD:
+                self.period = float(child.firstChild.data)
+            elif child._get_localName() == src.xmlDefs.ELEMENT_SERVERINFO:
+                self.serverinfo = child.firstChild.data
+            elif child._get_localName() == src.xmlDefs.ELEMENT_START:
+                if child.firstChild is not None:
+                    self.startscript = child.firstChild.data
+            elif child._get_localName() == src.xmlDefs.ELEMENT_TESTINFO:
+                self.testinfo = child.firstChild.data
+            elif child._get_localName() == src.xmlDefs.ELEMENT_END:
+                if child.firstChild is not None:
+                    self.endscript = child.firstChild.data
+            elif child._get_localName() == src.xmlDefs.ELEMENT_WARNINGTIME:
+                self.warningtime = float(child.firstChild.data)
+            elif child._get_localName() == src.xmlDefs.ELEMENT_SUBSTITUTIONS:
+                self.parseSubstitutionsXML(child)
+
+    def parseSubstitutionsXML(self, node):
+        for child in node._get_childNodes():
+            if child._get_localName() == src.xmlDefs.ELEMENT_SUBSTITUTION:
+                key = None
+                value = None
+                for schild in child._get_childNodes():
+                    if schild._get_localName() == src.xmlDefs.ELEMENT_KEY:
+                        key = schild.firstChild.data
+                    elif schild._get_localName() == src.xmlDefs.ELEMENT_VALUE:
+                        value = schild.firstChild.data
+                if key and value:
+                    self.subsdict[key] = value

Modified: CalDAVTester/trunk/src/xmlDefs.py
===================================================================
--- CalDAVTester/trunk/src/xmlDefs.py	2007-01-08 19:56:38 UTC (rev 969)
+++ CalDAVTester/trunk/src/xmlDefs.py	2007-01-08 20:30:53 UTC (rev 970)
@@ -36,9 +36,11 @@
 ELEMENT_KEY = "key"
 ELEMENT_LOGGING = "logging"
 ELEMENT_METHOD = "method"
+ELEMENT_MONITORINFO = "monitorinfo"
 ELEMENT_NAME = "name"
 ELEMENT_PATH = "path"
 ELEMENT_PERFINFO = "perfinfo"
+ELEMENT_PERIOD = "period"
 ELEMENT_POPULATE = "populate"
 ELEMENT_PORT = "port"
 ELEMENT_REQUEST = "request"
@@ -58,6 +60,7 @@
 ELEMENT_THREADS = "threads"
 ELEMENT_VALUE = "value"
 ELEMENT_VERIFY = "verify"
+ELEMENT_WARNINGTIME = "warningtime"
 
 ATTR_AUTH = "auth"
 ATTR_COUNT = "count"

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20070108/f4563a7f/attachment.html


More information about the calendarserver-changes mailing list