当前位置: 首页>>代码示例>>Python>>正文


Python GrinderExecutor.prepare方法代码示例

本文整理汇总了Python中bzt.modules.grinder.GrinderExecutor.prepare方法的典型用法代码示例。如果您正苦于以下问题:Python GrinderExecutor.prepare方法的具体用法?Python GrinderExecutor.prepare怎么用?Python GrinderExecutor.prepare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bzt.modules.grinder.GrinderExecutor的用法示例。


在下文中一共展示了GrinderExecutor.prepare方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_install_Grinder

# 需要导入模块: from bzt.modules.grinder import GrinderExecutor [as 别名]
# 或者: from bzt.modules.grinder.GrinderExecutor import prepare [as 别名]
    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
开发者ID:PurdyForks,项目名称:taurus,代码行数:31,代码来源:test_Grinder.py

示例2: test_fail_on_zero_results

# 需要导入模块: from bzt.modules.grinder import GrinderExecutor [as 别名]
# 或者: from bzt.modules.grinder.GrinderExecutor import prepare [as 别名]
 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)
开发者ID:dotIN,项目名称:taurus,代码行数:9,代码来源:test_Grinder.py

示例3: test_grinder_widget

# 需要导入模块: from bzt.modules.grinder import GrinderExecutor [as 别名]
# 或者: from bzt.modules.grinder.GrinderExecutor import prepare [as 别名]
 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")
开发者ID:Yingmin-Li,项目名称:taurus,代码行数:9,代码来源:test_GrinderExecutor.py

示例4: test_install_Grinder

# 需要导入模块: from bzt.modules.grinder import GrinderExecutor [as 别名]
# 或者: from bzt.modules.grinder.GrinderExecutor import prepare [as 别名]
    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))
开发者ID:VegiS,项目名称:taurus,代码行数:29,代码来源:test_Grinder.py

示例5: test_resource_files_collection_local

# 需要导入模块: from bzt.modules.grinder import GrinderExecutor [as 别名]
# 或者: from bzt.modules.grinder.GrinderExecutor import prepare [as 别名]
 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)
开发者ID:Yingmin-Li,项目名称:taurus,代码行数:10,代码来源:test_GrinderExecutor.py

示例6: test_grinder_widget

# 需要导入模块: from bzt.modules.grinder import GrinderExecutor [as 别名]
# 或者: from bzt.modules.grinder.GrinderExecutor import prepare [as 别名]
 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")
开发者ID:dotIN,项目名称:taurus,代码行数:13,代码来源:test_Grinder.py

示例7: test_script_generation

# 需要导入模块: from bzt.modules.grinder import GrinderExecutor [as 别名]
# 或者: from bzt.modules.grinder.GrinderExecutor import prepare [as 别名]
    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))
开发者ID:PurdyForks,项目名称:taurus,代码行数:55,代码来源:test_Grinder.py

示例8: test_fail_on_zero_results

# 需要导入模块: from bzt.modules.grinder import GrinderExecutor [as 别名]
# 或者: from bzt.modules.grinder.GrinderExecutor import prepare [as 别名]
 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)
开发者ID:PurdyForks,项目名称:taurus,代码行数:15,代码来源:test_Grinder.py

示例9: test_with_results

# 需要导入模块: from bzt.modules.grinder import GrinderExecutor [as 别名]
# 或者: from bzt.modules.grinder.GrinderExecutor import prepare [as 别名]
    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()
开发者ID:PurdyForks,项目名称:taurus,代码行数:19,代码来源:test_Grinder.py

示例10: test_full_Grinder

# 需要导入模块: from bzt.modules.grinder import GrinderExecutor [as 别名]
# 或者: from bzt.modules.grinder.GrinderExecutor import prepare [as 别名]
    def test_full_Grinder(self):
        obj = GrinderExecutor()
        obj.kpi_file = os.path.abspath(__dir__() + "/../grinder/test.log")
        obj.engine = EngineEmul()
        obj.execution.merge(
            {"concurrency": {"local": 2}, "hold-for": 5, "scenario": {"requests": ["http://blazedemo.com"]}}
        )
        obj.prepare()

        try:
            obj.cmd_line = __dir__() + "/../grinder/grinder.sh"
            obj.startup()
            while not obj.check():
                time.sleep(obj.engine.check_interval)
        finally:
            obj.shutdown()
        self.assertRaises(RuntimeWarning, obj.post_process)
开发者ID:VegiS,项目名称:taurus,代码行数:19,代码来源:test_Grinder.py

示例11: test_full_Grinder

# 需要导入模块: from bzt.modules.grinder import GrinderExecutor [as 别名]
# 或者: from bzt.modules.grinder.GrinderExecutor import prepare [as 别名]
    def test_full_Grinder(self):
        obj = GrinderExecutor()
        obj.kpi_file = os.path.abspath(__dir__() + '/../grinder/test.log')
        obj.engine = EngineEmul()
        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()
        self.assertRaises(RuntimeWarning, obj.post_process)
开发者ID:dotIN,项目名称:taurus,代码行数:24,代码来源:test_Grinder.py

示例12: test_requests

# 需要导入模块: from bzt.modules.grinder import GrinderExecutor [as 别名]
# 或者: from bzt.modules.grinder.GrinderExecutor import prepare [as 别名]
 def test_requests(self):
     obj = GrinderExecutor()
     obj.engine = EngineEmul()
     obj.settings.merge({'path': __dir__() + "/../grinder/fake_grinder.jar"})
     obj.execution.merge({"scenario": {"requests": ['http://blazedemo.com']}})
     obj.prepare()
开发者ID:PurdyForks,项目名称:taurus,代码行数:8,代码来源:test_Grinder.py

示例13: test_requests

# 需要导入模块: from bzt.modules.grinder import GrinderExecutor [as 别名]
# 或者: from bzt.modules.grinder.GrinderExecutor import prepare [as 别名]
 def test_requests(self):
     obj = GrinderExecutor()
     obj.engine = EngineEmul()
     obj.execution.merge({"scenario": {"requests": ['http://blazedemo.com']}})
     obj.prepare()
开发者ID:dotIN,项目名称:taurus,代码行数:7,代码来源:test_Grinder.py


注:本文中的bzt.modules.grinder.GrinderExecutor.prepare方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。