def measure(host, port, dtrace, attendeeCount, samples, fieldName, replacer, eventPerSample=False): user = password = "******" root = "/" principal = "/" calendar = "event-%s-benchmark" % (fieldName, ) 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) if eventPerSample: # Create an event for each sample that will be taken, so that no event # is used for two different samples. f = _selfish_sample else: # Just create one event and re-use it for all samples. f = _generous_sample data = yield f(dtrace, replacer, agent, host, port, user, calendar, fieldName, attendeeCount, samples) returnValue(data)
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)
def test_AuthHandlerAgent_parse(self): """ Make sure auth method is handled case-insensitively. """ headers = ( "Basic realm=\"foo\"", "basic realm=\"foo\"", "BASIC realm=\"foo\"", "Digest realm=\"foo\"", "digest realm=\"foo\"", "DIGEST realm=\"foo\"", ) for hdrvalue in headers: hdlr = AuthHandlerAgent(None, None) ch = hdlr._parse(hdrvalue) self.assertTrue(ch is not None)
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)