def measure(host, port, dtrace, attendees, samples): userNumber = 1 user = password = "******" % (userNumber,) root = "/" principal = "/" calendar = "vfreebusy-vary-attendees-benchmark" targets = range(2, attendees + 2) authinfo = HTTPDigestAuthHandler() # Set up authentication info for our own user and all the other users that # may need an event created on one of their calendars. for i in [userNumber] + targets: targetUser = "******" % (i,) for path in ["calendars/users/%s/" % (targetUser,), "calendars/__uids__/10000000-0000-0000-0000-000000000%03d/" % (i,)]: authinfo.add_password( realm="Test Realm", uri="http://%s:%d/%s" % (host, port, path), user=targetUser, passwd=targetUser) agent = AuthHandlerAgent(Agent(reactor), authinfo) # Set up events on about half of the target accounts baseTime = datetime.now().replace(minute=45, second=0, microsecond=0) for i in targets[::2]: targetUser = "******" % (i,) account = CalDAVAccount( agent, "%s:%d" % (host, port), user=targetUser, password=password, root=root, principal=principal) cal = "/calendars/users/%s/%s/" % (targetUser, calendar) yield account.deleteResource(cal) yield account.makeCalendar(cal) yield account.writeData(cal + "foo.ics", makeEventNear(baseTime, i), "text/calendar") # And now issue the actual VFREEBUSY request method = 'POST' uri = 'http://%s:%d/calendars/__uids__/10000000-0000-0000-0000-000000000001/outbox/' % (host, port) headers = Headers({ "content-type": ["text/calendar"], "originator": ["mailto:%[email protected]" % (user,)], "recipient": [", ".join(["urn:x-uid:10000000-0000-0000-0000-000000000%03d" % (i,) for i in [userNumber] + targets])]}) body = StringProducer(VFREEBUSY % { "attendees": "".join([ "ATTENDEE:urn:x-uid:10000000-0000-0000-0000-000000000%03d\n" % (i,) for i in [userNumber] + targets]), "start": formatDate(baseTime.replace(hour=0, minute=0)) + 'Z', "end": formatDate( baseTime.replace(hour=0, minute=0) + timedelta(days=1)) + 'Z'}) samples = yield sample( dtrace, samples, agent, lambda: (method, uri, headers, body), OK) returnValue(samples)
def measure(host, port, dtrace, numCalendars, samples): # There's already the "calendar" calendar numCalendars -= 1 user = password = "******" root = "/" principal = "/" authinfo = HTTPDigestAuthHandler() authinfo.add_password(realm="Test Realm", uri="http://%s:%d/" % (host, port), user=user, passwd=password) agent = AuthHandlerAgent(Agent(reactor), authinfo) # Create the number of calendars necessary account = CalDAVAccount(agent, "%s:%d" % (host, port), user=user, password=password, root=root, principal=principal) cal = "/calendars/users/%s/propfind-%%d/" % (user, ) for i in range(numCalendars): yield account.makeCalendar(cal % (i, )) body = StringProducer(PROPFIND) params = (('PROPFIND', 'http://%s:%d/calendars/__uids__/%s/' % (host, port, user), Headers({ "depth": ["1"], "content-type": ["text/xml"] }), body) for i in count(1)) samples = yield sample(dtrace, samples, agent, params.next, MULTI_STATUS) # Delete the calendars we created to leave the server in roughly # the same state as we found it. for i in range(numCalendars): yield account.deleteResource(cal % (i, )) returnValue(samples)
def measure(host, port, dtrace, numEvents, samples): user = password = "******" root = "/" principal = "/" uri = "http://%s:%d/" % (host, port) authinfo = HTTPDigestAuthHandler() authinfo.add_password(realm="Test Realm", uri=uri, user=user, passwd=password) agent = AuthHandlerAgent(Agent(reactor), authinfo) # Create the number of calendars necessary account = CalDAVAccount(agent, "%s:%d" % (host, port), user=user, password=password, root=root, principal=principal) cal = "calendars/users/%s/find-events/" % (user, ) yield account.makeCalendar("/" + cal) # Create the indicated number of events on the calendar yield uploadEvents(numEvents, agent, uri, cal) body = StringProducer(PROPFIND) params = (('PROPFIND', '%scalendars/__uids__/%s/find-events/' % (uri, user), Headers({ "depth": ["1"], "content-type": ["text/xml"] }), body) for i in count(1)) samples = yield sample(dtrace, samples, agent, params.next, MULTI_STATUS) # Delete the calendar we created to leave the server in roughly # the same state as we found it. yield account.deleteResource("/" + cal) returnValue(samples)
def measure(host, port, dtrace, numCalendars, samples): # There's already the "calendar" calendar numCalendars -= 1 user = password = "******" root = "/" principal = "/" authinfo = HTTPDigestAuthHandler() authinfo.add_password( realm="Test Realm", uri="http://%s:%d/" % (host, port), user=user, passwd=password) agent = AuthHandlerAgent(Agent(reactor), authinfo) # Create the number of calendars necessary account = CalDAVAccount( agent, "%s:%d" % (host, port), user=user, password=password, root=root, principal=principal) cal = "/calendars/users/%s/propfind-%%d/" % (user,) for i in range(numCalendars): yield account.makeCalendar(cal % (i,)) body = StringProducer(PROPFIND) params = ( ('PROPFIND', 'http://%s:%d/calendars/__uids__/%s/' % (host, port, user), Headers({"depth": ["1"], "content-type": ["text/xml"]}), body) for i in count(1)) samples = yield sample(dtrace, samples, agent, params.next, MULTI_STATUS) # Delete the calendars we created to leave the server in roughly # the same state as we found it. for i in range(numCalendars): yield account.deleteResource(cal % (i,)) returnValue(samples)
def measure(host, port, dtrace, numEvents, samples): user = password = "******" root = "/" principal = "/" uri = "http://%s:%d/" % (host, port) authinfo = HTTPDigestAuthHandler() authinfo.add_password( realm="Test Realm", uri=uri, user=user, passwd=password) agent = AuthHandlerAgent(Agent(reactor), authinfo) # Create the number of calendars necessary account = CalDAVAccount( agent, "%s:%d" % (host, port), user=user, password=password, root=root, principal=principal) cal = "calendars/users/%s/find-events/" % (user,) yield account.makeCalendar("/" + cal) # Create the indicated number of events on the calendar yield uploadEvents(numEvents, agent, uri, cal) body = StringProducer(PROPFIND) params = ( ('PROPFIND', '%scalendars/__uids__/%s/find-events/' % (uri, user), Headers({"depth": ["1"], "content-type": ["text/xml"]}), body) for i in count(1)) samples = yield sample(dtrace, samples, agent, params.next, MULTI_STATUS) # Delete the calendar we created to leave the server in roughly # the same state as we found it. yield account.deleteResource("/" + cal) returnValue(samples)