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


Python locust.TaskSet方法代码示例

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


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

示例1: is_child

# 需要导入模块: import locust [as 别名]
# 或者: from locust import TaskSet [as 别名]
def is_child(self):
        """
        Return True if this TaskSet is a child of another TaskSet
        """
        return isinstance(self.parent, TaskSet) 
开发者ID:edx-unsupported,项目名称:edx-load-tests,代码行数:7,代码来源:locustfile.py

示例2: on_start

# 需要导入模块: import locust [as 别名]
# 或者: from locust import TaskSet [as 别名]
def on_start(self):
        """Raise an exception. This TaskSet is not meant to be run on its own."""
        raise Exception("This TaskSet is not meant to be run") 
开发者ID:edx-unsupported,项目名称:edx-load-tests,代码行数:5,代码来源:LMS_user_tasks.py

示例3: _is_child

# 需要导入模块: import locust [as 别名]
# 或者: from locust import TaskSet [as 别名]
def _is_child(self):
        """
        Returns True if the parent of this TaskSet instance is another TaskSet.
        """
        return isinstance(self.parent, TaskSet) 
开发者ID:edx-unsupported,项目名称:edx-load-tests,代码行数:7,代码来源:base.py

示例4: on_start

# 需要导入模块: import locust [as 别名]
# 或者: from locust import TaskSet [as 别名]
def on_start(self):
        if not self.locust._is_registered:
            self.auto_auth(params={'no_login': True})

            # If we failed to register the user, and this TaskSet is a child of the main LmsTest TaskSet, interrupt so
            # that we can select another TaskSet and try to register again.
            #
            # NOTE: this is basically a retry mechanism without backoff, so it may behoove us to add delays to this
            if self._is_child and not self.locust._is_registered:
                self.interrupt()

        if self.locust._is_registered and not self.locust._is_logged_in:
            self.login()

            # If we failed to log in, and this TaskSet is a child of the main LmsTest TaskSet, interrupt so
            # that we can select another TaskSet and try to log in again.
            #
            # NOTE: this is basically a retry mechanism without backoff, so it may behoove us to add delays to this
            if self._is_child and not self.locust._is_logged_in:
                self.interrupt()

        if self.locust._is_logged_in and not self.locust._is_enrolled:
            self.enroll(self.course_id)

            # If we failed to enroll, and this TaskSet is a child of the main LmsTest TaskSet, interrupt so
            # that we can select another TaskSet and try to enroll again.
            #
            # NOTE: this is basically a retry mechanism without backoff, so it may behoove us to add delays to this
            if self._is_child and not self.locust._is_enrolled:
                self.interrupt() 
开发者ID:edx-unsupported,项目名称:edx-load-tests,代码行数:32,代码来源:base.py

示例5: test_it_renders_a_locustfile_template

# 需要导入模块: import locust [as 别名]
# 或者: from locust import TaskSet [as 别名]
def test_it_renders_a_locustfile_template(self):
        a_name = "some_task"
        a_request = MagicMock(spec=Request)
        a_request.method = HttpMethod.GET
        a_request.url = MagicMock(spec=SplitResult)
        a_request.url.scheme = "some_scheme"
        a_request.url.hostname = "some_hostname"
        a_request.url.path = "some_path"
        a_request.url.geturl()
        a_request.url.geturl.return_value = "some_url"
        a_request.headers = {"a": "b"}
        a_request.name = None
        task = Task(a_name, a_request)
        scenario = Scenario(name="SomeScenario", children=[task], origin=None)
        scenario_group = Scenario(
            name="ScenarioGroup", children=[scenario], weight=2, origin=None
        )
        script = locustfile([scenario_group])
        expected = string.Template(
            f"""
# File automatically generated by Transformer v{__version__}:
# https://github.com/zalando-incubator/Transformer
import re
from distutils.version import LooseVersion
from locust import __version__
LOCUST_MAJOR_VERSION = LooseVersion(__version__).version[0]
if LOCUST_MAJOR_VERSION >= 1:
    from locust import HttpUser
    from locust import SequentialTaskSet
    from locust import TaskSet
    from locust import task
    HttpLocust = HttpUser
    TaskSequence = SequentialTaskSet
    def seq_task(_):
        return task
else:
    from locust import HttpLocust
    from locust import TaskSequence
    from locust import TaskSet
    from locust import seq_task
    from locust import task
class ScenarioGroup(TaskSet):
    @task(1)
    class SomeScenario(TaskSequence):
        @seq_task(1)
        def some_task(self):
            response = self.client.get(url='some_url', name='some_url', timeout=$TIMEOUT, allow_redirects=False, headers={{'a': 'b'}})
class LocustForScenarioGroup(HttpLocust):
    if LOCUST_MAJOR_VERSION >= 1:
        tasks = [ScenarioGroup]
    else:
        task_set = ScenarioGroup
    weight = 2
    min_wait = 0
    max_wait = 10
"""
        ).safe_substitute({"TIMEOUT": TIMEOUT})
        assert expected.strip() == script.strip() 
开发者ID:zalando-incubator,项目名称:transformer,代码行数:60,代码来源:test_locust.py


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