我需要加载测试Odoo环境,我已经在其中编写了一个带有不同方法的测试类。目前我正在尝试在本地测试这些东西,但我遇到了一个我现在不理解的错误。
Traceback (most recent call last):
File "src/gevent/greenlet.py", line 908, in gevent._gevent_cgreenlet.Greenlet.run
File "/home/jhoffmann/ametras_odoo_stress_testing/venv/lib/python3.8/site-packages/locust/user/users.py", line 175, in run_user
user.run()
File "/home/jhoffmann/ametras_odoo_stress_testing/venv/lib/python3.8/site-packages/locust/user/users.py", line 143, in run
self._taskset_instance.run()
File "/home/jhoffmann/ametras_odoo_stress_testing/venv/lib/python3.8/site-packages/locust/user/task.py", line 365, in run
self.wait()
File "/home/jhoffmann/ametras_odoo_stress_testing/venv/lib/python3.8/site-packages/locust/user/task.py", line 443, in wait
self._sleep(self.wait_time())
File "/home/jhoffmann/ametras_odoo_stress_testing/venv/lib/python3.8/site-packages/locust/user/task.py", line 418, in wait_time
return self.user.wait_time()
TypeError: <lambda>() missing 1 required positional argument: 'instance'
2022-10-20T11:30:13Z <Greenlet at 0x7f49e55376a0: run_user(<__main__.OdooTestCasesUser object at 0x7f49e51f46)> failed with TypeError
我已经写了以下测试类
class OdooTestCases(TaskSet):
weight = 10
fixed_count = 1
min_wait = 0.5
max_wait = 5.0
@task(20)
def read_partners(self):
customer_model = self.client.get_model("res.partner")
customer_ids = customer_model.search([], limit=80)
@task(10)
def read_product_template_qty(self):
customer_model = self.client.get_model("product.template")
customer_ids = customer_model.search([], limit=80)
@task(10)
def read_sale_orders(self):
so_model = self.client.get_model("sale.order")
so_ids = so_model.search([], limit=100)
@task(20)
def read_stock_pickings(self):
stock_picking_model = self.client.get_model("stock.picking")
stock_pickings = stock_picking_model.search([], limit=100)
@task(20)
def read_stock_movings(self):
stock_moving_model = self.client.get_model("stock.move")
stock_movings = stock_moving_model.search([], limit=100)
@task(30)
def read_stock_locations(self):
stock_location_model = self.client.get_model("stock.location")
stock_locations = stock_location_model.search([], limit=100)
@task(25)
def read_stock_picking_types(self):
stock_picking_type_model = self.client.get_model("stock.picking.type")
stock_picking_types = stock_picking_type_model.search([], limit=100)
def stop(self):
self.interrupt()
class OdooTestCasesUser(OdooLocustUser):
wait_time = between(0.500, 5)
host = "localhost"
database = "demo"
login = "test"
password = "test"
def __init__(self, parent):
super().__init__(parent)
self.login = "test"
self.password = "test"
self.wait_time = between(0.500, 5)
self.tasks = [OdooTestCases]
另一个问题是,我无法在CLI上返回测试结果。我想尽一切办法来解决这个问题,我在互联网上发现了这些,但没有成功。如果有人能给我一个猜测或解决方案,我会非常高兴。如果有人需要更多关于这个案子的信息,请打电话给我。
看起来您正在使用传统风格的等待时间:
min_wait = 0.5
max_wait = 5.0
AND新型
wait_time = ...
也许可以删除遗留的?