def flush(self): """ :type self: StringIONotifying or StringIO """ StringIO.flush(self) self.listener()
def __init__(self, listener): """ :type self: StringIO """ StringIO.__init__(self) # pylint: disable=non-parent-init-called self.listener = listener
def __init__(self, listener): """ :type self: StringIO """ StringIO.__init__(self) self.listener = listener
def flush(self): """ :type self: StringIONotifying or StringIO """ # noinspection PyArgumentList StringIO.flush(self) self.listener()
def test_reader_buffering(self): first_part = '{"a": 1, "b": 2}\n{"a": 2,' second_part = '"b": 3}\n{"a": 3, "b": 4}\n' reader = LDJSONReader("yip", logging.getLogger()) buffer = StringIO(first_part) reader.fds = buffer items = list(reader.read(last_pass=False)) self.assertEqual(len(items), 1) buffer.write(second_part) items = list(reader.read(last_pass=False)) self.assertEqual(len(items), 2)
def test_schedule_rps(self): executor = PBenchExecutor() executor.engine = EngineEmul() executor.engine.config.merge({"provisioning": "test"}) rps = 9 rampup = 12 executor.execution.merge({ "throughput": rps, "ramp-up": rampup, "steps": 3, "hold-for": 0 }) obj = Scheduler(executor.get_load(), StringIO("4 test\ntest\n"), logging.getLogger("")) cnt = 0 cur = 0 currps = 0 for item in obj.generate(): # logging.debug("Item: %s", item) if int(math.ceil(item[0])) != cur: # self.assertLessEqual(currps, rps) cur = int(math.ceil(item[0])) logging.debug("RPS: %s", currps) currps = 0 cnt += 1 currps += 1 logging.debug("RPS: %s", currps)
def test_schedule_empty(self): executor = PBenchExecutor() executor.engine = EngineEmul() obj = Scheduler(executor.get_load(), StringIO("4 test\ntest\n"), logging.getLogger("")) for item in obj.generate(): logging.debug("Item: %s", item)
def test_schedule_empty(self): executor = PBenchExecutor() executor.engine = EngineEmul() # concurrency: 1, iterations: 1 obj = Scheduler(executor.get_load(), StringIO("4 test\ntest\n"), logging.getLogger("")) items = list(obj.generate()) for item in items: logging.debug("Item: %s", item) self.assertEqual(1, len(items))
def test_schedule_empty(self): executor = PBenchExecutor() executor.engine = EngineEmul() try: obj = Scheduler(executor.get_load(), StringIO("4 test\ntest\n"), logging.getLogger("")) for item in obj.generate(): logging.debug("Item: %s", item) self.fail() except NotImplementedError: pass
def test_schedule_with_no_rampup(self): executor = PBenchExecutor() executor.engine = EngineEmul() executor.execution.merge({ "concurrency": 10, "ramp-up": None, "steps": 3, "hold-for": 10 }) # this line shouln't throw an exception obj = Scheduler(executor.get_load(), StringIO("4 test\ntest\n"), logging.getLogger(""))
def test_schedule_concurrency_steps(self): executor = PBenchExecutor() executor.engine = EngineEmul() executor.execution.merge({ "concurrency": 5, "ramp-up": 10, "steps": 3 }) obj = Scheduler(executor.get_load(), StringIO("5 test1\ntest1\n5 test2\ntest2\n"), logging.getLogger("")) items = list(obj.generate()) self.assertEqual(8, len(items)) self.assertEqual(-1, items[5][0]) # instance became unlimited self.assertEqual(Scheduler.REC_TYPE_LOOP_START, items[6][5]) # looped payload
def test_schedule_concurrency(self): executor = PBenchExecutor() executor.engine = EngineEmul() executor.execution.merge({ "concurrency": 5, "ramp-up": 10, "hold-for": 5 }) obj = Scheduler(executor.get_load(), StringIO("5 test1\ntest1\n5 test2\ntest2\n"), logging.getLogger("")) items = list(obj.generate()) logging.debug("%s", items) self.assertEqual(8, len(items)) self.assertEqual(-1, items[5][0]) # instance became unlimited self.assertEqual(1, items[6][5]) # looped payload