Example #1
0
def _upload(reactor, url, project, revision, revision_date, benchmark,
            executable, environment, result_value, result_date, std_dev,
            max_value, min_value):
    data = {
        'commitid': str(revision),
        'revision_date': revision_date,
        'project': project,
        'benchmark': benchmark,
        'environment': environment,
        'executable': executable,
        'result_value': str(result_value),
        'result_date': result_date,
        'std_dev': str(std_dev),
        'max': str(max_value),
        'min': str(min_value),
    }
    print('uploading', data)
    agent = Agent(reactor)
    d = agent.request('POST', url, None, StringProducer(urlencode(data)))

    def check(response):
        d = readBody(response)

        def read(body):
            print('body', repr(body))
            if response.code != 200:
                raise Exception("Upload failed: %r" % (response.code,))
        d.addCallback(read)
        return d
    d.addCallback(check)
    return d
Example #2
0
def measure(calendar, organizerSequence, events, host, port, dtrace, samples):
    """
    Benchmark event creation.
    """
    user = password = "******" % (organizerSequence,)
    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)

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

    method = 'PUT'
    uri = 'http://%s:%d/calendars/__uids__/%s/%s/foo-%%d.ics' % (
        host, port, user, calendar)
    headers = Headers({"content-type": ["text/calendar"]})

    # Sample it a bunch of times
    samples = yield sample(
        dtrace, samples,
        agent, ((method, uri % (i,), headers, StringProducer(body))
                for (i, body)
                in events).next,
        CREATED)
    returnValue(samples)
Example #3
0
def _generous_sample(dtrace, replacer, agent, host, port, user, calendar,
                     fieldName, attendeeCount, samples):
    url = 'http://%s:%s/calendars/__uids__/%s/%s/%s-change.ics' % (
        host, port, user, calendar, fieldName)

    headers = Headers({"content-type": ["text/calendar"]})

    # See the makeEvent call above.
    event = makeEvent(0, 1, attendeeCount)

    yield agent.request('PUT', url, headers, StringProducer(event))

    # Sample changing the event according to the replacer.
    samples = yield sample(dtrace, samples, agent,
                           (('PUT', url, headers,
                             StringProducer(replacer(event, i)))
                            for i in count(1)).next, NO_CONTENT)
    returnValue(samples)
Example #4
0
def _selfish_sample(dtrace, replacer, agent, host, port, user, calendar,
                    fieldName, attendeeCount, samples):
    url = 'http://%s:%s/calendars/__uids__/%s/%s/%s-change-%%d.ics' % (
        host, port, user, calendar, fieldName)

    headers = Headers({"content-type": ["text/calendar"]})

    events = [
        # The organizerSequence here (1) may need to be a parameter.
        # See also the makeEvent call below.
        (makeEvent(i, 1, attendeeCount), url % (i, )) for i in range(samples)
    ]

    for (event, url) in events:
        yield agent.request('PUT', url, headers, StringProducer(event))

    # Sample changing the event according to the replacer.
    samples = yield sample(dtrace, samples, agent,
                           (('PUT', url, headers,
                             StringProducer(replacer(event, i)))
                            for i, (event, url) in enumerate(events)).next,
                           NO_CONTENT)
    returnValue(samples)
Example #5
0
def measure(host, port, dtrace, attendeeCount, samples):
    user = password = "******"
    root = "/"
    principal = "/"
    calendar = "report-principal"

    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)

    url = 'http://%s:%d/principals/' % (host, port)
    headers = Headers({"content-type": ["text/xml"]})

    samples = yield sample(
        dtrace, samples, agent, lambda:
        ('REPORT', url, headers, StringProducer(body)))
    returnValue(samples)
Example #6
0
 def writeData(self, path, data, contentType):
     return self.agent.request('PUT', self._makeURL(path),
                               Headers({'content-type': [contentType]}),
                               StringProducer(data))