本文整理汇总了Python中bzt.modules.grinder.GrinderExecutor类的典型用法代码示例。如果您正苦于以下问题:Python GrinderExecutor类的具体用法?Python GrinderExecutor怎么用?Python GrinderExecutor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GrinderExecutor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_install_Grinder
def test_install_Grinder(self):
path = os.path.abspath(__dir__() + "/../../build/tmp/grinder-taurus/lib/grinder.jar")
shutil.rmtree(os.path.dirname(os.path.dirname(path)), ignore_errors=True)
grinder_link = GrinderExecutor.DOWNLOAD_LINK
grinder_version = GrinderExecutor.VERSION
mirrors_source = GrinderExecutor.MIRRORS_SOURCE
GrinderExecutor.DOWNLOAD_LINK = "file:///" + __dir__() + "/../data/grinder-{version}_{version}-binary.zip"
GrinderExecutor.VERSION = "3.11"
GrinderExecutor.MIRRORS_SOURCE = "file:///" + __dir__() + "/../data/unicode_file"
self.assertFalse(os.path.exists(path))
obj = GrinderExecutor()
obj.engine = EngineEmul()
obj.settings.merge({"path": path})
obj.settings.merge({"properties-file": __dir__() + "/../grinder/grinder.base.properties",
"properties": {"sample_prop": "some_val"}})
obj.execution.merge({"scenario": {
"script": __dir__() + "/../grinder/helloworld.py",
"properties-file": __dir__() + "/..//grinder/grinder.properties",
"properties": {"grinder.useConsole": "false"}}})
obj.prepare()
self.assertTrue(os.path.exists(path))
GrinderExecutor.DOWNLOAD_LINK = grinder_link
GrinderExecutor.VERSION = grinder_version
GrinderExecutor.MIRRORS_SOURCE = mirrors_source
示例2: test_install_Grinder
def test_install_Grinder(self):
path = os.path.abspath(__dir__() + "/../../build/tmp/grinder-taurus/lib/grinder.jar")
shutil.rmtree(os.path.dirname(os.path.dirname(path)), ignore_errors=True)
self.assertFalse(os.path.exists(path))
obj = GrinderExecutor()
obj.engine = EngineEmul()
obj.settings.merge({"path": path})
obj.settings.merge(
{
"properties-file": __dir__() + "/../grinder/grinder.base.properties",
"properties": {"sample_prop": "some_val"},
}
)
obj.execution.merge(
{
"scenario": {
"script": __dir__() + "/../grinder/helloworld.py",
"properties-file": __dir__() + "/..//grinder/grinder.properties",
"properties": {"grinder.useConsole": "false"},
}
}
)
obj.prepare()
self.assertTrue(os.path.exists(path))
示例3: test_fail_on_zero_results
def test_fail_on_zero_results(self):
obj = GrinderExecutor()
obj.engine = EngineEmul()
obj.execution.merge({"concurrency": {"local": 2},
"scenario": {"script": __dir__() + "/../grinder/helloworld.py"}})
obj.prepare()
self.assertRaises(RuntimeWarning, obj.post_process)
示例4: test_resource_files_collection_noscript
def test_resource_files_collection_noscript(self):
obj = GrinderExecutor()
obj.engine = EngineEmul()
obj.execution.merge({"scenario": {"properties-file": "tests/grinder/grinder.properties"}})
res_files = obj.resource_files()
artifacts = os.listdir(obj.engine.artifacts_dir)
self.assertEqual(len(res_files), 2)
self.assertEqual(len(artifacts), 2)
示例5: test_resource_files_collection_local
def test_resource_files_collection_local(self):
obj = GrinderExecutor()
obj.engine = EngineEmul()
obj.execution.merge({"scenario": {"script": "tests/grinder/helloworld.py",
"properties-file": "tests/grinder/grinder.properties"}})
obj.prepare()
artifacts = os.listdir(obj.engine.artifacts_dir)
self.assertEqual(len(artifacts), 2)
示例6: test_resource_files_collection_remote
def test_resource_files_collection_remote(self):
obj = GrinderExecutor()
obj.engine = EngineEmul()
obj.execution.merge({"scenario": {"script": __dir__() + "/../grinder/helloworld.py",
"properties-file": __dir__() + "/../grinder/grinder.properties"}})
res_files = obj.resource_files()
artifacts = os.listdir(obj.engine.artifacts_dir)
self.assertEqual(len(res_files), 2)
self.assertEqual(len(artifacts), 2)
示例7: test_script_generation
def test_script_generation(self):
obj = GrinderExecutor()
obj.engine = EngineEmul()
obj.settings.merge({'path': __dir__() + "/../grinder/fake_grinder.jar"})
obj.execution.merge({
"scenario": {
"default-address": "http://blazedemo.com",
"headers": {
"My-Header": "Its-Value",
"Another-Header": "Another-Value",
},
"timeout": "30s",
"think-time": "2s",
"store-cookie": True,
"requests": [
'/',
{'url': 'http://example.com/',
'method': 'POST',
'think-time': "1s",
'headers': {
'Custom': 'Header',
}},
]
}
})
obj.prepare()
script = open(os.path.join(obj.engine.artifacts_dir, 'grinder_requests.py')).read()
default_addr = re.findall(r"url='http://blazedemo.com'", script)
self.assertEquals(1, len(default_addr))
requests = re.findall(r"request\.([A-Z]+)\('(.+?)'", script)
self.assertEquals(2, len(requests))
self.assertEquals(requests[0], ('GET', '/'))
self.assertEquals(requests[1], ('POST', 'http://example.com/'))
sleeps = re.findall(r"grinder\.sleep\((.+)\)", script)
self.assertEquals(2, len(sleeps))
self.assertEquals(sleeps[0], '2000')
self.assertEquals(sleeps[1], '1000')
headers = re.findall(r"NVPair\('(.+)', '(.+)'\)", script)
self.assertEquals(3, len(headers))
self.assertIn(("My-Header", "Its-Value"), headers)
self.assertIn(("Another-Header", "Another-Value"), headers)
self.assertIn(("Custom", "Header"), headers)
timeout = re.findall(r"defaults.setTimeout\((\d+)\)", script)
self.assertEquals(1, len(timeout))
self.assertEquals(timeout[0], '30000')
cookies = re.findall(r"defaults.setUseCookies\(1\)", script)
self.assertEquals(1, len(cookies))
示例8: test_resource_files_collection_invalid
def test_resource_files_collection_invalid(self):
obj = GrinderExecutor()
obj.engine = EngineEmul()
obj.execution.merge({"scenario": {"script": "tests/grinder/helloworld.py",
"properties-file": "tests/grinder/grinder_invalid.properties"}})
res_files = obj.resource_files()
artifacts = os.listdir(obj.engine.artifacts_dir)
self.assertEqual(len(res_files), 2)
self.assertEqual(len(artifacts), 2)
self.assertIn("helloworld.py", open(os.path.join(obj.engine.artifacts_dir,
"grinder_invalid.properties")).read())
示例9: test_fail_on_zero_results
def test_fail_on_zero_results(self):
obj = GrinderExecutor()
obj.engine = EngineEmul()
obj.settings.merge({'path': __dir__() + "/../grinder/fake_grinder.jar"})
obj.execution.merge({"concurrency": {"local": 2},
"scenario": {"script": __dir__() + "/../grinder/helloworld.py"}})
obj.prepare()
obj.engine.prepared = [obj]
obj.engine.started = [obj]
obj.engine.provisioning = Local()
obj.engine.provisioning.engine = obj.engine
obj.engine.provisioning.executors = [obj]
self.assertRaises(RuntimeWarning, obj.engine.provisioning.post_process)
示例10: test_with_results
def test_with_results(self):
obj = GrinderExecutor()
obj.engine = EngineEmul()
obj.settings.merge({'path': __dir__() + "/../grinder/fake_grinder.jar"})
obj.execution.merge({
"concurrency": {"local": 2},
"scenario": {"script": __dir__() + "/../grinder/helloworld.py"}})
obj.prepare()
obj.engine.prepared = [obj]
obj.engine.started = [obj]
prov = Local()
prov.engine = obj.engine
prov.executors = [obj]
obj.engine.provisioning = prov
obj.reader.buffer = ['some info']
obj.engine.provisioning.post_process()
示例11: test_grinder_widget
def test_grinder_widget(self):
obj = GrinderExecutor()
obj.engine = EngineEmul()
obj.execution.merge({"scenario": {"script": "tests/grinder/helloworld.py"}})
obj.prepare()
obj.get_widget()
self.assertEqual(obj.widget.script_name.text, "Script: helloworld.py")
示例12: test_grinder_widget
def test_grinder_widget(self):
obj = GrinderExecutor()
obj.engine = EngineEmul()
obj.engine.config.merge({"provisioning": 'local'})
obj.execution.merge({"concurrency": {"local": 2},
"ramp-up": 2,
"hold-for": 2,
"scenario": {"script": __dir__() + "/../grinder/helloworld.py"}})
obj.prepare()
obj.get_widget()
self.assertEqual(obj.widget.widgets[0].text, "Script: helloworld.py")
示例13: test_resource_files_collection_basic
def test_resource_files_collection_basic(self):
obj = GrinderExecutor()
obj.engine = EngineEmul()
obj.execution.merge({"scenario": {"script": __dir__() + "/../grinder/helloworld.py"}})
res_files = obj.resource_files()
self.assertEqual(len(res_files), 1)
示例14: test_full_Grinder
def test_full_Grinder(self):
obj = GrinderExecutor()
obj.kpi_file = os.path.abspath(__dir__() + '/../grinder/test.log')
obj.engine = EngineEmul()
obj.settings.merge({'path': __dir__() + "/../grinder/fake_grinder.jar"})
obj.execution.merge({"concurrency": {"local": 2},
"hold-for": 5,
"scenario": {"requests": ['http://blazedemo.com']}})
obj.prepare()
self.assertEqual(len(obj.cmd_line), 5)
cmd_line = ' '.join(obj.cmd_line)
self.assertTrue(cmd_line.startswith('java -classpath'))
self.assertNotEqual(cmd_line.find('net.grinder.Grinder'), -1)
try:
obj.cmd_line = __dir__() + "/../grinder/grinder" + EXE_SUFFIX
obj.startup()
while not obj.check():
time.sleep(obj.engine.check_interval)
finally:
obj.shutdown()
obj.post_process()
self.assertFalse(obj.has_results())
示例15: get_grinder
def get_grinder():
obj = GrinderExecutor()
obj.engine = EngineEmul()
obj.env = obj.engine.env
obj.settings.merge({'path': RESOURCES_DIR + "grinder/fake_grinder.jar"})
return obj