locust

multipledispatch ModuleNotFoundError running from command-line

一世执手 提交于 2021-02-08 06:40:14
问题 Running a locust (locust.io) script from the command line. locust calls main.py which has the following imports: from locust import HttpUser, between, task from StreamLoader.stream_generator import * # thought this brings in everything Packer.py has these imports: from multipledispatch import dispatch from PackedItem import PackedItem StreamGenerator.py has: import hashlib from StreamLoader.Packer import Packer from aes_encryption import AesEncryption I used pip to install multipledispatch

Headless browser and locust.io

﹥>﹥吖頭↗ 提交于 2021-02-08 06:35:34
问题 Is it possible to integrate a headless browser with locust? I need my load tests to process client side script that triggers additional requests on each page load. 回答1: That's an old question, but I came across it now, and found a solution in "realbrowserlocusts" (https://github.com/nickboucart/realbrowserlocusts) - it adds "Real Browser support for Locust.io load testing" using selenium. If you use one of its classes (FirefoxLocust, ChromeLocust, PhantomJSLocust) instead of HttpLocust for

Exception handling with Realbrowserlocusts

蓝咒 提交于 2021-01-29 08:28:13
问题 In using realbrowserlocusts class it appears that I'm limited in any exception handling. The only reference that partially works is: self.client.wait.until(EC.visibility_of_element_located .... In a failed condition where the element is not found the script simply starts over again. With the script I'm working with I need to maintain a solid session state; I need to throw and exception(report an error), log the user out and then let the script start over again. I've been testing out the

Locust Request Statistics

久未见 提交于 2021-01-24 07:41:47
问题 I'm considering using locust for some of my performance tests. I'm more familiar with Python and find locust much easier to read than JMeter JMX. One thing I'm accustomed to doing with JMeter is generating my own average, 90pct, 95pct, and 99pct reports from multiple runs. To do this, I've written a script that parses the JMeter logs which contain information on every request (response time, payload size, etc.), and then combine all the runs into a single data set and generate average and

Locust性能-零基础入门系列(9)-SequentialTaskSet应用

ぐ巨炮叔叔 提交于 2020-12-24 07:38:33
**第一部分:** 在流量压力情况下,怎么保证多用户(线程)在执行多个测试任务时遵循一定的顺序,而不是一种随机的现象。这种需求在Locust中也是可以实现的,可以将taskset继承TaskSet的子类SequentialTaskSet。以一个例子来说明这种用法: from locust import User,SequentialTaskSet,task,between def function_task(l): print("This is the function task") class MyUser(User): wait_time = between(5,9) @task class SequenceOfTasks(SequentialTaskSet): @task def first_task(self): print("this is the first task") tasks = [function_task] @task def second_task(self): print("this is the second task") @task def third_task(self): print("this is the third task") 以上代码例子中,SequeneOfTasks类是嵌入到MyUser类中的

Locust性能-零基础入门系列(9)-SequentialTaskSet应用

耗尽温柔 提交于 2020-12-24 07:38:19
第一部分: 在流量压力情况下,怎么保证多用户(线程)在执行多个测试任务时遵循一定的顺序,而不是一种随机的现象。这种需求在Locust中也是可以实现的,可以将taskset继承TaskSet的子类SequentialTaskSet。以一个例子来说明这种用法: from locust import User,SequentialTaskSet,task,between def function_task(l): print("This is the function task") class MyUser(User): wait_time = between(5,9) @task class SequenceOfTasks(SequentialTaskSet): @task def first_task(self): print("this is the first task") tasks = [function_task] @task def second_task(self): print("this is the second task") @task def third_task(self): print("this is the third task") 以上代码例子中,SequeneOfTasks类是嵌入到MyUser类中的

linux下的文件操作——批量重命名

十年热恋 提交于 2020-12-24 02:27:31
概述:在日常工作中,我们经常需要对一批文件进行重命名操作,例如将所有的jpg文件改成bnp,将名字中的1改成one,等等。文本主要为你讲解如何实现这些操作 1、删除所有的 .bak 后缀: rename 's/\.bak$//' *.bak 注意,这个命令的格式组织如下:s/ \.bark$ / / 是s/para1/para2/ 这个有点想sed的语法,将para1匹配的字符串换成para2 2、把 .jpe 文件后缀修改为 .jpg: rename 's/\.jpe$/\.jpg/' *.jpe 3、把所有文件的文件名改为小写: rename 'y/A-Z/a-z/' * 4、将 abcd.jpg 重命名为 abcd_efg.jpg: for var in *.jpg; do mv "$var" "${var%.jpg}_efg.jpg"; done 其中,此处涉及到shell的字符串匹配操作: 1> ${variable#pattern} 如果pattern匹配variable的开始部分,从variable的开始处删除字符直到第一个匹配的位置,包括匹配部分,返回剩余部分。 2> ${variable##pattern} 如果pattern匹配variable的开始部分,从variable的开始处删除字符直到最后一个匹配的位置,包括匹配部分,返回剩余部分。 3> $

Problem updating Locust script to 1.x: TypeError: __init__() takes 1 positional argument but 2 were given

一世执手 提交于 2020-12-13 03:37:28
问题 Having changed (0.x style) class MyBaseLocust(Locust): def __init__(self): super(MyLocust, self).__init__() to (1.x style) class MyBaseUser(User): def __init__(self): super(MyBaseUser, self).__init__() I get: [2020-07-17 14:16:33,694] XXX/CRITICAL/locust.runners: Unhandled exception in greenlet: <Greenlet at 0x28639396378: <lambda>> Traceback (most recent call last): ... in spawn_users hatch() File "c:\venv\project\lib\site-packages\locust\runners.py", line 165, in hatch new_user = user_class

locust压测入门

不羁的心 提交于 2020-12-10 19:35:59
一、安装 pip install locust 了解locust相关命令:locust --help 二、获取当前CPU核心数 (后面需要根据核心数起进程) pip3 install psutil ``` import pustil print(pustil.cpu_count(False)) ``` 三、准备压测脚本(lc.py): ``` # 这是一个压测的临时脚本. import requests import json import uuid import time from locust import between, task, constant from locust.contrib.fasthttp import FastHttpUser import random # from utils.data import data data = { "header": [["query"]], "data": [ {"query": "后海大鲨鱼"}, {"query": "这个衣服宽松不"}, {"query": "包装好点"}, ], } class WebsiteUser(FastHttpUser): wait_time = between(1, 1) host = "http://nta-api-ks.leyanbot.com" def body(self):

接口测试人员需要掌握的知识技能

别来无恙 提交于 2020-11-03 09:07:14
一、首先明白接口是什么 软件接口是指程序中具体负责在不同模块之间传输或接受数据的并做处理的类或者函数。(而不是指传输的数据!!) 二、什么是接口测试 接口测试就是通过向接口传递数据来测试这个接口是否正确。比如:一个QQ登录功能接口,就需要我们传递QQ号和密码去验证这个登录接口是否正确,能否使用。 三、进行接口测试需要掌握哪些知识 1、了解系统及内部各个组件之间的业务逻辑交互; 2、了解接口的I/O(input/output:输入输出); 3、了解协议的基本内容,包括:通信原理、三次握手、常用的协议类型、报文构成、数据传输方式、常见的状态码、URL构成等; 4、常用的接口测试工具,比如:apipost、jmeter、loadrunner、soapUI等; 5、数据库基础操作命令(检查数据入库、提取测试数据等); 6、常见的字符类型,比如:char、varchar、text、int、float、datatime、string等; 四、如何学这些技能? 1、系统间业务交互逻辑:通过需求文档、流程图、思维导图、沟通等很多渠道和方式; 2、协议:推荐《图解http》这本书,内容生动,相对算是入门级的书籍,其他的还有《图解tcp、IP》等; 3、接口测试工具:百度这些工具,然后你会发现,好多的教学博客、相关问题解决方案、以及一些基于工具的书籍,当然,选择合适的书很重要; 4、数据库操作命令