在GitLab CI管道中使用蝗虫测试,用户永远不会产卵



我尝试使用GitLab CI运行蝗虫测试,但是,我遇到了一个问题,即用户实际上并没有生成,即使已经显示了相应的消息。

.gitlab ci.yml.场景的简化版本位于一个单独的文件中,如本问题中建议的@Cyberwiz。此外,我试图通过测试将场景添加到同一个locostfile.py中,但它没有改变。

load_test:
image: python:3.9-slim-buster
before_script:
- pip install virtualenv
- virtualenv venv
- source venv/bin/activate
- pip install -r requirements.txt
- locust -V
script:
- locust -H https://host -f locustfile.py,scenario.py --autostart --autoquit 0 --html locust_report.html

locostfile.py看起来是这样的。我总共有10个用户,每个用户都有唯一的电子邮件,我在20秒内逐一登录。添加了LOAD CLASSUSER AUTH打印,以了解这些登录何时在管道中发生(请参阅管道日志(。

USER_EMAILS = [ ... emails ... ]
print(f"nUSER EMAILS: {USER_EMAILS}")


class SocialLoad(TaskSet):

print(f"nLOAD CLASS") # for debugging

def on_start(self):
self.login()
...
tasks
...
def login():
print(f"nUSER AUTH")
...

GitLab管道日志。看起来LOAD CLASSUSER AUTH打印发生在所有关于生成用户的消息之后,这对我来说很奇怪。当我在没有CI的情况下运行此测试时,它们在生成过程中正常发生。

[2022-10-04 20:14:24,657] runner-g-idswu7-project-4001-concurrent-0/INFO/locust.main: Starting web interface at http://0.0.0.0:8089 (accepting connections from all network interfaces)
[2022-10-04 20:14:24,666] runner-g-idswu7-project-4001-concurrent-0/INFO/locust.main: Starting Locust 2.12.0
[2022-10-04 20:14:24,666] runner-g-idswu7-project-4001-concurrent-0/INFO/locust.runners: Shape test starting. User count and spawn rate are ignored for this type of load test
[2022-10-04 20:14:24,671] runner-g-idswu7-project-4001-concurrent-0/INFO/locust.runners: Shape worker starting
[2022-10-04 20:14:24,671] runner-g-idswu7-project-4001-concurrent-0/INFO/locust.runners: Shape test updating to 10 users at 0.50 spawn rate
[2022-10-04 20:14:24,672] runner-g-idswu7-project-4001-concurrent-0/INFO/locust.runners: Ramping to 10 users at a rate of 0.50 per second
[2022-10-04 20:14:42,680] runner-g-idswu7-project-4001-concurrent-0/INFO/locust.runners: All users spawned: {"User": 10} (10 total users)
[2022-10-04 20:15:24,722] runner-g-idswu7-project-4001-concurrent-0/INFO/locust.runners: Shape test stopping
[2022-10-04 20:15:24,732] runner-g-idswu7-project-4001-concurrent-0/INFO/locust.main: --run-time limit reached, stopping test
[2022-10-04 20:15:24,732] runner-g-idswu7-project-4001-concurrent-0/INFO/locust.main: --autoquit time reached, shutting down
[2022-10-04 20:15:24,760] runner-g-idswu7-project-4001-concurrent-0/INFO/locust.main: writing html report to file: locust_report.html
[2022-10-04 20:15:24,761] runner-g-idswu7-project-4001-concurrent-0/INFO/locust.main: Shutting down (exit code 0)
Type     Name                                                                          # reqs      # fails |    Avg     Min     Max    Med |   req/s  failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
Aggregated                                                                         0     0(0.00%) |      0       0       0      0 |    0.00        0.00
Response time percentiles (approximated)
Type     Name                                                                                  50%    66%    75%    80%    90%    95%    98%    99%  99.9% 99.99%   100% # reqs
--------|--------------------------------------------------------------------------------|--------|------|------|------|------|------|------|------|------|------|------|------
--------|--------------------------------------------------------------------------------|--------|------|------|------|------|------|------|------|------|------|------|------
USER EMAILS: [ ... emails ... ]
SOCIAL LOAD
STARTED USER AUTH
STARTED USER AUTH
STARTED USER AUTH
STARTED USER AUTH
STARTED USER AUTH
STARTED USER AUTH
STARTED USER AUTH
STARTED USER AUTH
STARTED USER AUTH
STARTED USER AUTH

结果为空。此外,我打印出了crededlocust_report.html文件,该文件恰好也是空的。

问题:即使显示了All users spawned: {"User": 10} (10 total users)消息,看起来用户永远不会生成。是的,有print,这表明login()函数已经被调用,但是,登录本身(print之后的代码,在这里的代码片段中没有(从未发生过。如果是这样的话,在测试运行时,有可能让它们"正常"繁殖吗?

我认为根本原因与检索电子邮件步骤有关,因为当我只对一个用户运行另一个简单的测试(并且没有检索任何电子邮件(时,一切都很顺利。

碰巧根本原因是服务器端的VPN,它的白名单中没有包括所需的IP。

相关内容

最新更新