def testNoConnection(): endpoint = BluefloodEndpoint(ingest_url='http://localhost:9623', retrieve_url='http://localhost:8231') with pytest.raises(Exception): d = yield endpoint.commit() with pytest.raises(Exception): yield endpoint.retrieve_points('', 0, 0, 0) with pytest.raises(Exception): yield endpoint.retrieve_resolution('', 0, 0)
def _setup_blueflood(self, factory, agent): log.msg('Send metrics to {} as tenant {} with {} sec interval'.format( self.blueflood_url, self.tenant, self.flush_interval)) log.msg('Limit is {} bytes'.format(self.limit)) client = BluefloodEndpoint(ingest_url=self.blueflood_url, tenant=self.tenant, agent=agent, limit=int(self.limit)) flusher = BluefloodFlush(client=client, ttl=self.ttl, metric_prefix=self.metric_prefix) factory._metric_collection.flusher = flusher
def testLimitIngestion(): timestamp = int(time.time()) name = '' value = 1.0 ttl = 0 metric = { 'collectionTime': timestamp, 'metricName': name, 'metricValue': value, 'ttlInSeconds': ttl } metric_size = len(json.dumps(metric)) count = 5 endpoint = BluefloodEndpoint(limit=metric_size * count) for i in range(count - 1): endpoint.ingest(name, timestamp, value, ttl) with pytest.raises(LimitExceededException): endpoint.ingest(name, timestamp, value, ttl)
def setup(): return BluefloodEndpoint(agent=Agent(reactor))
from twisted.web.client import Agent, FileBodyProducer, readBody from twisted.internet import reactor, defer from bluefloodserver.blueflood import BluefloodEndpoint, LimitExceededException # python-twisted source code # TODO: find better way to enable twisted plugin for this particular test module # tried pytest_plugins directly here with no luck @decorator def inlineCallbacks(fun, *args, **kw): return defer.inlineCallbacks(fun)(*args, **kw) try: b = BluefloodEndpoint() data = urllib2.urlopen(b.ingest_url).read() except urllib2.HTTPError, e: skip = False except urllib2.URLError, e: skip = True else: skip = False @pytest.fixture def setup(): return BluefloodEndpoint(agent=Agent(reactor)) @inlineCallbacks