我正在使用Locust对应用程序进行负载测试。它具有IP地址而不是网址,即192.24.130.8080/app。
要让用户登录,用户将被重定向到KeyCloak身份验证服务,该服务类似于以下内容:
我有以下代码,使用用户名和登录密码。但是,当我将代码中的密码更改为错误的密码时,负载测试的运行方式相同。这向我表明,我只是在点击此重定向页面,而没有越过它。
from locust import HttpLocust, TaskSet, task
class UserBehavior(TaskSet):
def on_start(self):
""" on_start is called when a Locust start before any task is scheduled """
self.login()
def on_stop(self):
""" on_stop is called when the TaskSet is stopping """
self.logout()
def login(self):
self.client.post("/app/&response_type=code&scope=openid#/", {"user":"user100", "password":"sun"})
def logout(self):
self.client.post("/app/&response_type=code&scope=openid#/", {"user":"user100", "password":"sun"})
@task(3)
def app(self):
self.client.get("/index/#/")
@task(1)
def app2(self):
self.client.get("/account/932507")
class UserWait(HttpLocust):
task_set = UserBehavior
#1000 ms = 1 second
min_wait = 2000
max_wait = 3000
我不确定如何通过此Keycloak oauth。任何帮助将不胜感激!
答案 0 :(得分:0)
您应该知道select e.c1
from employee e
where not exists (select 1 from employee1 e1 where e1.c1 = e.c1);
只是python请求会话的包装。您可以直接查看python-requests oauth handling以获得解决方案。