邮件调用如何与LOcustIO一起使用?我怀疑Locust没有做它想做的事情,因为它正在运行所有负载测试的返回成功所以我决定发布,使用LocustIO通过Web应用程序写入数据库,令我惊讶的是没有写入db 。虽然我知道有些人已成功完成此操作,但我想知道如何使用LocustIO作为负载测试的一部分来写入Db。
这是使用的代码:
from locust import HttpLocust, TaskSet, task
import logging, sys
from credentials import *
class LoginWithUniqueUsersSteps(TaskSet):
institutionCode = "NOT_FOUND"
username = "NOT_FOUND"
password = "NOT_FOUND"
def on_start(self):
if len(USER_CREDENTIALS) > 0:
self.institutionCode, self.username, self.password = USER_CREDENTIALS.pop()
@task
def login(self):
self.client.post("/dejavuweb/", {
'institutionCode': self.institutionCode, 'email': self.username, 'password': self.password
})
logging.info('Login with %s institutionCode %s username and %s password', self.institutionCode, self.username, self.password)
@task
def createTerminal(self):
response = self.client.request(method="POST", url="/dejavuweb/Home#Function/7", data= {"TerminalName": "RealterminalName"})
print("Create; Response status code:", response.status_code)
print("Create; Response content:", response.content)
class LoginWithUniqueUsersTest(HttpLocust):
task_set = LoginWithUniqueUsersSteps
host = "http://dev.trublend.cloud"
sock = None
def __init__(self):
super(LoginWithUniqueUsersTest, self).__init__()
请注意,我复制,编辑上面的代码片段以实现我想要的效果。
LocustIO结果的屏幕截图: