<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[14070] CalDAVTester/trunk/src</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/14070">14070</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2014-10-10 13:30:54 -0700 (Fri, 10 Oct 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add a --debug option to help find async scheduling related problems.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalDAVTestertrunksrccaldavtestpy">CalDAVTester/trunk/src/caldavtest.py</a></li>
<li><a href="#CalDAVTestertrunksrcmanagerpy">CalDAVTester/trunk/src/manager.py</a></li>
<li><a href="#CalDAVTestertrunksrcserverinfopy">CalDAVTester/trunk/src/serverinfo.py</a></li>
<li><a href="#CalDAVTestertrunksrctestsuitepy">CalDAVTester/trunk/src/testsuite.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalDAVTestertrunksrccaldavtestpy"></a>
<div class="modfile"><h4>Modified: CalDAVTester/trunk/src/caldavtest.py (14069 => 14070)</h4>
<pre class="diff"><span>
<span class="info">--- CalDAVTester/trunk/src/caldavtest.py        2014-10-10 14:44:50 UTC (rev 14069)
+++ CalDAVTester/trunk/src/caldavtest.py        2014-10-10 20:30:54 UTC (rev 14070)
</span><span class="lines">@@ -82,6 +82,7 @@
</span><span class="cx">         self.suites = []
</span><span class="cx">         self.grabbedlocation = None
</span><span class="cx">         self.previously_found = set()
</span><ins>+        self.uidmaps = {}
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def missingFeatures(self):
</span><span class="lines">@@ -101,7 +102,9 @@
</span><span class="cx">             return 0, 0, 1
</span><span class="cx"> 
</span><span class="cx">         # Always need a new set of UIDs for the entire test
</span><del>-        self.manager.server_info.newUIDs()
</del><ins>+        uids = self.manager.server_info.newUIDs()
+        for uid, uidname in uids:
+            self.uidmaps[uid] = &quot;{} - {}&quot;.format(uidname, self.name)
</ins><span class="cx"> 
</span><span class="cx">         self.only = any([suite.only for suite in self.suites])
</span><span class="cx">         try:
</span><span class="lines">@@ -157,7 +160,9 @@
</span><span class="cx">             etags = {}
</span><span class="cx">             only_tests = any([test.only for test in suite.tests])
</span><span class="cx">             testsuite = self.manager.testSuite(testfile, result_name, &quot;&quot;)
</span><del>-            suite.aboutToRun()
</del><ins>+            uids = suite.aboutToRun()
+            for uid, uidname in uids:
+                self.uidmaps[uid] = &quot;{} - {}&quot;.format(uidname, label)
</ins><span class="cx">             for test in suite.tests:
</span><span class="cx">                 result = self.run_test(testsuite, test, etags, only_tests, label=&quot;%s | %s&quot; % (label, test.name))
</span><span class="cx">                 if result == &quot;t&quot;:
</span><span class="lines">@@ -244,6 +249,22 @@
</span><span class="cx">         return result
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    def doget(self, resource, label=&quot;&quot;):
+        req = request(self.manager)
+        req.method = &quot;GET&quot;
+        req.ruris.append(resource[0])
+        req.ruri = resource[0]
+        if len(resource[1]):
+            req.user = resource[1]
+        if len(resource[2]):
+            req.pswd = resource[2]
+        _ignore_result, _ignore_resulttxt, response, respdata = self.dorequest(req, False, False, label=label)
+        if response.status / 100 != 2:
+            return False, None
+
+        return True, respdata
+
+
</ins><span class="cx">     def dofindall(self, collection, label=&quot;&quot;):
</span><span class="cx">         hrefs = []
</span><span class="cx">         req = request(self.manager)
</span><span class="lines">@@ -398,6 +419,7 @@
</span><span class="cx"> 
</span><span class="cx">     def dowaitcount(self, collection, count, label=&quot;&quot;):
</span><span class="cx"> 
</span><ins>+        hrefs = []
</ins><span class="cx">         for _ignore in range(self.manager.server_info.waitcount):
</span><span class="cx">             req = request(self.manager)
</span><span class="cx">             req.method = &quot;PROPFIND&quot;
</span><span class="lines">@@ -418,21 +440,39 @@
</span><span class="cx"> &quot;&quot;&quot;
</span><span class="cx">             req.data.content_type = &quot;text/xml&quot;
</span><span class="cx">             result, _ignore_resulttxt, response, respdata = self.dorequest(req, False, False, label=&quot;%s | %s %d&quot; % (label, &quot;WAITCOUNT&quot;, count))
</span><del>-            ctr = 0
</del><ins>+            hrefs = []
</ins><span class="cx">             if result and (response is not None) and (response.status == 207) and (respdata is not None):
</span><span class="cx">                 tree = ElementTree(file=StringIO(respdata))
</span><span class="cx"> 
</span><span class="cx">                 for response in tree.findall(&quot;{DAV:}response&quot;):
</span><del>-                    ctr += 1
</del><ins>+                    href = response.findall(&quot;{DAV:}href&quot;)[0]
+                    if href.text.rstrip(&quot;/&quot;) != collection[0].rstrip(&quot;/&quot;):
+                        hrefs.append(href.text)
</ins><span class="cx"> 
</span><del>-                if ctr - 1 == count:
-                    return None
</del><ins>+                if len(hrefs) == count:
+                    return True, None
</ins><span class="cx">             delay = self.manager.server_info.waitdelay
</span><span class="cx">             starttime = time.time()
</span><span class="cx">             while (time.time() &lt; starttime + delay):
</span><span class="cx">                 pass
</span><ins>+
+        if self.manager.debug:
+            # Get the content of each resource
+            rdata = &quot;&quot;
+            for href in hrefs:
+                result, respdata = self.doget((href, collection[1], collection[2],), label)
+                if respdata.startswith(&quot;BEGIN:VCALENDAR&quot;):
+                    uid = respdata.find(&quot;UID:&quot;)
+                    if uid != -1:
+                        uid = respdata[uid + 4:uid + respdata[uid:].find(&quot;\r\n&quot;)]
+                        test = self.uidmaps.get(uid, &quot;unknown&quot;)
+                    else:
+                        test = &quot;unknown&quot;
+                rdata += &quot;\n\nhref: {}\ntest: {}\n\n{}\n&quot;.format(href, test, respdata)
+
+            return False, rdata
</ins><span class="cx">         else:
</span><del>-            return ctr - 1
</del><ins>+            return False, len(hrefs)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def dowaitchanged(self, uri, etag, user, pswd, label=&quot;&quot;):
</span><span class="lines">@@ -547,9 +587,9 @@
</span><span class="cx">             count = int(req.method[10:])
</span><span class="cx">             for ruri in req.ruris:
</span><span class="cx">                 collection = (ruri, req.user, req.pswd)
</span><del>-                waitcount = self.dowaitcount(collection, count, label=label)
-                if waitcount is not None:
-                    return False, &quot;Count did not change: {}&quot;.format(waitcount), None, None
</del><ins>+                waitresult, waitdetails = self.dowaitcount(collection, count, label=label)
+                if not waitresult:
+                    return False, &quot;Count did not change: {}&quot;.format(waitdetails), None, None
</ins><span class="cx">             else:
</span><span class="cx">                 return True, &quot;&quot;, None, None
</span><span class="cx"> 
</span><span class="lines">@@ -558,12 +598,12 @@
</span><span class="cx">             count = int(req.method[len(&quot;WAITDELETEALL&quot;):])
</span><span class="cx">             for ruri in req.ruris:
</span><span class="cx">                 collection = (ruri, req.user, req.pswd)
</span><del>-                waitcount = self.dowaitcount(collection, count, label=label)
-                if waitcount is None:
</del><ins>+                waitresult, waitdetails = self.dowaitcount(collection, count, label=label)
+                if waitresult:
</ins><span class="cx">                     hrefs = self.dofindall(collection, label=&quot;%s | %s&quot; % (label, &quot;DELETEALL&quot;))
</span><span class="cx">                     self.dodeleteall(hrefs, label=&quot;%s | %s&quot; % (label, &quot;DELETEALL&quot;))
</span><span class="cx">                 else:
</span><del>-                    return False, &quot;Count did not change: {}&quot;.format(waitcount), None, None
</del><ins>+                    return False, &quot;Count did not change: {}&quot;.format(waitdetails), None, None
</ins><span class="cx">             else:
</span><span class="cx">                 return True, &quot;&quot;, None, None
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalDAVTestertrunksrcmanagerpy"></a>
<div class="modfile"><h4>Modified: CalDAVTester/trunk/src/manager.py (14069 => 14070)</h4>
<pre class="diff"><span>
<span class="info">--- CalDAVTester/trunk/src/manager.py        2014-10-10 14:44:50 UTC (rev 14069)
+++ CalDAVTester/trunk/src/manager.py        2014-10-10 20:30:54 UTC (rev 14070)
</span><span class="lines">@@ -62,6 +62,7 @@
</span><span class="cx">         self.print_request = False
</span><span class="cx">         self.print_response = False
</span><span class="cx">         self.print_request_response_on_error = False
</span><ins>+        self.debug = False
</ins><span class="cx"> 
</span><span class="cx">         self.results = []
</span><span class="cx">         self.totals = {
</span><span class="lines">@@ -238,6 +239,7 @@
</span><span class="cx">                 &quot;print-details-onfail&quot;,
</span><span class="cx">                 &quot;always-print-request&quot;,
</span><span class="cx">                 &quot;always-print-response&quot;,
</span><ins>+                &quot;debug&quot;
</ins><span class="cx">             ],
</span><span class="cx">         )
</span><span class="cx"> 
</span><span class="lines">@@ -281,6 +283,8 @@
</span><span class="cx">                 random_order = True
</span><span class="cx">             elif option == &quot;--random-seed&quot;:
</span><span class="cx">                 random_seed = value
</span><ins>+            elif option == &quot;--debug&quot;:
+                self.debug = True
</ins><span class="cx"> 
</span><span class="cx">         if all:
</span><span class="cx">             files = []
</span></span></pre></div>
<a id="CalDAVTestertrunksrcserverinfopy"></a>
<div class="modfile"><h4>Modified: CalDAVTester/trunk/src/serverinfo.py (14069 => 14070)</h4>
<pre class="diff"><span>
<span class="info">--- CalDAVTester/trunk/src/serverinfo.py        2014-10-10 14:44:50 UTC (rev 14069)
+++ CalDAVTester/trunk/src/serverinfo.py        2014-10-10 20:30:54 UTC (rev 14070)
</span><span class="lines">@@ -152,6 +152,7 @@
</span><span class="cx">         uidsubs = dict([(&quot;$uid{}:&quot;.format(i), str(uuid4())) for i in range(1, 21)])
</span><span class="cx">         self.subsdict.update(uidsubs)
</span><span class="cx">         self.extrasubsdict.update(uidsubs)
</span><ins>+        return set([(v, k) for k, v in uidsubs.items()])
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def parseXML(self, node):
</span></span></pre></div>
<a id="CalDAVTestertrunksrctestsuitepy"></a>
<div class="modfile"><h4>Modified: CalDAVTester/trunk/src/testsuite.py (14069 => 14070)</h4>
<pre class="diff"><span>
<span class="info">--- CalDAVTester/trunk/src/testsuite.py        2014-10-10 14:44:50 UTC (rev 14069)
+++ CalDAVTester/trunk/src/testsuite.py        2014-10-10 20:30:54 UTC (rev 14070)
</span><span class="lines">@@ -45,8 +45,7 @@
</span><span class="cx">         a test file we also need test suites to have unique UIDs. The &quot;change-uid&quot; attribute
</span><span class="cx">         can be used to reset the active UIDs for a test suite.
</span><span class="cx">         &quot;&quot;&quot;
</span><del>-        if self.changeuid:
-            self.manager.server_info.newUIDs()
</del><ins>+        return self.manager.server_info.newUIDs() if self.changeuid else set()
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def missingFeatures(self):
</span></span></pre>
</div>
</div>

</body>
</html>