本文整理汇总了Python中bzt.modules.pbench.PBenchExecutor类的典型用法代码示例。如果您正苦于以下问题:Python PBenchExecutor类的具体用法?Python PBenchExecutor怎么用?Python PBenchExecutor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PBenchExecutor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_schedule_empty
def test_schedule_empty(self):
executor = PBenchExecutor()
executor.engine = EngineEmul()
# concurrency: 1, iterations: 1
obj = Scheduler(executor.get_load(), io.BytesIO(b("4 test\ntest\n")), logging.getLogger(""))
items = list(obj.generate())
for item in items:
logging.debug("Item: %s", item)
self.assertEqual(1, len(items))
示例2: test_schedule_concurrency_steps
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(), io.BytesIO(b("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
示例3: test_schedule_empty
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
示例4: test_schedule_concurrency
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
示例5: test_install_pbench
def test_install_pbench(self):
obj = PBenchExecutor()
obj.engine = EngineEmul()
obj.settings = BetterDict()
obj.engine.config = BetterDict()
obj.settings.merge({"path": "/notexistent"})
# obj.execution = obj.engine.config['execution'][0]
try:
obj.prepare()
self.fail()
except RuntimeError as exc:
self.assertEquals("Please install PBench tool manually", str(exc))
示例6: test_pbench_file_lister
def test_pbench_file_lister(self):
obj = PBenchExecutor()
obj.engine = EngineEmul()
obj.settings = BetterDict()
obj.engine.config = BetterDict()
obj.engine.config.merge(
{ScenarioExecutor.EXEC: {"executor": "pbench", "scenario": {"script": "/opt/data/script.src"}}}
)
obj.execution = obj.engine.config["execution"]
obj.settings.merge({"path": os.path.join(os.path.dirname(__file__), "..", "phantom.sh")})
resource_files = obj.resource_files()
self.assertEqual(1, len(resource_files))
self.assertEqual(resource_files[0], "script.src")
示例7: test_pbench_payload_relpath
def test_pbench_payload_relpath(self):
"Verify that enhanced pbench preserves relative script path"
script_path = "tests/data/pbench.src"
obj = PBenchExecutor()
obj.engine = EngineEmul()
obj.settings = BetterDict()
obj.engine.config = BetterDict()
obj.engine.config.merge({
ScenarioExecutor.EXEC: {
"executor": "pbench",
"scenario": {"script": "tests/data/pbench.src"}
},
"provisioning": "test",
})
obj.execution = obj.engine.config['execution']
obj.settings.merge({
"path": os.path.join(os.path.dirname(__file__), '..', "phantom.sh"),
"enhanced": True,
})
obj.prepare()
pbench_conf = os.path.join(obj.engine.artifacts_dir, "pbench.conf")
with open(pbench_conf) as conf_fds:
config = conf_fds.read()
self.assertIn(script_path, config)
示例8: test_schedule_rps
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(), io.BytesIO(b("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)
示例9: test_same_address_port
def test_same_address_port(self):
obj = PBenchExecutor()
obj.engine = EngineEmul()
obj.settings = BetterDict()
obj.engine.config = BetterDict()
obj.engine.config.merge(yaml.load(open(__dir__() + "/../yaml/phantom_request_same_address.yml").read()))
obj.execution = obj.engine.config["execution"][0]
obj.settings.merge({"path": os.path.join(os.path.dirname(__file__), "..", "phantom.sh")})
try:
obj.prepare()
self.fail()
except ValueError:
pass
示例10: test_pbench_payload_py3_crash
def test_pbench_payload_py3_crash(self):
obj = PBenchExecutor()
obj.engine = EngineEmul()
obj.settings = BetterDict()
obj.engine.config = BetterDict()
obj.engine.config.merge({
ScenarioExecutor.EXEC: {
"executor": "pbench",
"scenario": {"requests": ["test%d" % i for i in range(20)]}
},
"provisioning": "test",
})
obj.execution = obj.engine.config['execution']
obj.settings.merge({
"path": os.path.join(os.path.dirname(__file__), '..', "phantom.sh"),
})
obj.prepare()
示例11: test_pbench_script
def test_pbench_script(self):
obj = PBenchExecutor()
obj.engine = EngineEmul()
obj.settings = BetterDict()
obj.engine.config = BetterDict()
obj.engine.config.merge({
ScenarioExecutor.EXEC: {
"executor": "pbench",
"scenario": {"script": __dir__() + "/../data/pbench.src"}
},
"provisioning": "test"
})
obj.execution = obj.engine.config['execution']
obj.settings.merge({
"path": os.path.join(os.path.dirname(__file__), '..', "phantom.sh"),
})
obj.prepare()
示例12: test_improved_request_building
def test_improved_request_building(self):
obj = PBenchExecutor()
obj.engine = EngineEmul()
obj.settings = BetterDict()
obj.engine.config = BetterDict()
obj.engine.config.merge(yaml.load(open(__dir__() + "/../yaml/phantom_improved_request.yml").read()))
obj.execution = obj.engine.config['execution'][0]
obj.settings.merge({
"path": os.path.join(os.path.dirname(__file__), '..', "phantom.sh"),
})
obj.prepare()
with open(obj.pbench.schedule_file) as fds:
config = fds.readlines()
get_requests = [req_str.split(" ")[1] for req_str in config if req_str.startswith("GET")]
self.assertEqual(len(get_requests), 2)
for get_req in get_requests:
self.assertEqual(dict(parse.parse_qsl(parse.urlsplit(get_req).query)),
{"get_param1": "value1", "get_param2": "value2"})
示例13: test_simple
def test_simple(self):
obj = PBenchExecutor()
obj.engine = EngineEmul()
obj.engine.aggregator = ConsolidatingAggregator()
obj.engine.aggregator.add_listener(DataPointLogger())
obj.engine.config.merge({"provisioning": "test"})
if os.path.exists("/home/undera/Sources/phantom"): # FIXME: not good, get rid of it
obj.settings.merge({
"path": "/home/undera/Sources/phantom/bin/phantom",
"modules-path": "/home/undera/Sources/phantom/lib/phantom",
})
else:
obj.settings.merge({
"path": os.path.join(os.path.dirname(__file__), '..', "phantom.sh"),
})
obj.execution.merge({
"log-responses": "proto_error",
# "iterations": 5000000,
"concurrency": 10,
"throughput": 1000,
"ramp-up": "1m",
# "steps": 5,
"hold-for": "15",
"scenario": {
"timeout": 1,
"default-address": "http://localhost:33",
"headers": {
"Connection": "close"
},
"requests": [
# "/",
{
"url": "/api",
"method": "POST",
"headers": {
"Content-Length": 0
},
"body": {
"param": "value"
}
}
]
}
})
obj.engine.aggregator.prepare()
obj.prepare()
obj.engine.aggregator.startup()
obj.startup()
while not obj.check():
logging.debug("Running...")
obj.engine.aggregator.check()
time.sleep(1)
obj.shutdown()
obj.engine.aggregator.shutdown()
obj.post_process()
obj.engine.aggregator.post_process()
示例14: test_schedule_empty
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)
示例15: test_schedule_with_no_rampup
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(), io.BytesIO(b("4 test\ntest\n")), logging.getLogger(""))