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)
Esempio n. 2
0
 def worker():
     for i in range(numEvents):
         event = makeEvent(i, 1, 0)
         yield agent.request(
             'PUT',
             '%s%s%d.ics' % (uri, cal, i),
             Headers({"content-type": ["text/calendar"]}),
             StringProducer(event))
Esempio n. 3
0
def measure(host, port, dtrace, events, samples):
    user = password = "******"
    uid = "10000000-0000-0000-0000-000000000001"
    root = "/"
    principal = "/"
    calendar = "vfreebusy-benchmark"

    authinfo = HTTPDigestAuthHandler()
    authinfo.add_password(realm="Test Realm",
                          uri="http://%s:%d/" % (host, port),
                          user=user,
                          passwd=password)
    agent = AuthHandlerAgent(Agent(reactor), authinfo)

    # First set things up
    account = yield initialize(agent, host, port, user, password, root,
                               principal, calendar)

    base = "/calendars/users/%s/%s/foo-%%d.ics" % (user, calendar)
    baseTime = datetime.now().replace(hour=12,
                                      minute=15,
                                      second=0,
                                      microsecond=0)
    for i, cal in enumerate(makeEvents(baseTime, events)):
        yield account.writeData(base % (i, ), cal, "text/calendar")

    method = 'POST'
    uri = 'http://%s:%d/calendars/__uids__/%s/outbox/' % (host, port, user)
    headers = Headers({
        "content-type": ["text/calendar"],
        "originator": ["mailto:%[email protected]" % (user, )],
        "recipient": [
            "urn:x-uid:%s, urn:x-uid:10000000-0000-0000-0000-000000000002" %
            (uid, )
        ]
    })

    vfb = VFREEBUSY % {
        "attendees":
        "".join([
            "ATTENDEE:urn:x-uid:%s\n" % (uid, ),
            "ATTENDEE:urn:x-uid:10000000-0000-0000-0000-000000000002\n"
        ]),
        "start":
        formatDate(baseTime.replace(hour=0, minute=0)) + 'Z',
        "end":
        formatDate(baseTime.replace(hour=0, minute=0) + timedelta(days=1)) +
        'Z'
    }
    body = StringProducer(vfb.replace("\n", "\r\n"))

    samples = yield sample(dtrace, samples, agent, lambda:
                           (method, uri, headers, body), OK)
    returnValue(samples)
Esempio n. 4
0
def measure(host, port, dtrace, attendeeCount, samples):
    organizerSequence = 1
    user = password = "******" % (organizerSequence, )
    root = "/"
    principal = "/"

    # Two calendars between which to move the event.
    fooCalendar = "event-move-foo-benchmark"
    barCalendar = "event-move-bar-benchmark"

    authinfo = HTTPDigestAuthHandler()
    authinfo.add_password(realm="Test Realm",
                          uri="http://%s:%d/" % (host, port),
                          user=user,
                          passwd=password)
    agent = AuthHandlerAgent(Agent(reactor), authinfo)

    # Set up the calendars first
    for calendar in [fooCalendar, barCalendar]:
        yield initialize(agent, host, port, user, password, root, principal,
                         calendar)

    fooURI = 'http://%s:%d/calendars/__uids__/%s/%s/some-event.ics' % (
        host, port, user, fooCalendar)
    barURI = 'http://%s:%d/calendars/__uids__/%s/%s/some-event.ics' % (
        host, port, user, barCalendar)

    # Create the event that will move around
    headers = Headers({"content-type": ["text/calendar"]})
    yield agent.request(
        'PUT', fooURI, headers,
        StringProducer(makeEvent(1, organizerSequence, attendeeCount)))

    # Move it around sooo much
    source = cycle([fooURI, barURI])
    dest = cycle([barURI, fooURI])

    params = (('MOVE', source.next(),
               Headers({
                   "destination": [dest.next()],
                   "overwrite": ["F"]
               })) for i in count(1))

    samples = yield sample(dtrace, samples, agent, params.next, CREATED)
    returnValue(samples)
Esempio n. 5
0
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)
Esempio n. 6
0
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)
Esempio n. 7
0
def measure(host, port, dtrace, attendeeCount, samples):
    organizerSequence = 1
    user = password = "******" % (organizerSequence,)
    root = "/"
    principal = "/"
    calendar = "event-deletion-benchmark"

    authinfo = HTTPDigestAuthHandler()
    authinfo.add_password(
        realm="Test Realm",
        uri="http://%s:%d/" % (host, port),
        user=user,
        passwd=password)
    agent = AuthHandlerAgent(Agent(reactor), authinfo)

    # Set up the calendar first
    yield initialize(agent, host, port, user, password, root, principal, calendar)

    # An infinite stream of VEVENTs to PUT to the server.
    events = ((i, makeEvent(i, organizerSequence, attendeeCount))
              for i in count(2))

    # Create enough events to delete
    uri = 'http://%s:%d/calendars/__uids__/%s/%s/foo-%%d.ics' % (
        host, port, user, calendar)
    headers = Headers({"content-type": ["text/calendar"]})
    urls = []
    for i, body in events:
        urls.append(uri % (i,))
        yield agent.request(
            'PUT', urls[-1], headers, StringProducer(body))
        if len(urls) == samples:
            break

    # Now delete them all
    samples = yield sample(
        dtrace, samples,
        agent, (('DELETE', url) for url in urls).next,
        NO_CONTENT)
    returnValue(samples)