當前位置: 首頁>>代碼示例>>Python>>正文


Python grinder.GrinderExecutor類代碼示例

本文整理匯總了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
開發者ID:PurdyForks,項目名稱:taurus,代碼行數:29,代碼來源:test_Grinder.py

示例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))
開發者ID:VegiS,項目名稱:taurus,代碼行數:27,代碼來源:test_Grinder.py

示例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)
開發者ID:dotIN,項目名稱:taurus,代碼行數:7,代碼來源:test_Grinder.py

示例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)
開發者ID:Yingmin-Li,項目名稱:taurus,代碼行數:8,代碼來源:test_GrinderExecutor.py

示例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)
開發者ID:Yingmin-Li,項目名稱:taurus,代碼行數:8,代碼來源:test_GrinderExecutor.py

示例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)
開發者ID:vasischev,項目名稱:taurus,代碼行數:9,代碼來源:test_GrinderExecutor.py

示例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))
開發者ID:PurdyForks,項目名稱:taurus,代碼行數:53,代碼來源:test_Grinder.py

示例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())
開發者ID:Yingmin-Li,項目名稱:taurus,代碼行數:12,代碼來源:test_GrinderExecutor.py

示例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)
開發者ID:PurdyForks,項目名稱:taurus,代碼行數:13,代碼來源:test_Grinder.py

示例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()
開發者ID:PurdyForks,項目名稱:taurus,代碼行數:17,代碼來源:test_Grinder.py

示例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")
開發者ID:Yingmin-Li,項目名稱:taurus,代碼行數:7,代碼來源:test_GrinderExecutor.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")
開發者ID:dotIN,項目名稱:taurus,代碼行數:11,代碼來源:test_Grinder.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)
開發者ID:PurdyForks,項目名稱:taurus,代碼行數:6,代碼來源:test_Grinder.py

示例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())
開發者ID:PurdyForks,項目名稱:taurus,代碼行數:24,代碼來源:test_Grinder.py

示例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
開發者ID:keithmork,項目名稱:taurus,代碼行數:6,代碼來源:test_Grinder.py


注:本文中的bzt.modules.grinder.GrinderExecutor類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。