def __init__(self, parent): TaskSet.__init__(self, parent) # 获得请求所需参数实例 posts_data = PostsData() self.headers = posts_data.headers # 字典类型 self.posts = posts_data.get_posts # API接口地址 self.url = '/jsonrpc'
def setUp(self) -> None: self.custom_locust = CustomLocust(Locust()) parent_task_set = TaskSet(self.custom_locust) setattr(parent_task_set, "host", "") setattr(parent_task_set, "auth", ["", ""]) self.task_set = AppianTaskSet(parent_task_set) self.task_set.host = "" # test_on_start_auth_success is covered here. self.custom_locust.set_response("auth?appian_environment=tempo", 200, '{}') if not hasattr(self.task_set, 'appian'): self.task_set.on_start() self.custom_locust.set_response( "/suite/rest/a/applications/latest/app/records/view/all", 200, self.record_types) self.custom_locust.set_response( "/suite/rest/a/sites/latest/D6JMim/pages/records/recordType/commit", 200, self.records) self.custom_locust.set_response( "/suite/rest/a/applications/latest/legacy/tempo/records/type/commit/view/all", 200, self.records) self.custom_locust.set_response( "/suite/rest/a/sites/latest/D6JMim/page/records/record/lQB0K7YxC0UQ2Fhx4pmY1F49C_MjItD4hbtRdKDmOo6V3MOBxI47ipGa_bJKZf86CLtvOCp1cfX-sa2O9hp6WTKZpbGo5MxRaaTwMkcYMeDl8kN8Hg/view/summary", 200, self.record_summary_view)
def setUp(self) -> None: self.custom_locust = CustomLocust(Locust()) self.parent_task_set = TaskSet(self.custom_locust) setattr(self.parent_task_set, "host", "") setattr(self.parent_task_set, "credentials", [["", ""]]) setattr(self.parent_task_set, "auth", ["a", "b"]) self.task_set = AppianTaskSet(self.parent_task_set) self.task_set.host = "" self.task_set.on_start()
def setUp(self) -> None: record_mode = True if integration_url else False self.custom_locust = CustomLocust(User(ENV), integration_url=integration_url, record_mode=record_mode) parent_task_set = TaskSet(self.custom_locust) setattr(parent_task_set, "host", integration_url) setattr(parent_task_set, "auth", auth) setattr(self.custom_locust, "record_mode", True) self.task_set = AppianTaskSet(parent_task_set) ENV.stats.clear_all()
def setUp(self) -> None: self.custom_locust = CustomLocust(Locust()) parent_task_set = TaskSet(self.custom_locust) setattr(parent_task_set, "host", "") setattr(parent_task_set, "auth", ["admin_user", ""]) self.task_set = AppianTaskSet(parent_task_set) self.task_set.host = "" # test_on_start_auth_success is covered here. self.custom_locust.set_response("auth?appian_environment=tempo", 200, '{}') self.task_set.on_start()
def setUpWithPath(self, base_path_override: str = None) -> None: self.custom_locust = CustomLocust(Locust()) parent_task_set = TaskSet(self.custom_locust) setattr(parent_task_set, "host", "") setattr(parent_task_set, "credentials", [["", ""]]) setattr(parent_task_set, "auth", ["", ""]) if base_path_override: setattr(parent_task_set, "base_path_override", base_path_override) self.task_set = AppianTaskSet(parent_task_set) self.task_set.on_start()
def get_project_info(task_set: TaskSet) -> ProjectInfo: """ Returns a randomly chosen project info for the locust. It expects a locust configuration with an entry for num_projects Something Like: users: SimpleLoadTest: num_projects: 10 """ locust_params = task_set.get_locust_params() num_projects = locust_params.get("num_projects", 1) return generate_project_info(num_projects)
def setUp(self) -> None: self.custom_locust = CustomLocust(User(ENV)) parent_task_set = TaskSet(self.custom_locust) setattr(parent_task_set, "host", "") setattr(parent_task_set, "auth", ["", ""]) self.task_set = AppianTaskSet(parent_task_set) self.task_set.host = "" # test_on_start_auth_success is covered here. self.custom_locust.set_response("auth?appian_environment=tempo", 200, '{}') self.task_set.on_start() self.custom_locust.set_response("/suite/rest/a/uicontainer/latest/reports", 200, self.reports) ENV.stats.clear_all()
def setUp(self) -> None: self.custom_locust = CustomLocust(Locust()) parent_task_set = TaskSet(self.custom_locust) setattr(parent_task_set, "host", "") setattr(parent_task_set, "auth", ["", ""]) self.task_set = AppianTaskSet(parent_task_set) self.task_set.host = "" # test_on_start_auth_success is covered here. self.custom_locust.set_response("auth?appian_environment=tempo", 200, '{}') self.task_set.on_start() self.custom_locust.set_response( "/suite/api/tempo/open-a-case/available-actions?ids=%5B%5D", 200, self.actions)
def setUp(self) -> None: self.custom_locust = CustomLocust(Locust()) parent_task_set = TaskSet(self.custom_locust) setattr(parent_task_set, "host", "") setattr(parent_task_set, "auth", ["", ""]) self.task_set = AppianTaskSet(parent_task_set) self.task_set.host = "" # test_on_start_auth_success is covered here. self.custom_locust.set_response("auth?appian_environment=tempo", 200, '{}') self.custom_locust.set_default_response(200, "{}") self.task_set.on_start() self.custom_locust.set_response( "/suite/rest/a/task/latest/1/attributes", 200, self.get_task_attributes(is_auto_acceptable=True)) self.custom_locust.set_response(_Tasks.INITIAL_FEED_URI, 200, self.task_feed_resp)
def setUp(self) -> None: self.custom_locust = CustomLocust(Locust()) parent_task_set = TaskSet(self.custom_locust) setattr(parent_task_set, "host", "") setattr(parent_task_set, "auth", ["", ""]) self.task_set = AppianTaskSet(parent_task_set) self.task_set.host = "" # test_on_start_auth_success is covered here. self.custom_locust.set_response("auth?appian_environment=tempo", 200, '{}') self.task_set.on_start() all_sites_str = read_mock_file("all_sites.json") self.custom_locust.set_response(_Sites.TEMPO_SITE_PAGE_NAV, 200, all_sites_str) # Default responses are page responses page_resp_json = read_mock_file("page_resp.json") self.custom_locust.client.set_default_response(200, page_resp_json)
from locust import HttpLocust, TaskSet, task ts = TaskSet()
def __init__(self, parent): TaskSet.__init__(self, parent)